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

Tweak document and message for Style/FlipFlop cop #6635

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3129,7 +3129,7 @@ Style/ExpandPathArguments:
VersionAdded: '0.53'

Style/FlipFlop:
Description: 'Checks for flip flops'
Description: 'Checks for flip-flops'
StyleGuide: '#no-flip-flops'
Enabled: true
VersionAdded: '0.16'
Expand Down
5 changes: 3 additions & 2 deletions lib/rubocop/cop/style/flip_flop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
module RuboCop
module Cop
module Style
# This cop looks for uses of flip flop operator
# This cop looks for uses of flip-flop operator.
# flip-flop operator is deprecated since Ruby 2.6.0.
#
# @example
# # bad
Expand All @@ -16,7 +17,7 @@ module Style
# puts x if (x >= 5) && (x <= 10)
# end
class FlipFlop < Cop
MSG = 'Avoid the use of flip flop operators.'.freeze
MSG = 'Avoid the use of flip-flop operators.'.freeze

def on_iflipflop(node)
add_offense(node)
Expand Down
3 changes: 2 additions & 1 deletion manual/cops_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,8 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChan
--- | --- | --- | --- | ---
Enabled | Yes | No | 0.16 | -

This cop looks for uses of flip flop operator
This cop looks for uses of flip-flop operator.
flip-flop operator is deprecated since Ruby 2.6.0.

### Examples

Expand Down
8 changes: 4 additions & 4 deletions spec/rubocop/cop/style/flip_flop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
RSpec.describe RuboCop::Cop::Style::FlipFlop do
subject(:cop) { described_class.new }

it 'registers an offense for inclusive flip flops' do
it 'registers an offense for inclusive flip-flops' do
expect_offense(<<-RUBY.strip_indent)
DATA.each_line do |line|
print line if (line =~ /begin/)..(line =~ /end/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid the use of flip flop operators.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid the use of flip-flop operators.
end
RUBY
end

it 'registers an offense for exclusive flip flops' do
it 'registers an offense for exclusive flip-flops' do
expect_offense(<<-RUBY.strip_indent)
DATA.each_line do |line|
print line if (line =~ /begin/)...(line =~ /end/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid the use of flip flop operators.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid the use of flip-flop operators.
end
RUBY
end
Expand Down