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
Allow specifying the location to report on for check_code_length
#12676
Comments
@koic fwiw I'm happy to have a crack at this, I just would like to know if maintainers are ok with what I've suggested or have other ideas or etc 🙂 |
So I'm looking into this, and not sure if my preferred "pass a block" idea will work because a block is already being passed to
From what I understand the block is for autocorrection, but this isn't doing anything autocorrecting-ish - instead its doing an assignment, which looks to end up calling a dynamically created method via Meanwhile I've also just found #2414 and #2629 which might indicate the current reporting location was intentionally switched to - I suspect that the ecosystem has since changed in a manner that makes it fine to revisit but I'm overall getting the feeling this might be harder to tackle than initially thought. Any guidance or opinions would be welcome :) |
Fixes rubocop#12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Fixes rubocop#12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Fixes rubocop#12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Fixes rubocop#12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Fixes rubocop#12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Fixes rubocop#12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Fixes rubocop#12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Fixes rubocop#12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Fixes #12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Fixes rubocop#12676. Highlighting offenses for entire classes, modules, and methods is considered noisy in LSP. Instead, highlighting will be applied only to the class names or method names for offenses. To maintain compatibility for uses outside of LSP, such as with `--disable-uncorrectable`, the behavior will be changed only when `RuboCop::LSP.enabled?` is true.
Is your feature request related to a problem? Please describe.
"I'm always frustrated when..." I'm working on a complex test and suddenly my IDE flags every single line in the block because it's too long:
In the above, the first test is being flagged by
RSpec/MultipleExpectations
while the second is being flagged byRSpec/ExampleLength
- while these cops belong torubocop-rspec
, the latter is literally just callingcheck_code_length
which is arubocop
core method hence I'm opening this issue.Describe the solution you'd like
I'd like
RSpec/ExampleLength
to report on the sending node rather than the whole block, so by extension I'd like to be able to somehow control the nodecheck_code_length
reports as the location of the offense.Describe alternatives you've considered
Forking
check_code_length
inrubocop-rspec
- there's not that much code so this doesn't seem like the worst thing in the world, but I expect it would be harder to convince the team to accept such a PR and really this issue could apply to any cop usingcheck_code_length
.I could also disable the cop on the test while I'm working, but that's a bit annoying to have to manage - I've got to do it each time, and then remove it if I manage to shrink the example again.
Additional context
I've got three ideas on how this could be supported without a breaking change:
add_offense
, and passed the values currently being passed toadd_offense
; this would allow the most flexibilityyield
so it'd gracefully fallback on older versions of Rubocop)location
a param with a default value; I think that should be completely not breaking, though it would be annoying having such a complex default value and technically the method would do a bit more work than it does now whennode.line_count <= max_length
check_code_length
and then expose a couple of public methods with different signatures (including the current "original", +check_code_length_with_location
etc); effectively 2. but in a way that makes it easier to avoid breaking changes if the signature needs to change in futureThe text was updated successfully, but these errors were encountered: