lintr icon indicating copy to clipboard operation
lintr copied to clipboard

Bioconductor style linters

Open jimhester opened this issue 9 years ago • 14 comments

Add as an optional default perhaps?

http://bioconductor.org/developers/how-to/coding-style/

jimhester avatar Feb 02 '15 22:02 jimhester

@jimhester Any update on this? Would love to see this feature added. I'd be happy to help contribute.

mjsteinbaugh avatar Jun 18 '17 12:06 mjsteinbaugh

I'd also be interested in this 😃

kjohnsen avatar May 22 '18 00:05 kjohnsen

For those interested I would gladly review a PR!

jimhester avatar May 23 '18 16:05 jimhester

Cool thanks Jim, I'll see if I can put together a list of rules that would be helpful.

mjsteinbaugh avatar May 23 '18 17:05 mjsteinbaugh

I could use this since I'm developing a Bioconductor package now, so I'll see what I can do to help

kjohnsen avatar May 23 '18 23:05 kjohnsen

https://bioconductor.org/developers/how-to/coding-style/ would probably be a useful place to start.

jimhester avatar May 24 '18 12:05 jimhester

Maybe a good way to start is using this file I could spend some time, I have also some interest on this: see https://github.com/r-lib/styler/issues/331

I understand that this is different from r-lib/styler but I don't understand if there is any relationship between these packages or not. Anyway with that file it seems that it might be easier for me to use lintr

llrs avatar Sep 27 '18 09:09 llrs

@llrs I've been using this .lintr file in my packages, which has some additional checks

mjsteinbaugh avatar Sep 27 '18 11:09 mjsteinbaugh

Hi @mjsteinbaugh , would you be OK if I used your .lintr for basejump to define a list of bioconductor defaults within lintr?

russHyde avatar Nov 12 '19 09:11 russHyde

Sure thing!

mjsteinbaugh avatar Nov 12 '19 10:11 mjsteinbaugh

There's some additional best-practices mentioned here: http://bioconductor.org/developers/package-guidelines/#rcode

  • Use vapply() instead of sapply() and use the various apply functions instead of for loops.
  • Use seq_len() or seq_along() instead of 1:... -Use TRUE/FALSE instead of T/F
  • Avoid class()== and class()!= instead use is()
  • Use system2() instead of system
  • Do not use set.seed in any internal R code.
  • No browser() calls should be in code
  • Avoid the use of <<-.
  • Avoid use of direct slot access with @ or slot(). Accessor methods should be created and utilized
  • Use <- instead of = for assignment
  • Function names should be camel case or utilize the underscore _ and not have a dot . which indicates S3 dispatch.
  • Use dev.new() to start a graphics drive if necessary. Avoid using x11() or X11() for it can only be called on machines that have access to an X server.

russHyde avatar Nov 12 '19 11:11 russHyde

Yes, refer to BiocCheck::BiocCheck() for details on additional Bioconductor checks. In particular, I run it on CI with these flags: https://github.com/acidgenomics/Rcheck/blob/master/checks/bioc-check

mjsteinbaugh avatar Nov 12 '19 12:11 mjsteinbaugh

Also, one addition that would be particularly useful in my opinion is improved handling of internal S4 method functions, which currently return as lint errors. Here's an example: https://github.com/acidgenomics/basejump/blob/master/R/counts-methods.R#L46

counts,SummarizedExperiment will currently fail the camelCase lint check. This is similar to the S3 method lint issue reported in #223.

mjsteinbaugh avatar Nov 12 '19 12:11 mjsteinbaugh

Encourage anyone that's interested to file PRs. Would especially be nice to include some for the 3.0.0 release. A lot of the points referenced in https://github.com/r-lib/lintr/issues/43#issuecomment-552857792 are already doable with existing linters; others would be straightforward adaptations of existing logic (see e.g. the linters filed in #884). We can add the bioconductor tag to allow linters_with_tags("bioconductor") to facilitate easy .lintr configs.

MichaelChirico avatar Apr 05 '22 04:04 MichaelChirico