Skip to content

Commit

Permalink
Improve a bit Style/OneLineConditional's message
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Aug 4, 2015
1 parent 3952c72 commit 6ef5a23
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/cop/style/one_line_conditional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module Style
class OneLineConditional < Cop
include OnNormalIfUnless

MSG = 'Favor the ternary operator (?:) ' \
'over %s/then/else/end constructs.'
MSG = 'Favor the ternary operator (`?:`) ' \
'over `%s/then/else/end` constructs.'

def on_normal_if_unless(node)
exp = node.loc.expression.source
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ def interrupt
"if it's surely a splat operator, or add a whitespace to the " \
'right of the `*` if it should be a multiplication.',
"#{abs('example.rb')}:3:1: C: " \
'Favor the ternary operator (?:) over if/then/else/end ' \
'Favor the ternary operator (`?:`) over `if/then/else/end` ' \
'constructs.',
''].join("\n"))
end
Expand Down
8 changes: 4 additions & 4 deletions spec/rubocop/cop/style/one_line_conditional_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

it 'registers an offense for one line if/then/else/end' do
inspect_source(cop, 'if cond then run else dont end')
expect(cop.messages).to eq(['Favor the ternary operator (?:)' \
' over if/then/else/end constructs.'])
expect(cop.messages).to eq(['Favor the ternary operator (`?:`)' \
' over `if/then/else/end` constructs.'])
end

it 'does not register an offense for if/then/end' do
Expand All @@ -18,8 +18,8 @@

it 'does register an offense for one line unless/then/else/end' do
inspect_source(cop, 'unless cond then run else dont end')
expect(cop.messages).to eq(['Favor the ternary operator (?:)' \
' over unless/then/else/end constructs.'])
expect(cop.messages).to eq(['Favor the ternary operator (`?:`)' \
' over `unless/then/else/end` constructs.'])
end

it 'does not register an offense for one line unless/then/end' do
Expand Down

0 comments on commit 6ef5a23

Please sign in to comment.