-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[R-package] [ci] added more linters #2803
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, as it passes CI tests!
@Laurae2 can you take a look when you have a chance? I'm making the R code more opinionated here, would like to be sure you agree with it before merging. |
gently ping @Laurae2 for a review |
.ci/lint_r_code.R
Outdated
, "equals_na" = lintr::equals_na_linter | ||
, "function_left" = lintr::function_left_parentheses_linter | ||
, "commas" = lintr::commas_linter | ||
, "concatenation" = lintr::unneeded_concatenation_linter | ||
, "implicit_integers" = lintr::implicit_integer_linter | ||
, "infix_spaces" = lintr::infix_spaces_linter | ||
, "long_lines" = lintr::line_length_linter(length = 120L) | ||
, "tabs" = lintr::no_tab_linter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow alphabet order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah! Good catch
@jameslamb I looked thoroughly and I agree with the changes. Do you think we should also add |
Yep I agree! I'll do that |
eb2f955
to
b60e94b
Compare
@Laurae2 I had to change one of the demos where we were using |
Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>
4168117
to
ba00969
Compare
I just rebased to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit.
Dots for the consistency with other descriptions.
no problem, thanks! by the way I just pulled this and rebased it to current |
@jameslamb Did you see this warning:
I guess it's from this PR. |
@StrikerRUS I did see that a bit after we merged, working on #2901 I was trying to avoid any more R PRs since we have so many open right now, but I think this one would be easy to fix. This comes from the fact that I'll submit a PR right now |
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
This PR adds a few more R linters:
absolute_path_linter
: prevent paths like~/repos/
nonportable_path_linter
: prevent paths likeC:\Users\
which only work on certain operating systemsundesirable_function_linter
: prevent the use of some functions which could cause issues, specifically:dyn.load()
/dyn.unload()
: direct calls to use symbols in.dll
/.so
files. My expectation is that someone using this in a PR either doesn't understand how to write R packages that call C++ code or is introducing something that will be very difficult to maintain.help()
: call up help documentation. This should only be used interactively, not in code checked into this repository.install.packages()
: install new libraries, e.g. from CRAN. This should only be used interactively, not in code checked into this repository.ifelse()
: This is a convenient but dangerous function, because its output type depends on whether or not the input is all-TRUE, all-FALSE, or a mix.rbind()
: stack two data frames on top of each other (similar topd.concat()
inpandas
).data.table::rbindlist()
is faster and safer in the case where the data frames have different columnsis.list()
: check if an object is a list. I found that in all uses inlightgbm
, we are checking if something is exactly a list, not "list-like".is.list()
will beTRUE
on adata.table
object, so usingidentical(class(x), "list")
is safer.require()
: load a package if it hasn't been loaded yet and raise a warning if it is not available.library()
is preferred, since hitting a loud error right away that says "this package does not exist" makes debugging easier than getting some of error like "function 'something' not found" further down in the codeundesirable_operator_linter
: prevent the use of certain operators in R code, specifically:%>%
,%.%
,%..%
: variations of "pipe" operators, commonly used in some R packages. Thelightgbm
package doesn't currently use this programming model, and preventing it with this linter is about preventing a mix of different programming styles in the codebase.?
: call up help documentation. This should only be used interactively, not in code checked into this repository.This PR also re-ordered the list of linters in
.ci/lint_r_code.R
to alphabetize them for readability.