Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce lintr #70

Merged
merged 8 commits into from
Aug 31, 2021
Merged

feat: introduce lintr #70

merged 8 commits into from
Aug 31, 2021

Conversation

gegnew
Copy link
Contributor

@gegnew gegnew commented Aug 16, 2021

  • Add .lintr config
  • Format and lint all files
  • clamp_q -> clampQ
  • Reduce cyclomatic complexity of getEvents
  • Reduce cyclomatic complexity of getStatistics
  • Add linting workflow

This was formatted with the styler/tidyverse defaults (https://styler.r-lib.org/index.html).

Q's:

  • Do we like this formatting style?
  • Should I add a pre-commit hook for styler? Currently the use of styler is not enforced anywhere.

@gegnew gegnew requested a review from zbjornson August 16, 2021 20:42
Copy link
Member

@zbjornson zbjornson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see this.

Do we like this formatting style?

Yes, though I wish it allowed = instead of <-. Surprisingly no one has asked for that in lintr's issues.

Should I add a pre-commit hook for styler? Currently the use of styler is not enforced anywhere.

Maybe wait on this and see how it goes? I don't love pre-commit hooks because they slow things down. It would be nice if styler could run in a "report-only" mode.

DESCRIPTION Outdated Show resolved Hide resolved
R/getEvents.R Outdated Show resolved Hide resolved
R/applyScale.R Outdated Show resolved Hide resolved
.lintr Show resolved Hide resolved
.lintr Outdated
object_name_linter = object_name_linter("camelCase"),
open_curly_linter = NULL,
closed_curly_linter = NULL,
object_usage_linter = NULL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also looks like it can be left enabled.

Copy link
Contributor Author

@gegnew gegnew Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's left enabled, I get the following errors:

R/util.R:91:11: warning: no visible binding for global variablelastErrorpkg.env$lastError
          ^~~~~~~~~
R/util.R:146:16: warning: no visible binding for global variable_idval <- vals$`_id`
               ^~~

The first I can fix by adding pkg.env$lastError <- NULL at the top of util.R. The second I could just skip with # nolint.

But one of the biggest reasons to use lintr is for IDE integration, imho, and unfortunately any package-internal functions (i.e. those that aren't included in the roxygen-generated NAMESPACE) will threw an error (see r-lib/lintr#482).

Additionally, object_usage_linter executes package code with eval during checks, which is potentially a bit dangerous (although there aren't any other contributors to the package, so it's probably not a huge concern).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, fine to leave it then.

(I'd like to get rid of getLastError btw. R has better facilities with try/catch I think.)

Just for my understanding, is the second one a false-positive? We have other code like getStatistics.R:161 percentOf <- serverPops$`_id`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#73

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering as well if it was a false positive. At any rate, I managed to quiet the error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does indeed appear to be a bug in lintr. I haven't tried to make a minimal repro to open an issue there. How'd you quiet the error?

@zbjornson
Copy link
Member

Also: need to build the .Rd files!

.lintr Outdated Show resolved Hide resolved
.lintr Show resolved Hide resolved
Copy link
Member

@zbjornson zbjornson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one tiny comment below and another above. ⬆️

R/annotateFcsFile.R Outdated Show resolved Hide resolved
@gegnew gegnew force-pushed the ge/lintr branch 3 times, most recently from 80de747 to 33e08b0 Compare August 26, 2021 06:43
@gegnew gegnew requested a review from zbjornson August 26, 2021 06:48
@zbjornson
Copy link
Member

Here we go, it's CRAN's policy. https://cran.r-project.org/doc/manuals/r-release/R-exts.html

The mandatory ‘Title’ field should give a short description of the package. Some package listings may truncate the title to 65 characters. It should use title case (that is, use capitals for the principal words: tools::toTitleCase can help you with this), not use any markup, not have any continuation lines, and not end in a period (unless part of …). Do not repeat the package name: it is often used prefixed by the name. Refer to other packages and external software in single quotes, and to book titles (and similar) in double quotes.

So maybe it will be happy with 'CellEngine' API toolkit? Not at my computer to try it.

@zbjornson
Copy link
Member

maybe it will be happy with 'CellEngine' API toolkit?

Confirmed, single quotes make it happy. I don't care if it's API toolkit for 'CellEngine' or 'CellEngine' API toolkit, but please add the single quotes per the guide above, then I'm good!

@zbjornson zbjornson merged commit 51bdc0e into master Aug 31, 2021
@zbjornson zbjornson deleted the ge/lintr branch August 31, 2021 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants