-
Notifications
You must be signed in to change notification settings - Fork 186
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
Unhelpful Error Message for linting #1725
Comments
that message is certainly no good :) FWIW, all linters' are factories since 3.0.0 -- that means all your entries should be converted to function calls, e.g.
see if that makes your error go away |
I reproduce the issue: cd /tmp
echo "linters: linters_with_defaults(assignment_linter = lintr::assignment_linter)" > .lintr
echo "a = 1" > file.R
Rscript -e "lintr::lint_dir()"
# Error: Linter 'assignment_linter' failed in /tmp/file.R: argument is not interpretable as logical
# In addition: Warning message:
# In if (allow_cascading_assign) "" else "[text() = '<-']" :
# the condition has length > 1 and only the first element will be used
# Execution halted as well as confirming |
Somehow, the factory is not being evaluated, assignment_linter(get_source_expressions("file.R")$expressions[[1L]])
# Error in if (allow_cascading_assign) "" else "[text() = '<-']" :
# argument is not interpretable as logical
# In addition: Warning message:
# In if (allow_cascading_assign) "" else "[text() = '<-']" :
# the condition has length > 1 and only the first element will be used The correct code should instead be: assignment_linter()(get_source_expressions("file.R")$expressions[[1L]])
# file.R:1:3: style: [NA] Use <-, not =, for assignment.
# a = 1
# ^ |
Great - that did the job! |
Great! Glad to un-break you. Leaving the issue open because it should fail in a much friendlier way for you to unstick yourself. |
Smaller reprex, showing that lintr::lint(text = "a = 1", linters = list(assignment_linter = lintr::assignment_linter))
#> Warning: Passing linters as variables was deprecated in lintr version 3.0.0. Use
#> a call to the linters (see ?linters) instead.
#> <text>:1:3: style: [assignment_linter] Use <-, not =, for assignment.
#> a = 1
#> ^
lintr::lint(text = "a = 1", linters = lintr::linters_with_defaults(assignment_linter = lintr::assignment_linter))
#> Error: Linter 'assignment_linter' failed in /tmp/RtmpHSaTXh/filec155373c23d6: the condition has length > 1 Created on 2022-12-03 with reprex v2.0.2 waldo::compare(lintr::linters_with_defaults(assignment_linter = lintr::assignment_linter)["assignment_linter"], list(assignment_linter = lintr::assignment_linter))
#> `old$assignment_linter` is an S3 object of class <linter/function>, a function
#> `new$assignment_linter` is a function Created on 2022-12-03 with reprex v2.0.2 |
With the update to lintr 3.0.1 I receive the following error message:
Unfortunately, the error message is not very helpful and I didn´t find any information online.
Is this a problem with lintr 3.0.1 or is my
.lintr
file badly specified.Here my
.lintr
file:The text was updated successfully, but these errors were encountered: