Skip to content
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

Rename LiteralInCondition and RegexpInCondition to LiteralAsCondition and RegexpAsCondition #4864

Merged
merged 2 commits into from
Oct 16, 2017

Conversation

pocke
Copy link
Collaborator

@pocke pocke commented Oct 15, 2017

Follow up for #4854 (comment)
This change renames cops, and improves the message and description.

  • Lint/LiteralInCondition => Lint/LiteralAsCondition
  • Lint/RegexpInCondition => Lint/RegexpAsCondition
    • Improve the offense message
    • Improve the cop description

Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Used the same coding conventions as the rest of the project.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • All tests(rake spec) are passing.
  • The new code doesn't generate RuboCop offenses that are checked by rake internal_investigation.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Updated cop documentation with rake generate_cops_documentation (required only when you've added a new cop or changed the configuration/documentation of an existing cop).

… and RegexpAsCondition

- Lint/LiteralInCondition => Lint/LiteralAsCondition
- Lint/RegexpInCondition => Lint/RegexpAsCondition
  - Improve the offense message
  - Improve the cop description
@pocke pocke force-pushed the rename-literal-in-condition branch from 60a3b53 to 6752d3a Compare October 15, 2017 08:03
CHANGELOG.md Outdated
@@ -10,7 +10,7 @@
* [#4796](https://github.com/bbatsov/rubocop/pull/4796): Add new `Lint/RedundantWithObject` cop. ([@koic][])
* [#4663](https://github.com/bbatsov/rubocop/issues/4663): Add new `Style/CommentedKeyword` cop. ([@donjar][])
* Add `IndentationWidth` configuration for `Layout/Tab` cop. ([@rrosenblum][])
* [#4854](https://github.com/bbatsov/rubocop/pull/4854): Add new `Lint/RegexpInCondition` cop. ([@pocke][])
* [#4854](https://github.com/bbatsov/rubocop/pull/4854): Add new `Lint/RegexpInCondition` cop(Note: This cop was renamed to `Lint/RegexpAsCondition`). ([@pocke][])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is unreleased I guess you can just update the name in place.

class RegexpInCondition < Cop
MSG = 'Do not use regexp literal in condition.' \
class RegexpAsCondition < Cop
MSG = 'Do not use regexp literal as condition.' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a

Description: >-
Do not use regexp literal in condition.
Do not use regexp literal as condition.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 15, 2017

Btw, on an unrelated note - probably the messages should also feature the literal in question, so they are more useful to end users.

@bbatsov bbatsov merged commit 76b65f4 into rubocop:master Oct 16, 2017
@pocke pocke deleted the rename-literal-in-condition branch December 2, 2017 04:45
floehopper added a commit to alphagov/govuk-lint that referenced this pull request Dec 7, 2017
By renaming the config key LiteralInCondition -> LiteralAsCondition.

The former cop was renamed in Rubocop v0.50.0 [1] and was causing the
following deprecation warning to be displayed:

    Warning: unrecognized cop LiteralInCondition found in ...

[1]:
https://github.com/bbatsov/rubocop/blob/v0.51.0/CHANGELOG.md#changes
[2]: rubocop/rubocop#4864
nickcharlton added a commit to thoughtbot/guides that referenced this pull request Dec 15, 2017
tas50 added a commit to tas50/cookstyle that referenced this pull request Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants