Skip to content

Commit

Permalink
Enable Style/ParenthesesAroundCondition cop
Browse files Browse the repository at this point in the history
To prevent style check in review like rails#33608 (comment).
  • Loading branch information
kamipo committed Aug 18, 2018
1 parent 9270c6d commit b2c1e29
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ Lint/StringConversionInInterpolation:
Lint/UriEscapeUnescape:
Enabled: true

Style/ParenthesesAroundCondition:
Enabled: true

Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: true
Expand Down
2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/text_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def excerpt(text, phrase, options = {})
# pluralize(2, 'Person', locale: :de)
# # => 2 Personen
def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale)
word = if (count == 1 || count =~ /^1(\.0+)?$/)
word = if count == 1 || count =~ /^1(\.0+)?$/
singular
else
plural || singular.pluralize(locale)
Expand Down
2 changes: 1 addition & 1 deletion actionview/test/template/text_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def setup
super
# This simulates the fact that instance variables are reset every time
# a view is rendered. The cycle helper depends on this behavior.
@_cycles = nil if (defined? @_cycles)
@_cycles = nil if defined?(@_cycles)
end

def test_concat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def belongs_to_counter_cache_after_update(reflection)
foreign_key = reflection.foreign_key
cache_column = reflection.counter_cache_column

if (@_after_replace_counter_called ||= false)
if @_after_replace_counter_called ||= false
@_after_replace_counter_called = false
elsif association(reflection.name).target_changed?
if reflection.polymorphic?
Expand Down
4 changes: 2 additions & 2 deletions guides/rails_guides/levenshtein.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def self.distance(str1, str2)
n = s.length
m = t.length

return m if (0 == n)
return n if (0 == m)
return m if 0 == n
return n if 0 == m

d = (0..m).to_a
x = nil
Expand Down
4 changes: 2 additions & 2 deletions railties/lib/rails/command/spellchecker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def levenshtein_distance(str1, str2) # :doc:
n = s.length
m = t.length

return m if (0 == n)
return n if (0 == m)
return m if 0 == n
return n if 0 == m

d = (0..m).to_a
x = nil
Expand Down

0 comments on commit b2c1e29

Please sign in to comment.