From d4f4bbd255a6fa760a0b0bee2a4b8676f73e7dd5 Mon Sep 17 00:00:00 2001 From: assignUser Date: Sat, 15 Aug 2020 18:21:57 +0000 Subject: [PATCH 01/20] everything except linter.sh --- .automation/test/r/README.md | 13 ++++++++++ .automation/test/r/R_bad_1.R | 43 +++++++++++++++++++++++++++++++ .automation/test/r/R_good_1.R | 48 +++++++++++++++++++++++++++++++++++ .github/linters/.lintr | 8 ++++++ Dockerfile | 8 ++++++ README.md | 2 ++ TEMPLATES/.lintr | 8 ++++++ docs/disabling-linters.md | 33 ++++++++++++++++++++++++ 8 files changed, 163 insertions(+) create mode 100644 .automation/test/r/README.md create mode 100644 .automation/test/r/R_bad_1.R create mode 100644 .automation/test/r/R_good_1.R create mode 100644 .github/linters/.lintr create mode 100644 TEMPLATES/.lintr diff --git a/.automation/test/r/README.md b/.automation/test/r/README.md new file mode 100644 index 00000000..19e0042f --- /dev/null +++ b/.automation/test/r/README.md @@ -0,0 +1,13 @@ +# R Test Cases +This folder holds the test cases for **R**. + +## Additional Docs +No Additional information is needed for this test case. + +## Good Test Cases +The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted. +- **Note:** They are linted utilizing the default linter rules. + +## Bad Test Cases +The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted. +- **Note:** They are linted utilizing the default linter rules. \ No newline at end of file diff --git a/.automation/test/r/R_bad_1.R b/.automation/test/r/R_bad_1.R new file mode 100644 index 00000000..480eacd1 --- /dev/null +++ b/.automation/test/r/R_bad_1.R @@ -0,0 +1,43 @@ +# Each of the default linters should throw at least one lint on this file + +# assignment +# function_left_parentheses +# closed_curly +# commas +# paren_brace +f = function (x,y = 1){} + +# commented_code +# some <- commented("out code") + +# cyclocomp +# equals_na +# infix_spaces +# line_length +# object_length +# object_name +# object_usage +# open_curly +someComplicatedFunctionWithALongCameCaseName <- function(x) +{ + y <- 1 + if (1 > 2 && 2 > 3 && 3 > 4 && 4 > 5 && 5*10 > 6 && x == NA) {TRUE} else {FALSE} +} + +# pipe_continuation +# seq_linter +# spaces_inside +x <- 1:10 +x[ 2] +1:length(x) %>% lapply(function(x) x*2) %>% + head() + +# single_quotes +message('single_quotes') + +# spaces_left_parentheses +# trailing_whitespace +y <- 2 +(1:10) + +# trailing_blank_lines + diff --git a/.automation/test/r/R_good_1.R b/.automation/test/r/R_good_1.R new file mode 100644 index 00000000..e6c5c41d --- /dev/null +++ b/.automation/test/r/R_good_1.R @@ -0,0 +1,48 @@ +# Each of the default linters should throw at least one lint on this file + +# assignment +# function_left_parentheses +# closed_curly +# commas +# paren_brace +f <- function(x, y = 1) { + +} + +# commented_code + +# cyclocomp +# equals_na +# infix_spaces +# line_length +# object_length +# object_name +# object_usage +# open_curly +short_snake <- function(x) { + y <- 1 + y <- y^2 + if (1 > 2 && 5 * 10 > 6 && is.na(x)) { + TRUE + } else { + FALSE + } +} + +# pipe_continuation +# seq_linter +# spaces_inside +x <- 1:10 +x[2] +seq_len(x) %>% + lapply(function(x) x * 2) %>% + head() + +# single_quotes +message("single_quotes") + +# spaces_left_parentheses +# trailing_whitespace +y <- 2 + (1:10) + +# trailing_blank_lines \ No newline at end of file diff --git a/.github/linters/.lintr b/.github/linters/.lintr new file mode 100644 index 00000000..66c5ca46 --- /dev/null +++ b/.github/linters/.lintr @@ -0,0 +1,8 @@ +# see https://github.com/jimhester/lintr#project-configuration for details +# on how to configure lintr. +# Defaults mostly adhere to: https://style.tidyverse.org/ +# +# 'object_usage_linter' runs code with eval() and is deactivated by default +# for security reasons. + +linters: with_defaults(object_usage_linter = NULL) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 98b7a3e2..9e5150b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ FROM yoheimuta/protolint:v0.26.0 as protolint FROM koalaman/shellcheck:v0.7.1 as shellcheck FROM wata727/tflint:0.18.0 as tflint FROM hadolint/hadolint:latest-alpine as dockerfile-lint +FROM assignuser/lintr-lib:latest as lintr-lib ################## # Get base image # @@ -240,6 +241,12 @@ RUN wget --tries=5 https://github.com/cvega/luarocks/archive/v3.3.1-super-linter RUN luarocks install luacheck +################# +# Install lintr # +################# +COPY --from=lintr-lib /usr/lib/R/library/ /home/r-library +RUN R -e "install.packages(list.dirs('/home/r-library',recursive = FALSE), repos = NULL, type = 'source')" + ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### @@ -294,6 +301,7 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ VALIDATE_PYTHON=${VALIDATE_PYTHON} \ VALIDATE_PYTHON_PYLINT=${VALIDATE_PYTHON_PYLINT} \ VALIDATE_PYTHON_FLAKE8=${VALIDATE_PYTHON_FLAKE8} \ + VALIDATE_R=${VALIDATE_R} \ VALIDATE_RAKU=${VALIDATE_RAKU} \ VALIDATE_RUBY=${VALIDATE_RUBY} \ VALIDATE_STATES=${VALIDATE_STATES} \ diff --git a/README.md b/README.md index 324a5aae..fd917855 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | | **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) | | **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) | +| **R** | [lintr](https://github.com/jimhester/lintr) | | **Raku** | [raku](https://raku.org) | | **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | @@ -227,6 +228,7 @@ But if you wish to select or exclude specific linters, we give you full control | **VALIDATE_PYTHON_PYLINT** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) | | **VALIDATE_PYTHON_FLAKE8** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: flake8) | | **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the Powershell language. | +| **VALIDATE_R** | `true` | Flag to enable or disable the linting process of the R language. | | **VALIDATE_RAKU** | `true` | Flag to enable or disable the linting process of the Raku language. | | **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. | | **VALIDATE_STATES** | `true` | Flag to enable or disable the linting process for AWS States Language. | diff --git a/TEMPLATES/.lintr b/TEMPLATES/.lintr new file mode 100644 index 00000000..66c5ca46 --- /dev/null +++ b/TEMPLATES/.lintr @@ -0,0 +1,8 @@ +# see https://github.com/jimhester/lintr#project-configuration for details +# on how to configure lintr. +# Defaults mostly adhere to: https://style.tidyverse.org/ +# +# 'object_usage_linter' runs code with eval() and is deactivated by default +# for security reasons. + +linters: with_defaults(object_usage_linter = NULL) \ No newline at end of file diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 13db1ee2..8cf1c6f1 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -42,6 +42,7 @@ For some linters it is also possible to override rules on a case by case level w - [Protocol Buffers](#protocol-buffers) - [Python3 pylint](#python3-pylint) - [Python3 flake8](#python3-flake8) + - [R](#r) - [Raku](#raku) - [Ruby](#ruby) - [Shell](#shell) @@ -896,7 +897,39 @@ var = "terrible code down here..." ``` --- +## R +- [lintr](https://github.com/jimhester/lintr) + +### lintr Config file + +- `.github/linters/.lintr` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.lintr` +- **Note:** The defaults adhere to the [tidyverse styleguide](https://style.tidyverse.org/) + +### lintr disable single line + +```r +1++1/3+2 # nolint +``` + +### lintr disable code block + +```r + # nolint start + hotGarbage = 1++1/3+2 + #a very long comment line + # nolint end +``` +### lintr disable entire file + +Add files to exclude into the config file as a list of filenames to exclude from linting. You can use a named item to exclude only certain lines from a file. + +```r +exclusions: list("inst/doc/creating_linters.R" = 1, "inst/example/bad.R", "tests/testthat/exclusions-test") +``` +--- ## Raku - [raku](https://raku.org) From 0933aebc7a78911072fbd92bbef0a19ccea51ae6 Mon Sep 17 00:00:00 2001 From: assignUser Date: Sat, 15 Aug 2020 19:29:22 +0000 Subject: [PATCH 02/20] add R with edgecases --- lib/linter.sh | 29 +++++++++++++++++++++++++++-- lib/worker.sh | 19 +++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index ab5c4d0f..048a5d6c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -107,6 +107,9 @@ PYTHON_PYLINT_FILE_NAME="${PYTHON_PYLINT_CONFIG_FILE:-.python-lint}" PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME}" # Path to the python lint rules PYTHON_FLAKE8_FILE_NAME="${PYTHON_FLAKE8_CONFIG_FILE:-.flake8}" # Name of the file PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME}" # Path to the python lint rules +# R Vars +R_FILE_NAME='.lintr' +R_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${R_FILE_NAME}" # Ruby Vars RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules @@ -130,7 +133,7 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the ya LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'checkstyle' 'clj-kondo' 'coffeelint' 'dart' 'dockerfilelint' 'dotenv-linter' 'editorconfig-checker' 'eslint' 'flake8' 'golangci-lint' 'hadolint' 'htmlhint' 'jsonlint' 'ktlint' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' - 'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'sql-lint' + 'pwsh' 'pylint' 'lintr' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'sql-lint' 'terrascan' 'tflint' 'xmllint' 'yamllint') ############################# @@ -140,7 +143,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'DART' 'DOCKERFILE' 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVA' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL' - 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'SQL' 'TERRAFORM' + 'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'R' 'RAKU' 'RUBY' 'STATES' 'SQL' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML') ############################################ @@ -197,6 +200,7 @@ VALIDATE_PHP_PSALM="${VALIDATE_PHP_PSALM}" # Boolean t VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language +VALIDATE_R="${VALIDATE_R}" # Boolean to validate language VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language @@ -295,6 +299,7 @@ FILE_ARRAY_POWERSHELL=() # Array of files to check FILE_ARRAY_PROTOBUF=() # Array of files to check FILE_ARRAY_PYTHON_PYLINT=() # Array of files to check FILE_ARRAY_PYTHON_FLAKE8=() # Array of files to check +FILE_ARRAY_R=() # Array of files to check FILE_ARRAY_RAKU=() # Array of files to check FILE_ARRAY_RUBY=() # Array of files to check FILE_ARRAY_STATES=() # Array of files to check @@ -375,6 +380,8 @@ ERRORS_FOUND_PYTHON_PYLINT=0 # Count of errors found export ERRORS_FOUND_PYTHON_PYLINT # Workaround SC2034 ERRORS_FOUND_PYTHON_FLAKE8=0 # Count of errors found export ERRORS_FOUND_PYTHON_FLAKE8 # Workaround SC2034 +ERRORS_FOUND_R=0 # Count of errors found +export ERRORS_FOUND_R # Workaround SC2034 ERRORS_FOUND_RAKU=0 # Count of errors found export ERRORS_FOUND_RAKU # Workaround SC2034 ERRORS_FOUND_RUBY=0 # Count of errors found @@ -442,6 +449,11 @@ GetLinterVersions() { elif [[ ${LINTER} == "protolint" ]] || [[ ${LINTER} == "editorconfig-checker" ]]; then # Need specific command for Protolint and editorconfig-checker mapfile -t GET_VERSION_CMD < <(echo "--version not supported") + elif [[ ${LINTER} == "lintr" ]]; then + # Need specific command for lintr (--slave is deprecated in R 4.0 and replaced by --no-echo) + mapfile -t GET_VERSION_CMD < <(R --slave -e "r_ver <- R.Version()\$version.string; \ + lintr_ver <- packageVersion('lintr'); \ + glue::glue('lintr { lintr_ver } on { r_ver }')") else # Standard version command mapfile -t GET_VERSION_CMD < <("${LINTER}" --version 2>&1) @@ -1199,6 +1211,8 @@ GetLinterRules "POWERSHELL" GetLinterRules "PYTHON_PYLINT" # Get Python flake8 rules GetLinterRules "PYTHON_FLAKE8" +# Get R rules +GetLinterRules "R" # Get Ruby rules GetLinterRules "RUBY" # Get SQL rules @@ -1677,6 +1691,17 @@ if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}" fi +################ +# R LINTING # +################ +if [ "${VALIDATE_R}" == "true" ]; then + ####################### + # Lint the R files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "R" "lintr" "R --slave -e 'lintr::lint(" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" +fi + ################ # RAKU LINTING # ################ diff --git a/lib/worker.sh b/lib/worker.sh index e94d9a06..d0a34ee5 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -37,8 +37,12 @@ function LintCodebase() { ##################################### # Validate we have linter installed # ##################################### - VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) - + # Edgecase for Lintr as it is a Package for R + if [[ ${LINTER_NAME} == *"lintr"* ]]; then + VALIDATE_INSTALL_CMD=$(command -v "R" 2>&1) + else + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) + fi ####################### # Load the error code # ####################### @@ -202,6 +206,17 @@ function LintCodebase() { cd "${GITHUB_WORKSPACE}" || exit ${LINTER_COMMAND} --path "${DIR_NAME}" --files "$FILE_NAME" 2>&1 ) + ############################################################################### + # Corner case for R as we have to pass it to R # + ############################################################################### + elif [[ ${FILE_TYPE} == "R" ]]; then + ####################################### + # Lint the file with the updated path # + ####################################### + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}" || exit + ${LINTER_COMMAND}"${DIR_NAME}/$FILE_NAME")' 2>&1 #' + ) else ################################ # Lint the file with the rules # From a745a38df995fbed386e2e0b940bec0fa6859ded Mon Sep 17 00:00:00 2001 From: assignUser Date: Sat, 15 Aug 2020 22:53:08 +0000 Subject: [PATCH 03/20] add apks --- Dockerfile | 4 +++- lib/buildFileList.sh | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9e5150b3..32f09239 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,7 +72,9 @@ RUN apk add --update --no-cache \ py3-setuptools \ readline-dev \ ruby ruby-dev ruby-bundler ruby-rdoc \ - gnupg + gnupg \ + R \ + libc-dev libxml2-dev ######################################## # Copy dependencies files to container # diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index e565868d..9123adc8 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -355,6 +355,21 @@ function BuildFileList() { # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the Golang files # + ######################## + elif [ "${FILE_TYPE}" == "R" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_R+=("${FILE}") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ########################### + # Get the Terraform files # + ########################### ########################### # Get the Terraform files # ########################### From 8baec3bc77c9c4190818b66c029d7a2ad65e34e8 Mon Sep 17 00:00:00 2001 From: assignUser Date: Sat, 15 Aug 2020 23:43:42 +0000 Subject: [PATCH 04/20] fix --- lib/linter.sh | 2 +- lib/worker.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 048a5d6c..8a7efcfa 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1699,7 +1699,7 @@ if [ "${VALIDATE_R}" == "true" ]; then # Lint the R files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "R" "lintr" "R --slave -e 'lintr::lint(" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" + LintCodebase "R" "lintr" "${R_LINTER_RULES}" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" fi ################ diff --git a/lib/worker.sh b/lib/worker.sh index d0a34ee5..c5f25012 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -215,7 +215,7 @@ function LintCodebase() { ####################################### LINT_CMD=$( cd "${GITHUB_WORKSPACE}" || exit - ${LINTER_COMMAND}"${DIR_NAME}/$FILE_NAME")' 2>&1 #' + R --slave -e "lintr::lint('${DIR_NAME}/$FILE_NAME')" 2>&1 ) else ################################ From 527334883ec74532c2784a748fd4fca521fa8243 Mon Sep 17 00:00:00 2001 From: assignUser Date: Sun, 16 Aug 2020 00:18:31 +0000 Subject: [PATCH 05/20] adjust lint command --- lib/linter.sh | 4 ++-- lib/worker.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 8a7efcfa..8eb6f0fb 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -108,8 +108,8 @@ PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME} PYTHON_FLAKE8_FILE_NAME="${PYTHON_FLAKE8_CONFIG_FILE:-.flake8}" # Name of the file PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME}" # Path to the python lint rules # R Vars -R_FILE_NAME='.lintr' -R_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${R_FILE_NAME}" +R_FILE_NAME='.lintr' # Name of the file +R_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${R_FILE_NAME}" # Path to the R lint rules # Ruby Vars RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules diff --git a/lib/worker.sh b/lib/worker.sh index c5f25012..ff9c17d4 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -215,7 +215,7 @@ function LintCodebase() { ####################################### LINT_CMD=$( cd "${GITHUB_WORKSPACE}" || exit - R --slave -e "lintr::lint('${DIR_NAME}/$FILE_NAME')" 2>&1 + R --slave -e "errors <- lintr::lint('$FILE');print(errors);quit(save = 'no', status = if (length(errors) > 0) 1 else 0)" 2>&1 ) else ################################ From f6fcfb79225c805054f9012779429e4a29e51b70 Mon Sep 17 00:00:00 2001 From: assignUser Date: Sun, 16 Aug 2020 00:20:06 +0000 Subject: [PATCH 06/20] adjust .lintr --- .github/linters/.lintr | 7 ------- TEMPLATES/.lintr | 7 ------- 2 files changed, 14 deletions(-) diff --git a/.github/linters/.lintr b/.github/linters/.lintr index 66c5ca46..05eefeeb 100644 --- a/.github/linters/.lintr +++ b/.github/linters/.lintr @@ -1,8 +1 @@ -# see https://github.com/jimhester/lintr#project-configuration for details -# on how to configure lintr. -# Defaults mostly adhere to: https://style.tidyverse.org/ -# -# 'object_usage_linter' runs code with eval() and is deactivated by default -# for security reasons. - linters: with_defaults(object_usage_linter = NULL) \ No newline at end of file diff --git a/TEMPLATES/.lintr b/TEMPLATES/.lintr index 66c5ca46..05eefeeb 100644 --- a/TEMPLATES/.lintr +++ b/TEMPLATES/.lintr @@ -1,8 +1 @@ -# see https://github.com/jimhester/lintr#project-configuration for details -# on how to configure lintr. -# Defaults mostly adhere to: https://style.tidyverse.org/ -# -# 'object_usage_linter' runs code with eval() and is deactivated by default -# for security reasons. - linters: with_defaults(object_usage_linter = NULL) \ No newline at end of file From d9536d43ba9cade4024fabac1204d1ef93646400 Mon Sep 17 00:00:00 2001 From: assignUser Date: Sun, 16 Aug 2020 01:27:41 +0000 Subject: [PATCH 07/20] fix whitespace --- docs/disabling-linters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 8cf1c6f1..bfde2625 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -916,7 +916,7 @@ var = "terrible code down here..." ### lintr disable code block -```r +```r # nolint start hotGarbage = 1++1/3+2 #a very long comment line @@ -926,7 +926,7 @@ var = "terrible code down here..." Add files to exclude into the config file as a list of filenames to exclude from linting. You can use a named item to exclude only certain lines from a file. -```r +```r exclusions: list("inst/doc/creating_linters.R" = 1, "inst/example/bad.R", "tests/testthat/exclusions-test") ``` --- From 7632f646642c1a3d35aea51ecc51cb578efb79d3 Mon Sep 17 00:00:00 2001 From: assignUser Date: Sun, 16 Aug 2020 12:44:37 +0000 Subject: [PATCH 08/20] ad lintr to TestCodebase --- docs/disabling-linters.md | 2 +- lib/worker.sh | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index bfde2625..9da136ea 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -910,7 +910,7 @@ var = "terrible code down here..." ### lintr disable single line -```r +```r 1++1/3+2 # nolint ``` diff --git a/lib/worker.sh b/lib/worker.sh index ff9c17d4..8749a39f 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -300,7 +300,12 @@ function TestCodebase() { ##################################### # Validate we have linter installed # ##################################### - VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) + # Edgecase for Lintr as it is a Package for R + if [[ ${LINTER_NAME} == *"lintr"* ]]; then + VALIDATE_INSTALL_CMD=$(command -v "R" 2>&1) + else + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) + fi ####################### # Load the error code # @@ -432,6 +437,17 @@ function TestCodebase() { cd "${GITHUB_WORKSPACE}" || exit ${LINTER_COMMAND} --path "${DIR_NAME}" --files "$FILE_NAME" 2>&1 ) + ############################################################################### + # Corner case for R as we have to pass it to R # + ############################################################################### + elif [[ ${FILE_TYPE} == "R" ]]; then + ####################################### + # Lint the file with the updated path # + ####################################### + LINT_CMD=$( + cd "${GITHUB_WORKSPACE}" || exit + R --slave -e "errors <- lintr::lint('$FILE');print(errors);quit(save = 'no', status = if (length(errors) > 0) 1 else 0)" 2>&1 + ) else ################################ # Lint the file with the rules # @@ -615,6 +631,8 @@ function RunTestCases() { TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python" TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python" + # TestCodebase "Language" "Linter" "Linter-command" "Regex to find files" "Test Folder" + TestCodebase "R" "lintr" "raku -c" ".*\.\(r\|R\|Rmd\|rmd\)\$" "r" TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" From 6bb65aaa2c35ae4d07f51294843c54d8b50cc0f6 Mon Sep 17 00:00:00 2001 From: assignUser Date: Sun, 16 Aug 2020 13:31:23 +0000 Subject: [PATCH 09/20] lowercase file_type --- lib/buildFileList.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 9123adc8..d44f6348 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -355,10 +355,10 @@ function BuildFileList() { # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - ######################## - # Get the Golang files # - ######################## - elif [ "${FILE_TYPE}" == "R" ]; then + #################### + # Get the R files # + #################### + elif [ "${FILE_TYPE}" == "r" ]; then ################################ # Append the file to the array # ################################ From 0f47f68445be28f5e45ec521e87722867143190d Mon Sep 17 00:00:00 2001 From: assignUser Date: Mon, 17 Aug 2020 12:01:25 +0000 Subject: [PATCH 10/20] add .lintr detection --- .github/linters/.lintr | 2 +- TEMPLATES/.lintr | 2 +- lib/linter.sh | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/linters/.lintr b/.github/linters/.lintr index 05eefeeb..aac8e22e 100644 --- a/.github/linters/.lintr +++ b/.github/linters/.lintr @@ -1 +1 @@ -linters: with_defaults(object_usage_linter = NULL) \ No newline at end of file +linters: with_defaults(object_usage_linter = NULL) diff --git a/TEMPLATES/.lintr b/TEMPLATES/.lintr index 05eefeeb..aac8e22e 100644 --- a/TEMPLATES/.lintr +++ b/TEMPLATES/.lintr @@ -1 +1 @@ -linters: with_defaults(object_usage_linter = NULL) \ No newline at end of file +linters: with_defaults(object_usage_linter = NULL) diff --git a/lib/linter.sh b/lib/linter.sh index 8eb6f0fb..413f9537 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1695,8 +1695,17 @@ fi # R LINTING # ################ if [ "${VALIDATE_R}" == "true" ]; then + ########################## + # Check for local config # + ########################## + if [ ! -f "${GITHUB_WORKSPACE}/.lintr" ]; then + info " " + info "No .lintr configuration file found, using defaults." + cp $R_LINTER_RULES $GITHUB_WORKSPACE + fi + ####################### - # Lint the R files # + # Lint the R files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" LintCodebase "R" "lintr" "${R_LINTER_RULES}" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" From f9b81243db850a66b237b4b8439ea24b566619a3 Mon Sep 17 00:00:00 2001 From: assignUser Date: Mon, 17 Aug 2020 12:14:15 +0000 Subject: [PATCH 11/20] add quotes --- lib/linter.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 413f9537..9cd7c3b8 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1701,12 +1701,12 @@ if [ "${VALIDATE_R}" == "true" ]; then if [ ! -f "${GITHUB_WORKSPACE}/.lintr" ]; then info " " info "No .lintr configuration file found, using defaults." - cp $R_LINTER_RULES $GITHUB_WORKSPACE + cp $R_LINTER_RULES "$GITHUB_WORKSPACE" fi - ####################### - # Lint the R files # - ####################### + ###################### + # Lint the R files # + ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" LintCodebase "R" "lintr" "${R_LINTER_RULES}" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" fi From 4f4784fd410c5e3a62c2f8ce2b0cc542c28aac8b Mon Sep 17 00:00:00 2001 From: assignUser Date: Mon, 17 Aug 2020 13:30:39 +0000 Subject: [PATCH 12/20] fix displayed lintr command --- lib/linter.sh | 2 +- lib/worker.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 9cd7c3b8..11a85b55 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1708,7 +1708,7 @@ if [ "${VALIDATE_R}" == "true" ]; then # Lint the R files # ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "R" "lintr" "${R_LINTER_RULES}" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" + LintCodebase "R" "lintr" "lintr::lint('$File') ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" fi ################ diff --git a/lib/worker.sh b/lib/worker.sh index 8749a39f..43eb8c85 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -214,7 +214,7 @@ function LintCodebase() { # Lint the file with the updated path # ####################################### LINT_CMD=$( - cd "${GITHUB_WORKSPACE}" || exit + cd "${GITHUB_WORKSPACE}/${DIR_NAME}" || exit R --slave -e "errors <- lintr::lint('$FILE');print(errors);quit(save = 'no', status = if (length(errors) > 0) 1 else 0)" 2>&1 ) else From 727f982bf9e2f5b40deb3498df9d1d0d905e1a95 Mon Sep 17 00:00:00 2001 From: assignUser Date: Mon, 17 Aug 2020 13:38:00 +0000 Subject: [PATCH 13/20] typo --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 11a85b55..99cf7e8d 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1708,7 +1708,7 @@ if [ "${VALIDATE_R}" == "true" ]; then # Lint the R files # ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "R" "lintr" "lintr::lint('$File') ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" + LintCodebase "R" "lintr" "lintr::lint('$File')" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" fi ################ From 9ec761f61c8cbbe2746239d638c7e0bc4c9ed940 Mon Sep 17 00:00:00 2001 From: assignUser Date: Mon, 17 Aug 2020 15:34:55 +0000 Subject: [PATCH 14/20] prereview --- lib/worker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.sh b/lib/worker.sh index 43eb8c85..c3434462 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -214,7 +214,7 @@ function LintCodebase() { # Lint the file with the updated path # ####################################### LINT_CMD=$( - cd "${GITHUB_WORKSPACE}/${DIR_NAME}" || exit + cd "${DIR_NAME}" || exit R --slave -e "errors <- lintr::lint('$FILE');print(errors);quit(save = 'no', status = if (length(errors) > 0) 1 else 0)" 2>&1 ) else From 6372885cd0b5c9269ecfe033f7e3af5b7e6622d3 Mon Sep 17 00:00:00 2001 From: assignUser Date: Mon, 17 Aug 2020 16:27:31 +0000 Subject: [PATCH 15/20] relative exclusions work, adressed comments --- docs/disabling-linters.md | 4 ++-- lib/buildFileList.sh | 2 +- lib/linter.sh | 8 ++++---- lib/worker.sh | 10 ++++++++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 9da136ea..d96385c8 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -905,7 +905,7 @@ var = "terrible code down here..." - `.github/linters/.lintr` - You can pass multiple rules and overwrite default rules -- File should be located at: `.github/linters/.lintr` +- You can use either one `.lintr` file in the root of your repository and/or additonal `.lintr` files in subdirectories. When linting a file lintr will look for config files from the file location upwards and will use the closest one. - **Note:** The defaults adhere to the [tidyverse styleguide](https://style.tidyverse.org/) ### lintr disable single line @@ -924,7 +924,7 @@ var = "terrible code down here..." ``` ### lintr disable entire file -Add files to exclude into the config file as a list of filenames to exclude from linting. You can use a named item to exclude only certain lines from a file. +Add files to exclude into the config file as a list of filenames to exclude from linting. You can use a named item to exclude only certain lines from a file. Use paths relative to the location of the `.lintr` file. ```r exclusions: list("inst/doc/creating_linters.R" = 1, "inst/example/bad.R", "tests/testthat/exclusions-test") diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index d44f6348..760c0eec 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -358,7 +358,7 @@ function BuildFileList() { #################### # Get the R files # #################### - elif [ "${FILE_TYPE}" == "r" ]; then + elif [ "${FILE_TYPE}" == "r" ] || [ "${FILE_TYPE}" == "rmd" ]; then ################################ # Append the file to the array # ################################ diff --git a/lib/linter.sh b/lib/linter.sh index 99cf7e8d..e3cbad39 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -132,8 +132,8 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the ya ####################################### LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'checkstyle' 'clj-kondo' 'coffeelint' 'dart' 'dockerfilelint' 'dotenv-linter' 'editorconfig-checker' 'eslint' 'flake8' 'golangci-lint' - 'hadolint' 'htmlhint' 'jsonlint' 'ktlint' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' - 'pwsh' 'pylint' 'lintr' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'sql-lint' + 'hadolint' 'htmlhint' 'jsonlint' 'ktlint' 'lintr' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' + 'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'sql-lint' 'terrascan' 'tflint' 'xmllint' 'yamllint') ############################# @@ -299,7 +299,7 @@ FILE_ARRAY_POWERSHELL=() # Array of files to check FILE_ARRAY_PROTOBUF=() # Array of files to check FILE_ARRAY_PYTHON_PYLINT=() # Array of files to check FILE_ARRAY_PYTHON_FLAKE8=() # Array of files to check -FILE_ARRAY_R=() # Array of files to check +FILE_ARRAY_R=() # Array of files to check FILE_ARRAY_RAKU=() # Array of files to check FILE_ARRAY_RUBY=() # Array of files to check FILE_ARRAY_STATES=() # Array of files to check @@ -1708,7 +1708,7 @@ if [ "${VALIDATE_R}" == "true" ]; then # Lint the R files # ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "R" "lintr" "lintr::lint('$File')" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" + LintCodebase "R" "lintr" "lintr::lint(File)" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" fi ################ diff --git a/lib/worker.sh b/lib/worker.sh index c3434462..31d2f98d 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -213,10 +213,16 @@ function LintCodebase() { ####################################### # Lint the file with the updated path # ####################################### + if [ ! -f "${DIR_NAME}/.lintr" ]; then + r_dir="${GITHUB_WORKSPACE}" + else + r_dir="${DIR_NAME}" + fi LINT_CMD=$( - cd "${DIR_NAME}" || exit + cd "$r_dir" || exit R --slave -e "errors <- lintr::lint('$FILE');print(errors);quit(save = 'no', status = if (length(errors) > 0) 1 else 0)" 2>&1 ) + #LINTER_COMMAND="lintr::lint('${FILE}')" else ################################ # Lint the file with the rules # @@ -632,7 +638,7 @@ function RunTestCases() { TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python" TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python" # TestCodebase "Language" "Linter" "Linter-command" "Regex to find files" "Test Folder" - TestCodebase "R" "lintr" "raku -c" ".*\.\(r\|R\|Rmd\|rmd\)\$" "r" + TestCodebase "R" "lintr" "lintr::lint()" ".*\.\(r\|R\|Rmd\|rmd\)\$" "r" TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" From c2f35fc0b39d7183edfe2928fda05a98b2d1700d Mon Sep 17 00:00:00 2001 From: assignUser Date: Mon, 17 Aug 2020 21:45:16 +0200 Subject: [PATCH 16/20] Update lib/worker.sh Co-authored-by: Lukas Gravley --- lib/worker.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/worker.sh b/lib/worker.sh index 31d2f98d..ffb8addf 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -638,7 +638,8 @@ function RunTestCases() { TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python" TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python" # TestCodebase "Language" "Linter" "Linter-command" "Regex to find files" "Test Folder" - TestCodebase "R" "lintr" "lintr::lint()" ".*\.\(r\|R\|Rmd\|rmd\)\$" "r" +TestCodebase "R" "lintr" "lintr::lint()" ".*\.\(r\|R\|Rmd\|rmd\)\$" "r" +TestCodebase "R" "lintr" "lintr::lint()" ".*\.\(r\|rmd\)\$" "r" TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" From 3d4292f067ae701744b35e33761fdf93a683f894 Mon Sep 17 00:00:00 2001 From: assignUser Date: Mon, 17 Aug 2020 19:47:03 +0000 Subject: [PATCH 17/20] alphabetize --- Dockerfile | 8 +++++--- lib/worker.sh | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 32f09239..9899ba05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,6 +61,7 @@ RUN apk add --update --no-cache \ go \ icu-libs \ jq \ + libc-dev libxml2-dev \ libc-dev libxml2-utils \ make \ musl-dev \ @@ -70,11 +71,12 @@ RUN apk add --update --no-cache \ php7 php7-phar php7-json php7-mbstring php-xmlwriter \ php7-tokenizer php7-ctype php7-curl php7-dom php7-simplexml \ py3-setuptools \ + R \ readline-dev \ ruby ruby-dev ruby-bundler ruby-rdoc \ - gnupg \ - R \ - libc-dev libxml2-dev + gnupg + + ######################################## # Copy dependencies files to container # diff --git a/lib/worker.sh b/lib/worker.sh index ffb8addf..52490f44 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -637,9 +637,7 @@ function RunTestCases() { TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python" TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python" - # TestCodebase "Language" "Linter" "Linter-command" "Regex to find files" "Test Folder" -TestCodebase "R" "lintr" "lintr::lint()" ".*\.\(r\|R\|Rmd\|rmd\)\$" "r" -TestCodebase "R" "lintr" "lintr::lint()" ".*\.\(r\|rmd\)\$" "r" + TestCodebase "R" "lintr" "lintr::lint()" ".*\.\(r\|rmd\)\$" "r" TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" From 05abc5ee695306e272d9e665f8b192f3efde86e6 Mon Sep 17 00:00:00 2001 From: assignUser Date: Tue, 18 Aug 2020 13:59:33 +0000 Subject: [PATCH 18/20] lowercase tests --- .automation/test/r/{R_bad_1.R => r_bad_1.r} | 0 .automation/test/r/{R_good_1.R => r_good_1.r} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .automation/test/r/{R_bad_1.R => r_bad_1.r} (100%) rename .automation/test/r/{R_good_1.R => r_good_1.r} (100%) diff --git a/.automation/test/r/R_bad_1.R b/.automation/test/r/r_bad_1.r similarity index 100% rename from .automation/test/r/R_bad_1.R rename to .automation/test/r/r_bad_1.r diff --git a/.automation/test/r/R_good_1.R b/.automation/test/r/r_good_1.r similarity index 100% rename from .automation/test/r/R_good_1.R rename to .automation/test/r/r_good_1.r From 4f97027f7fe35a6a1367dcbefa4fcbd9ab00583a Mon Sep 17 00:00:00 2001 From: assignUser Date: Tue, 18 Aug 2020 18:07:53 +0200 Subject: [PATCH 19/20] Apply suggestions from code review Co-authored-by: Gabriel Diaz --- Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9899ba05..f57d8573 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,8 +61,7 @@ RUN apk add --update --no-cache \ go \ icu-libs \ jq \ - libc-dev libxml2-dev \ - libc-dev libxml2-utils \ + libc-dev libxml2-dev libxml2-utils \ make \ musl-dev \ npm nodejs-current \ @@ -75,8 +74,6 @@ RUN apk add --update --no-cache \ readline-dev \ ruby ruby-dev ruby-bundler ruby-rdoc \ gnupg - - ######################################## # Copy dependencies files to container # From cc903ad5837264e0b0bba6568ead1e0c465d73f6 Mon Sep 17 00:00:00 2001 From: assignUser Date: Tue, 18 Aug 2020 16:11:26 +0000 Subject: [PATCH 20/20] Adjust doc about exclusions --- docs/disabling-linters.md | 3 ++- lib/linter.sh | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index d96385c8..ec6b81b6 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -905,7 +905,8 @@ var = "terrible code down here..." - `.github/linters/.lintr` - You can pass multiple rules and overwrite default rules -- You can use either one `.lintr` file in the root of your repository and/or additonal `.lintr` files in subdirectories. When linting a file lintr will look for config files from the file location upwards and will use the closest one. +- You can use either one `.lintr` file in the root of your repository and/or additonal `.lintr` files in subdirectories. When linting a file lintr will look for config files from the file location upwards and will use the closest one. +- Absolute paths for exclusions will not work due to the code being linted within the docker environment. Use paths relative to the `.lintr` file in which youare adding them. - **Note:** The defaults adhere to the [tidyverse styleguide](https://style.tidyverse.org/) ### lintr disable single line diff --git a/lib/linter.sh b/lib/linter.sh index e3cbad39..401a5627 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1707,7 +1707,6 @@ if [ "${VALIDATE_R}" == "true" ]; then ###################### # Lint the R files # ###################### - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" LintCodebase "R" "lintr" "lintr::lint(File)" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}" fi