Skip to content

Commit

Permalink
Suppress keyword arguments warnings in Ruby 2.7 (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
pocke authored and glebm committed Jan 13, 2020
1 parent 26ae43e commit 0ac2841
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 32 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ sudo: false
dist: xenial
language: ruby
rvm:
- 2.5.3
- 2.4.5
- 2.7.0
- 2.6.5
- 2.5.7
- 2.4.9
- 2.3.8
- jruby-9.2.6.0
- rbx-3
Expand All @@ -21,12 +23,12 @@ before_script:
script:
- bundle exec rspec --format d
- >
if [[ "$(rvm current)" = "ruby-2.5"* ]]; then
if [[ "$(rvm current)" = "ruby-2.7"* ]]; then
bundle exec rubocop
fi
after_script:
- >
if [[ "$(rvm current)" = "ruby-2.5"* ]]; then
if [[ "$(rvm current)" = "ruby-2.7"* ]]; then
./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
fi
env:
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/tasks/command/commander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run(name, opts = {})
if opts.empty? || method(name).arity.zero?
send name
else
send name, opts
send name, **opts
end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/i18n/tasks/command/commands/health.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def health(opt = {})
fail CommandError, t('i18n_tasks.health.no_keys_detected') if stats[:key_count].zero?
terminal_report.forest_stats forest, stats
[
missing(opt),
unused(opt),
check_consistent_interpolations(opt),
check_normalized(opt)
missing(**opt),
unused(**opt),
check_consistent_interpolations(**opt),
check_normalized(**opt)
].detect { |result| result == :exit_1 }
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/tasks/command/commands/interpolations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Interpolations
args: %i[locales out_format]

def check_consistent_interpolations(opt = {})
forest = i18n.inconsistent_interpolations(opt.slice(:locales, :base_locale))
forest = i18n.inconsistent_interpolations(**opt.slice(:locales, :base_locale))
print_forest forest, opt, :inconsistent_interpolations
:exit_1 unless forest.empty?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/tasks/command/commands/missing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Missing
args: %i[locales out_format missing_types]

def missing(opt = {})
forest = i18n.missing_keys(opt.slice(:locales, :base_locale, :types))
forest = i18n.missing_keys(**opt.slice(:locales, :base_locale, :types))
print_forest forest, opt, :missing_keys
:exit_1 unless forest.empty?
end
Expand Down
4 changes: 2 additions & 2 deletions lib/i18n/tasks/command/commands/usages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def find(opt = {})
args: %i[locales out_format strict]

def unused(opt = {})
forest = i18n.unused_keys(opt.slice(:locales, :strict))
forest = i18n.unused_keys(**opt.slice(:locales, :strict))
print_forest forest, opt, :unused_keys
:exit_1 unless forest.empty?
end
Expand All @@ -43,7 +43,7 @@ def unused(opt = {})
args: %i[locales out_format strict keep_order confirm pattern]

def remove_unused(opt = {}) # rubocop:disable Metrics/AbcSize
unused_keys = i18n.unused_keys(opt.slice(:locales, :strict))
unused_keys = i18n.unused_keys(**opt.slice(:locales, :strict))

if opt[:pattern]
pattern_re = i18n.compile_key_pattern(opt[:pattern])
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/tasks/data/tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def attributes
end

def derive(new_attr = {})
self.class.new(attributes.merge(new_attr))
self.class.new(**attributes.merge(new_attr))
end

def children=(children)
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/tasks/data/tree/siblings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def from_key_attr(key_attrs, opts = {}, &block)
build_forest(opts) do |forest|
key_attrs.each do |(full_key, attr)|
fail "Invalid key #{full_key.inspect}" if full_key.end_with?('.')
node = ::I18n::Tasks::Data::Tree::Node.new(attr.merge(key: split_key(full_key).last))
node = ::I18n::Tasks::Data::Tree::Node.new(**attr.merge(key: split_key(full_key).last))
yield(full_key, node) if block
forest[full_key] = node
end
Expand Down
14 changes: 6 additions & 8 deletions lib/i18n/tasks/data/tree/traversal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,12 @@ def keys(root: false, &visitor)
self
end

def key_names(opts = {})
opts[:root] = false unless opts.key?(:root)
keys(opts).map { |key, _node| key }
def key_names(root: false)
keys(root: root).map { |key, _node| key }
end

def key_values(opts = {})
opts[:root] = false unless opts.key?(:root)
keys(opts).map { |key, node| [key, node.value] }
def key_values(root: false)
keys(root: root).map { |key, node| [key, node.value] }
end

def root_key_values(sort = false)
Expand Down Expand Up @@ -146,12 +144,12 @@ def get_nodes_by_key_filter(root: false, &block)
# @return [Siblings]
def intersect_keys(other_tree, key_opts = {}, &block)
if block
select_keys(key_opts) do |key, node|
select_keys(**key_opts.slice(:root)) do |key, node|
other_node = other_tree[key]
other_node && yield(key, node, other_node)
end
else
select_keys(key_opts) { |key, _node| other_tree[key] }
select_keys(**key_opts.slice(:root)) { |key, _node| other_tree[key] }
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/tasks/reports/terminal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ def show_tree(tree)

def forest_stats(forest, stats = task.forest_stats(forest))
text = if stats[:locale_count] == 1
I18n.t('i18n_tasks.data_stats.text_single_locale', stats)
I18n.t('i18n_tasks.data_stats.text_single_locale', **stats)
else
I18n.t('i18n_tasks.data_stats.text', stats)
I18n.t('i18n_tasks.data_stats.text', **stats)
end
title = Rainbow(I18n.t('i18n_tasks.data_stats.title', stats.slice(:locales))).bright
title = Rainbow(I18n.t('i18n_tasks.data_stats.title', **stats.slice(:locales))).bright
print_info "#{Rainbow(title).cyan} #{Rainbow(text).cyan}"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/tasks/scanners/ruby_ast_scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RubyAstScanner < FileScanner # rubocop:disable Metrics/ClassLength
RECEIVER_MESSAGES = [nil, AST::Node.new(:const, [nil, :I18n])].product(%i[t t! translate translate!])

def initialize(**args)
super(args)
super(**args)
@parser = ::Parser::CurrentRuby.new
@magic_comment_parser = ::Parser::CurrentRuby.new
@call_finder = RubyAstCallFinder.new(
Expand Down
4 changes: 2 additions & 2 deletions spec/file_system_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
locale_data = { 'pizza' => keys, 'sushi' => keys }
TestCodebase.setup
TestCodebase.in_test_app_dir do
data[:en] = data[:en].merge!('en' => locale_data)
data[:en] = data[:en].merge!({ 'en' => locale_data }) # rubocop:disable Style/BracesAroundHashParameters
files = %w[pizza.en.yml sushi.en.yml]
expect(Dir['*.yml'].sort).to eq(files.sort)
files.each { |f| expect(YAML.load_file(f)['en']).to eq(File.basename(f, '.en.yml') => keys) }
Expand Down Expand Up @@ -120,7 +120,7 @@
locale_data = { 'pizza' => keys, 'sushi' => keys }
TestCodebase.setup
TestCodebase.in_test_app_dir do
data[:en] = data[:en].merge!('en' => locale_data)
data[:en] = data[:en].merge!({ 'en' => locale_data }) # rubocop:disable Style/BracesAroundHashParameters
files = %w[pizza.en.json sushi.en.json]
expect(Dir['*.json'].sort).to eq(files.sort)
files.each do |f|
Expand Down
2 changes: 1 addition & 1 deletion spec/support/keys_and_occurrences.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def make_occurrence(path: '', line: '', pos: 1, line_pos: 1, line_num: 1, raw_ke
# rubocop:enable Metrics/ParameterLists

def make_occurrences(occurrences)
occurrences.map { |attr| make_occurrence(attr) }
occurrences.map { |attr| make_occurrence(**attr) }
end

def make_key_occurrences(key, occurrences)
Expand Down
4 changes: 2 additions & 2 deletions spec/support/trees.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def build_node(attr = {})
I18n::Tasks::Data::Tree::Node.from_key_value(key, value)
end

def new_node(attr = {})
I18n::Tasks::Data::Tree::Node.new(attr)
def new_node(**attr)
I18n::Tasks::Data::Tree::Node.new(**attr)
end
end

0 comments on commit 0ac2841

Please sign in to comment.