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
[Fix #3542] Add IgnoreCopDirectives option to Metrics/LineLength #3583
[Fix #3542] Add IgnoreCopDirectives option to Metrics/LineLength #3583
Conversation
@@ -2,6 +2,8 @@ | |||
|
|||
## master (unreleased) | |||
|
|||
* [#3542](https://github.com/bbatsov/rubocop/issues/3542): Add a configuration option, `IgnoreCopDirectives`, to `Metrics/LineLength` to stop cop directives (`# rubocop:disable Metrics/AbcSize`) from being counted when considering line length. ([@jmks][]) |
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 should be under "New Features".
@@ -1117,6 +1117,7 @@ Metrics/LineLength: | |||
URISchemes: | |||
- http | |||
- https | |||
IgnoreCopDirectives: false |
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.
I'd also add some comment here explaining what this config does.
comment.text.match(CommentConfig::COMMENT_DIRECTIVE_REGEXP) | ||
end | ||
|
||
def source_without_directive(line) |
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.
Shouldn't this be named line_length_without_directive
or something like this?
The name you chose is OK.
Yep. Frankly we don't pay much attention to Rubinius support - there are always some issues with it. |
And you'll have to rebase. |
The IgnoreCopDirectives option of Metrics/LineLength ignores directives like '# rubocop:disable ...' when calculating the line's length.
d4db8ec
to
b91ea0f
Compare
Updated from the review and rebased. |
Thanks very much for your work on this @jmks! |
Fix #3542 Since it's Hackoberfest, I thought I'd give this a shot.
This adds a
IgnoreCopDirectives
option toMetrics\LineLength
that ignores directives like# rubocop:disable ...
from counting against the line length max.I'm unsure of a couple things:
# rubocop:[dis]able
type comments already have a name. In the source they seem to be called directives, so I went with that when naming the optionIgnoreCopDirectives
Thanks!
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.