-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
--show-cops
CLI option
#395
Conversation
I guess it would be nice if cops were displayed in categories - style, lint, rails. |
@dirkbolte Did you know that |
👍 for this feature. I've been thinking something like this too, since there's no list of available cops currently. Most users notice existence of each cop only when an offence is reported for their code for the first time. |
This feature reminded me that it wouldn't be bad if all cops had some description we can show alongside their names. |
@jonas054 I never tried
|
The last bit will not be possible, since the enabled cops are calculated on a directory bases - unless we assume that with option we'll display the settings for the current directory (which is a reasonable suggestion). As for the descriptions - I'd suggest you take them from default config file and add a |
@dirkbolte Sounds good! I have something that's been on my mind for a while. We have, or will have, these pieces of information related to each cop:
Can we unify these and avoid duplication? |
My first approach would be to use a DESCRIPTION constant as suggested, extract the first line as a short message for the display (to have a similar behavior as Yard). If this constant isn't set, no description would be printed (do we don't have to adjust all cops at once). |
The last commit should contain all the features we talked about in this thread, although the code still looks a little ugly. |
cops.categories.each { |cat| expect(@stdout).to include(cat) } | ||
end | ||
|
||
# it 'prints all cops in their right category' do |
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.
Why is this part commented out?
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.
Will fix that. Forgot to re-enable it.
Am 04.08.2013 um 21:53 schrieb Jonas Arvidsson [email protected]:
In spec/rubocop/cli_spec.rb:
@stdout = $stdout.string
end
it 'prints all available cops and their description' do
subject
cops.each do |cop|
expect(@stdout).to include cop.cop_name
expect(@stdout).to include cop.short_description
end
end
it 'prints all categories' do
subject
cops.categories.each { |cat| expect(@stdout).to include(cat) }
end
+# it 'prints all cops in their right category' do
Why is this part commented out?—
Reply to this email directly or view it on GitHub.
I added the changes and moved all comments in the default configs to 'Description'. Branch is rebased to upstream. I also added a spec to ensure that all future cops have a description. An issue with the implementation is that descriptions do not wrap cleanly at 80 characters when calling --show-cops. |
Seems to me you used some code that's available only in Ruby 2.0 since the build is failing for all other Rubies. |
@@ -142,6 +143,8 @@ | |||
* New cop `EndBlock` tracks uses of `END` blocks. | |||
* New cop `DotPosition` tracks the dot position in multi-line method calls. | |||
* New cop `Attr` tracks uses of `Module#attr`. | |||
* Add support for auto-correction of some offences with `-a`/`--auto-correct`. | |||
* Added `--show-cops` option to show available cops. |
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.
Move this entry to the latest version of RuboCop, since 0.11.0 was already released.
Looks good now. I've added some minor style remarks as inline comments in the code - address them, squash the commits into one and we're good to merge this. |
Will do. Thanks for the feedback. Am 12.08.2013 um 10:33 schrieb Bozhidar Batsov [email protected]:
|
The code looks OK now. Just don't forget to squash the commits together into one. |
* added option to cli * extended cop to get description out of configuration * changed default configuration to have a description field for all cops
Hope that squash is ok. Thanks for the patience. |
You're welcome :-) |
When working with rubocop the last days I had issues to isolate cop names for either specifying them with
--only
or when adding arubocop:disable
comment.For making this easier I thought about an option to list all available cops. The output is not pretty but it's a start.