-
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
Outdent code extracted from indented chunks #1949
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1949 +/- ##
=======================================
Coverage 98.95% 98.95%
=======================================
Files 113 113
Lines 4972 4980 +8
=======================================
+ Hits 4920 4928 +8
Misses 52 52
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
(ignoring the lint that's turned up & covered by #1879) |
Will this make the lints show in the correct position? |
Good point. I guess it will be wrong... Is that enough not to merge here? It seems to me like this is an improvement & we could just mark a TODO for now, WDYT? |
Currently we don't have this problem and wrong lint positions may be very confusing (f.ex. if a whitespace lint lands on the wrong whitespace). @klmr what do you prefer to have in lintr 3.1.0, false positives for indentation or wrong lint locations for indented code blocks, if they contain lints? |
Tough question! Personally I'd prefer if correct code didn't trigger any false positives, since linter warnings are actually fairly noisy in most editors. As a consequence this leads users (well, at least me personally) to disable linting entirely rather than having even just a handful of false positives to deal with. I'd actually love to hear how other users think about this. |
that was my thinking too. bad lint metadata isn't an issue on lint-free code. and indented code blocks should be relatively rare anyway. OTOH we should throw a warning in the meantime when this is detected |
Is there an easy way to detect this? |
maybe I'm not getting the question, but in get_source_expression, yes, it's just I'll take another look at how much refactoring would be needed to fix this more properly. there's a related bug about keeping chunk-level metadata around -- that would be a decent solution here (since the indentation is a chunk-level data point). worst case, yes, I think we can inefficiently reconstruct "good" column numbers by matching the lint text to the contents (except maybe in the case of all-blank lines) |
Ah okay fine. The disadvantage of signalling in |
NEWS.md
Outdated
@@ -109,6 +109,8 @@ | |||
|
|||
* `missing_argument_linter()` allows missing arguments in `quote()` calls (#1889, @IndrajeetPatil). | |||
|
|||
* `get_source_expressions()` outdents code extracted from indented chunks, which helps avoid spurious lints related to whitespace (#1945, @MichaelChirico). |
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.
This note seems kind of hard to understand.
Maybe
get_source_expressions()
correctly extracts indented code chunks from R Markdown documents, which helps avoid spurious lints related to whitespace (#1945, @MichaelChirico).
WDYT?
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.
Great! Also added a note about using the leftmost column in the weird staggered case.
Closes #1945
This handles the issue at hand, not sure if @AshesITR would rather avoid further entrenching ourselves in the current setup :)