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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


### Bug fixes

Expand Down Expand Up @@ -41,6 +41,7 @@
* [#4787](https://github.com/bbatsov/rubocop/pull/4787): RuboCop no longer installs on MRI 2.0. ([@deivid-rodriguez][])
* [#4266](https://github.com/bbatsov/rubocop/issues/4266): Download the inherited config files of a remote file from the same remote. ([@tdeo][])
* [#4853](https://github.com/bbatsov/rubocop/pull/4853): Make `Lint/LiteralInCondition` cop aware of `!` and `not`. ([@pocke][])
* [#4864](https://github.com/bbatsov/rubocop/pull/4864): Rename `Lint/LiteralInCondition` to `Lint/LiteralAsCondition`. ([@pocke][])

## 0.50.0 (2017-09-14)

Expand Down
6 changes: 3 additions & 3 deletions config/enabled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ Lint/InterpolationCheck:
Description: 'Raise warning for interpolation in single q strs'
Enabled: true

Lint/LiteralInCondition:
Lint/LiteralAsCondition:
Description: 'Checks of literals used in conditions.'
Enabled: true

Expand Down Expand Up @@ -1338,9 +1338,9 @@ Lint/RedundantWithObject:
Description: 'Checks for redundant `with_object`.'
Enabled: true

Lint/RegexpInCondition:
Lint/RegexpAsCondition:
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

The regexp literal matches `$_` implicitly.
Enabled: true

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
require_relative 'rubocop/cop/lint/inherit_exception'
require_relative 'rubocop/cop/lint/ineffective_access_modifier'
require_relative 'rubocop/cop/lint/interpolation_check'
require_relative 'rubocop/cop/lint/literal_in_condition'
require_relative 'rubocop/cop/lint/literal_as_condition'
require_relative 'rubocop/cop/lint/literal_in_interpolation'
require_relative 'rubocop/cop/lint/loop'
require_relative 'rubocop/cop/lint/multiple_compare'
Expand All @@ -253,7 +253,7 @@
require_relative 'rubocop/cop/lint/rand_one'
require_relative 'rubocop/cop/lint/redundant_with_index'
require_relative 'rubocop/cop/lint/redundant_with_object'
require_relative 'rubocop/cop/lint/regexp_in_condition'
require_relative 'rubocop/cop/lint/regexp_as_condition'
require_relative 'rubocop/cop/lint/require_parentheses'
require_relative 'rubocop/cop/lint/rescue_exception'
require_relative 'rubocop/cop/lint/rescue_type'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Lint
# if some_var && some_condition
# do_something
# end
class LiteralInCondition < Cop
class LiteralAsCondition < Cop
MSG = 'Literal `%s` appeared in a condition.'.freeze

def on_if(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module Lint
# if /foo/ =~ $_
# do_something
# end
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

' The regexp literal matches `$_` implicitly.'.freeze

def on_match_current_line(node)
Expand Down
4 changes: 2 additions & 2 deletions manual/cops.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ In the following section you find all available cops:
* [Lint/IneffectiveAccessModifier](cops_lint.md#lintineffectiveaccessmodifier)
* [Lint/InheritException](cops_lint.md#lintinheritexception)
* [Lint/InterpolationCheck](cops_lint.md#lintinterpolationcheck)
* [Lint/LiteralInCondition](cops_lint.md#lintliteralincondition)
* [Lint/LiteralAsCondition](cops_lint.md#lintliteralascondition)
* [Lint/LiteralInInterpolation](cops_lint.md#lintliteralininterpolation)
* [Lint/Loop](cops_lint.md#lintloop)
* [Lint/MultipleCompare](cops_lint.md#lintmultiplecompare)
Expand All @@ -210,7 +210,7 @@ In the following section you find all available cops:
* [Lint/RandOne](cops_lint.md#lintrandone)
* [Lint/RedundantWithIndex](cops_lint.md#lintredundantwithindex)
* [Lint/RedundantWithObject](cops_lint.md#lintredundantwithobject)
* [Lint/RegexpInCondition](cops_lint.md#lintregexpincondition)
* [Lint/RegexpAsCondition](cops_lint.md#lintregexpascondition)
* [Lint/RequireParentheses](cops_lint.md#lintrequireparentheses)
* [Lint/RescueException](cops_lint.md#lintrescueexception)
* [Lint/RescueType](cops_lint.md#lintrescuetype)
Expand Down
4 changes: 2 additions & 2 deletions manual/cops_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ foo = 'something with #{interpolation} inside'
foo = "something with #{interpolation} inside"
```

## Lint/LiteralInCondition
## Lint/LiteralAsCondition

Enabled by default | Supports autocorrection
--- | ---
Expand Down Expand Up @@ -1469,7 +1469,7 @@ ary.each do |v|
end
```

## Lint/RegexpInCondition
## Lint/RegexpAsCondition

Enabled by default | Supports autocorrection
--- | ---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe RuboCop::Cop::Lint::LiteralInCondition do
describe RuboCop::Cop::Lint::LiteralAsCondition do
subject(:cop) { described_class.new }

%w(1 2.0 [1] {} :sym :"#{a}").each do |lit|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe RuboCop::Cop::Lint::RegexpInCondition do
describe RuboCop::Cop::Lint::RegexpAsCondition do
let(:config) { RuboCop::Config.new }
subject(:cop) { described_class.new(config) }

Expand Down