-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add lintr (fixes #179) #203
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# failure is a natural part of life | ||
set -e | ||
|
||
if [[ "$TASK" == "rpkg" ]]; then | ||
R_PACKAGE_DIR=$(pwd)/r-pkg | ||
Rscript -e "install.packages('lintr')" | ||
Rscript -e "lintr::lint_package('${R_PACKAGE_DIR}')" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you agree to my suggestion in the other comment about creating a One drawback of using So ideally you'd have a Rscript .ci/lint_r_code.R $(pwd) |
||
fi | ||
|
||
if [[ "$TASK" == "pypkg" ]]; then | ||
echo "R task only" | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ matrix: | |
- ES_VERSION=7.3.1 | ||
- TASK=rpkg | ||
after_success: | ||
- .ci/lint.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please . add this logic to Thank you for sharing the link to Jim Hester's recommended method for using I got similar feedback on LightGBM and was convinced. Instead of |
||
- .ci/report_to_covr.sh | ||
################# | ||
# Python builds # | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,11 @@ coverage_r: build_r | |
echo "Done calculating coverage" | ||
open coverage.html | ||
|
||
lint_r: | ||
echo "Linting R source..." | ||
TASK=rpkg .ci/lint.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you come back and change this? This should be: lint_r:
echo "Linting R source..."
Rscript .ci/lint.R $$(pwd)
echo "Done linting" So that when someone runs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take this into account. I would be interested in fixing the linting checks. What do you think of using styler, so that every developer could use the same rules ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok great, thanks! If you want to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use precommit so styler will run automatically before you make any commit. If you don't like it, just skip the hook with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion! Looks like an interesting project. I would like to avoid using pre-commit hooks for this project, especially any that require installing additional software beyond simple shell scripts. This project has both Python and R components, and I do not want someone developing on the Python side to need an R environment locally, or vice versa. I would like to minimize the barriers to entry for new contributors to the project, and I think that pushing checks into CI instead of making assumptions about contributors' local environments is one way to accomplish that goal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Then you could also use https://github.com/r-lib/ghactions and https://github.com/r-lib/actions, it has a styler example if that's preferred. |
||
echo "Done linting" | ||
|
||
docs_r: build_r | ||
Rscript -e "devtools::document('r-pkg/')" | ||
Rscript -e "pkgdown::build_site('r-pkg/')" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,6 @@ vignettes/*\.pdf | |
# Stuff | ||
.Rbuildignore | ||
.*\.gitkeep | ||
|
||
# Lintr | ||
.lintr |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
linters: list( | ||
"closed_curly" = lintr::closed_curly_linter | ||
, "infix_spaces" = lintr::infix_spaces_linter | ||
, "long_lines" = lintr::line_length_linter(length = 120) | ||
, "tabs" = lintr::no_tab_linter | ||
, "open_curly" = lintr::open_curly_linter | ||
, "spaces_inside" = lintr::spaces_inside_linter | ||
, "spaces_left_parens" = lintr::spaces_left_parentheses_linter | ||
, "trailing_blank" = lintr::trailing_blank_lines_linter | ||
, "trailing_white" = lintr::trailing_whitespace_linter | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great, thanks! I know that in #179 I mentioned this set of linters, but since that issue was created Could you update the list of linters to this? LINTERS_TO_USE <- list(
"assignment" = lintr::assignment_linter
, "closed_curly" = lintr::closed_curly_linter
, "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
, "open_curly" = lintr::open_curly_linter
, "paren_brace_linter" = lintr::paren_brace_linter
, "semicolon" = lintr::semicolon_terminator_linter
, "seq" = lintr::seq_linter
, "single_quotes" = lintr::single_quotes_linter
, "spaces_inside" = lintr::spaces_inside_linter
, "spaces_left_parens" = lintr::spaces_left_parentheses_linter
, "todo_comments" = lintr::todo_comment_linter
, "trailing_blank" = lintr::trailing_blank_lines_linter
, "trailing_white" = lintr::trailing_whitespace_linter
, "true_false" = lintr::T_and_F_symbol_linter
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ Imports: | |
Suggests: | ||
covr, | ||
knitr, | ||
lintr, | ||
rmarkdown, | ||
testthat | ||
License: BSD_3_clause + file LICENSE | ||
|
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.
since you've already added this install to
.ci/setup.sh
, can you remove it here?