Skip to content

Commit

Permalink
Fix a build error
Browse files Browse the repository at this point in the history
This commit fixes the following build error.

```consle
% bundle exec rake
(snip)

Offenses:

lib/rubocop/cop/rails/delegate.rb:103:13: W: [Correctable]
Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying
precedence with parentheses to avoid ambiguity.
            include_prefix_case? && method_name == prefixed_method_name(body)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rails/dynamic_find_by.rb:43:21: W: [Correctable]
Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying
precedence with parentheses to avoid ambiguity.
          return if node.receiver.nil? && !inherit_active_record_base?(node) || allowed_invocation?(node)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rails/http_positional_arguments.rb:72:15: W:
[Correctable] Lint/AmbiguousOperatorPrecedence: Wrap expressions with
varying precedence with parentheses to avoid ambiguity.
              format_arg?(pair.key) && data.pairs.one?
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rails/pluralization_grammar.rb:64:11: W: [Correctable]
Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying
precedence with parentheses to avoid ambiguity.
          singular_receiver?(number) && plural_method?(node.method_name) ||
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rails/pluralization_grammar.rb:65:13: W: [Correctable]
Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying
precedence with parentheses to avoid ambiguity.
            plural_receiver?(number) && singular_method?(node.method_name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rails/reversible_migration.rb:346:13: W: [Correctable]
Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying
precedence with parentheses to avoid ambiguity.
            ancestor.block_type? && ...
            ^^^^^^^^^^^^^^^^^^^^^^^

218 files inspected, 6 offenses detected, 6 offenses auto-correctable
```
  • Loading branch information
koic committed Aug 30, 2021
1 parent efe0ec9 commit 3e86c7b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/delegate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def arguments_match?(arg_array, body)

def method_name_matches?(method_name, body)
method_name == body.method_name ||
include_prefix_case? && method_name == prefixed_method_name(body)
(include_prefix_case? && method_name == prefixed_method_name(body))
end

def include_prefix_case?
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/dynamic_find_by.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DynamicFindBy < Base
IGNORED_ARGUMENT_TYPES = %i[hash splat].freeze

def on_send(node)
return if node.receiver.nil? && !inherit_active_record_base?(node) || allowed_invocation?(node)
return if (node.receiver.nil? && !inherit_active_record_base?(node)) || allowed_invocation?(node)

method_name = node.method_name
static_name = static_method_name(method_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/http_positional_arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def needs_conversion?(data)

data.each_pair.none? do |pair|
special_keyword_arg?(pair.key) ||
format_arg?(pair.key) && data.pairs.one?
(format_arg?(pair.key) && data.pairs.one?)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rails/pluralization_grammar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def correct_method(method_name)
def offense?(node)
number, = *node.receiver

singular_receiver?(number) && plural_method?(node.method_name) ||
plural_receiver?(number) && singular_method?(node.method_name)
(singular_receiver?(number) && plural_method?(node.method_name)) ||
(plural_receiver?(number) && singular_method?(node.method_name))
end

def plural_method?(method_name)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rails/reversible_migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ def within_change_method?(node)

def within_reversible_or_up_only_block?(node)
node.each_ancestor(:block).any? do |ancestor|
ancestor.block_type? &&
ancestor.send_node.method?(:reversible) ||
(ancestor.block_type? &&
ancestor.send_node.method?(:reversible)) ||
ancestor.send_node.method?(:up_only)
end
end
Expand Down

0 comments on commit 3e86c7b

Please sign in to comment.