Skip to content

Commit

Permalink
Avoid some warnings "too many arguments for format string"
Browse files Browse the repository at this point in the history
See #12910

This aren't all cops where this happens, just the ones with trivial solutions
  • Loading branch information
Earlopain committed May 17, 2024
1 parent 673495b commit 8abf553
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 3 additions & 5 deletions lib/rubocop/cop/bundler/gem_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ def allowed_gems
Array(cop_config['AllowedGems'])
end

def message(range)
gem_specification = range.source

def message(_range)
if required_style?
format(REQUIRED_MSG, gem_specification: gem_specification)
REQUIRED_MSG
elsif forbidden_style?
format(FORBIDDEN_MSG, gem_specification: gem_specification)
FORBIDDEN_MSG
end
end

Expand Down
8 changes: 3 additions & 5 deletions lib/rubocop/cop/gemspec/dependency_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,11 @@ def allowed_gems
Array(cop_config['AllowedGems'])
end

def message(range)
gem_specification = range.source

def message(_range)
if required_style?
format(REQUIRED_MSG, gem_specification: gem_specification)
REQUIRED_MSG
elsif forbidden_style?
format(FORBIDDEN_MSG, gem_specification: gem_specification)
FORBIDDEN_MSG
end
end

Expand Down
8 changes: 5 additions & 3 deletions lib/rubocop/cop/style/if_with_boolean_literal_branches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ def offense_range_with_keyword(node, condition)
end

def message(node, keyword)
message_template = node.elsif? ? MSG_FOR_ELSIF : MSG

format(message_template, keyword: keyword)
if node.elsif?
MSG_FOR_ELSIF
else
format(MSG, keyword: keyword)
end
end

def return_boolean_value?(condition)
Expand Down

0 comments on commit 8abf553

Please sign in to comment.