Skip to content

Commit

Permalink
Restyle example formatting for Style/CaseEquality
Browse files Browse the repository at this point in the history
Follow up of #4880 (comment)

This PR is a change of document format for `Style/CaseEquality` cop.
  • Loading branch information
koic authored and bbatsov committed Aug 29, 2021
1 parent d1bc1eb commit d8ed6ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config/default.yml
Expand Up @@ -2995,7 +2995,7 @@ Style/CaseEquality:
Enabled: true
VersionAdded: '0.9'
VersionChanged: '0.89'
# If AllowOnConstant is enabled, the cop will ignore violations when the receiver of
# If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
# the case equality operator is a constant.
#
# # bad
Expand Down
15 changes: 6 additions & 9 deletions lib/rubocop/cop/style/case_equality.rb
Expand Up @@ -5,9 +5,11 @@ module Cop
module Style
# This cop checks for uses of the case equality operator(===).
#
# If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
# the case equality operator is a constant.
#
# @example
# # bad
# Array === something
# (1..100) === 7
# /something/ === some_string
#
Expand All @@ -16,18 +18,13 @@ module Style
# (1..100).include?(7)
# /something/.match?(some_string)
#
# @example AllowOnConstant
# # Style/CaseEquality:
# # AllowOnConstant: true
#
# @example AllowOnConstant: false (default)
# # bad
# (1..100) === 7
# /something/ === some_string
# Array === something
#
# @example AllowOnConstant: true
# # good
# Array === something
# (1..100).include?(7)
# /something/.match?(some_string)
#
class CaseEquality < Base
extend AutoCorrector
Expand Down

0 comments on commit d8ed6ab

Please sign in to comment.