-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Add 'for' and 'if' default prefixes for ContextWording #757
Conversation
afb9f5d
to
bf3cbf5
Compare
bf3cbf5
to
1eaaead
Compare
- when | ||
- with | ||
- without | ||
- if | ||
|
||
### Examples | ||
|
||
#### `Prefixes` configuration option, defaults: 'when', 'with', and | ||
#### `Prefixes` configuration option, defaults: 'for', 'when', |
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.
Looks like there's a problem with the existing documentation here, I've opened #758
But why change the default? It's configurable. Can you please provide more context for your example? |
I originally suggested to @josephan to propose this change, so I'll add my support here. As some background, initially only It was later updated to add I think using Here's a gist showing code from real-world-rails which uses this: https://gist.github.com/andyw8/217a5d62ac060a7031065fe5d9dca648 |
Just for the context, below are prefixes for when 23760 total: 67688 contexts. |
Other than "user", I think all of those could be valid candidates for this rule. |
I can add more to this list:
which can form readable sentences in conjunction with EDIT: I don't have a good idea of how to improve the cop, but it seems too restrictive and is addressing symptoms. Wondering if it would be possible to check the correctness of the complete sentence, I only know of |
Can you give an example of using "those" at the beginning of a context? |
Sorry, my bad. Edited. |
I think automatically checking the grammar is probably a step too far. It's probably not feasible to predict all the words that might be acceptable, so perhaps the guidance wording should be relaxed? Instead of saying
it could say
|
Agree. That's about how
I believe this rule may be relaxed somehow so as a result both the full sentence is readable, and it's clear what distinguishes the context in question from the other ones just by looking at its docstring. Is it even possible to enforce this? Does it make sense to make |
I think it would be ok for rubocop-rspec to be more strict than the styleguide if it can clearly indicate that the default entries are only suggestions rather than a 'definitive' list. |
I think relaxing the style guide wording and adding a note in the cop documentation to half-encourage people to think of adding to the list is fine, but selecting a small list of preferred words is something I think is helpful. Personally, I hate having multiple ways of doing things if they're all equally good. For instance, I can't think of a case where i'd use I don't think we should expect to be able to validate the full grammar or catch 100% of reasonable prefixes, but limiting ourselves to a handful usually makes for more uniform / easy to read test descriptions, imo. |
Completely agree that the guide should better say something like:
WDYT of relaxing the guide this way and keeping the cop default as is? |
@andyw8 Agree that it makes sense to emphasize that the default list is not set in stone, and if "sentence with proper grammar" condition is met, together with something like "reflects the distinction from other contexts", it's ok to use any set of prefixes. |
@andyw8 has updated the guide to be less strict regarding prefixes:
WDYT of closing this, and adding a section to README to emphasize that RuboCop-RSpec welcomes changes to its default configuration? From RuboCop's own README:
|
@pirj sounds good! |
Add
for
as a default prefix inContextWording
check.An example:
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).If you have created a new cop:
config/default.yml
.