Skip to content

RuboCop: Enable previously disabled cop RSpec/ContextWording

Peter Leitzen requested to merge pl-rubocop-enable-rspec-context-wording into master

What does this MR do and why?

This MR enables the following 👮 rule which was disabled only due to too many offenses:

Contributes to #369268 (closed).

Configuration Prefixes

It also modifies the default configuration to extend Prefixes.

According to https://github.com/rubocop/rspec-style-guide#context-descriptions:

A typical description will be an adjunct phrase starting with 'when', 'with', 'without', or similar words.

The list determined by listing most common used words in current offenses via:

files=$(ruby -ryaml -e 'puts YAML.load_file(".rubocop_todo/rspec/context_wording.yml").values.first.fetch("Exclude")')

bundle exec rubocop --parallel --only RSpec/ContextWording $files > rubocop-rspec-context-wording-offenses-default.txt

rg -r '$1'  -o "^\s+context .(\w+)" rubocop-rspec-context-wording-offenses-default.txt | sort | uniq -c |
 sort -nr | head -20
   1549 for
    890 and
    538 user
    510 on
    403 the
    356 as
    261 project
    245 in
    229 group
    221 by
    193 a
    191 no
    183 if
    181 filtering
    171 using
    169 invalid
    148 feature
    137 valid
    126 is
    118 authorized
Before After
18722 offenses detected 15499 offenses detected

All pending TODOs have been regenerated via

bundle exec rake rubocop:todo:generate[RSpec/ContetxWording]

How to set up and validate locally

bundle exec rake rubocop:todo:generate[RSpec/ContetxWording]

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports