Skip to content

Commit

Permalink
Unify to remove "This cop" from cop description in default.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed May 10, 2022
1 parent 9bc84f1 commit 15c1227
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Rails/AddColumnIndex:

Rails/AfterCommitOverride:
Description: >-
This cop enforces that there is only one call to `after_commit`
Enforces that there is only one call to `after_commit`
(and its aliases - `after_create_commit`, `after_update_commit`,
and `after_destroy_commit`) with the same callback name per model.
Enabled: 'pending'
Expand Down Expand Up @@ -691,7 +691,7 @@ Rails/RedundantReceiverInWithOptions:
VersionAdded: '0.52'

Rails/RedundantTravelBack:
Description: This cop checks for redundant `travel_back` calls.
Description: Checks for redundant `travel_back` calls.
Enabled: pending
VersionAdded: '2.12'
Include:
Expand Down Expand Up @@ -809,7 +809,7 @@ Rails/SaveBang:

Rails/SchemaComment:
Description: >-
This cop enforces the use of the `comment` option when adding a new table or column
Enforces the use of the `comment` option when adding a new table or column
to the database during a migration.
Enabled: false
VersionAdded: '2.13'
Expand Down
7 changes: 7 additions & 0 deletions spec/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
description = config[name]['Description']
expect(description.nil?).to be(false)
expect(description).not_to include("\n")

start_with_subject = description.match(/\AThis cop (?<verb>.+?) .*/)
suggestion = start_with_subject[:verb]&.capitalize if start_with_subject
suggestion ||= 'a verb'
expect(start_with_subject).to(
be_nil, "`Description` for `#{name}` should be started with `#{suggestion}` instead of `This cop ...`."
)
end
end

Expand Down

0 comments on commit 15c1227

Please sign in to comment.