Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.

Commit

Permalink
added linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Sep 30, 2019
1 parent fae6045 commit 2973992
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
26 changes: 12 additions & 14 deletions .ci/lint_r_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,33 @@
library(argparse)
library(lintr)

parser <- argparse::ArgumentParser()
parser$add_argument(
"--package-dir"
, type = "character"
, help = "Fully-qualified directory to an R package"
args <- commandArgs(
trailingOnly = TRUE
)
args <- parser$parse_args()

PACKAGE_DIR_TO_LINT <- args[["package_dir"]]
SOURCE_DIR <- args[[1]]

LINTERS_TO_USE <-list(
"open_curly" = lintr::open_curly_linter
, "closed_curly" = lintr::closed_curly_linter
, "tabz" = lintr::no_tab_linter
, "spaces" = lintr::infix_spaces_linter
"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
)

result <- lintr::lint_package(
path = PACKAGE_DIR_TO_LINT
path = SOURCE_DIR
, relative_path = FALSE
, linters = LINTERS_TO_USE
)

cat(sprintf(
"Found %i linting errors in %s\n"
, length(result)
, PACKAGE_DIR_TO_LINT
, SOURCE_DIR
))

if (length(result) > 0){
Expand Down
3 changes: 1 addition & 2 deletions .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ echo "========================================="
echo "= Checking code for R style problems... ="
echo "========================================="

Rscript ${CI_TOOLS}/lint_r_code.R \
--package-dir $(pwd)/
Rscript ${CI_TOOLS}/lint_r_code.R $(pwd)

echo "done checking code for style problems."

Expand Down

1 comment on commit 2973992

@lintr-bot
Copy link

Choose a reason for hiding this comment

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

/home/travis/build/jameslamb/rsixygen/R/document_class.R:4:1: style: lines should not be more than 120 characters.

CLONE_DESCRIBE <- "Method for copying an object. See \\\\href{https://adv-r.hadley.nz/r6.html#r6-semantics}{\\emph{Advanced R}} for the intricacies of R6 reference semantics."
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please sign in to comment.