From 180938b6b95f406319e1e4a098f1848a6a274381 Mon Sep 17 00:00:00 2001 From: Takuya Noguchi Date: Mon, 9 May 2022 02:42:16 +0000 Subject: [PATCH] Apply RuboCop linting for Ruby 2.3 Signed-off-by: Takuya Noguchi --- .rubocop.yml | 9 +++------ Gemfile | 2 +- lib/rake/task.rb | 4 ++-- test/test_rake_clean.rb | 2 +- test/test_rake_file_list.rb | 2 +- test/test_rake_task.rb | 2 +- test/test_rake_test_task.rb | 18 +++++++++--------- 7 files changed, 18 insertions(+), 21 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 84d6a7c5b..da0020dbe 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,10 +6,6 @@ AllCops: - rake.gemspec - bin/* -Metrics/LineLength: - Enabled: true - Max: 120 - Style/HashSyntax: Enabled: true @@ -23,8 +19,9 @@ Style/MultilineIfThen: Style/MethodDefParentheses: Enabled: true -Style/BracesAroundHashParameters: +Layout/LineLength: Enabled: true + Max: 120 Layout/IndentationWidth: Enabled: true @@ -35,7 +32,7 @@ Layout/Tab: Layout/EmptyLines: Enabled: true -Layout/TrailingBlankLines: +Layout/TrailingEmptyLines: Enabled: true Layout/TrailingWhitespace: diff --git a/Gemfile b/Gemfile index 8bcbf50a7..1b111915c 100644 --- a/Gemfile +++ b/Gemfile @@ -6,5 +6,5 @@ group :development do gem "bundler" gem "minitest" gem "coveralls" - gem "rubocop" + gem "rubocop", "~> 0.81.0" end diff --git a/lib/rake/task.rb b/lib/rake/task.rb index ec2c756e0..a8ed24ddf 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -276,9 +276,9 @@ def execute(args=nil) application.trace "** Execute #{name}" if application.options.trace application.enhance_with_matching_rule(name) if @actions.empty? if opts = Hash.try_convert(args) and !opts.empty? - @actions.each { |act| act.call(self, args, **opts)} + @actions.each { |act| act.call(self, args, **opts) } else - @actions.each { |act| act.call(self, args)} + @actions.each { |act| act.call(self, args) } end end diff --git a/test/test_rake_clean.rb b/test/test_rake_clean.rb index 654b95258..8fb6a715e 100644 --- a/test/test_rake_clean.rb +++ b/test/test_rake_clean.rb @@ -4,7 +4,7 @@ class TestRakeClean < Rake::TestCase # :nodoc: def test_clean - if RUBY_ENGINE == 'truffleruby' and RUBY_ENGINE_VERSION.start_with?('19.3.') + if RUBY_ENGINE == "truffleruby" and RUBY_ENGINE_VERSION.start_with?("19.3.") load "rake/clean.rb" # TruffleRuby 19.3 does not set self correctly with wrap=true else load "rake/clean.rb", true diff --git a/test/test_rake_file_list.rb b/test/test_rake_file_list.rb index eda55d29f..94572e92b 100644 --- a/test/test_rake_file_list.rb +++ b/test/test_rake_file_list.rb @@ -496,7 +496,7 @@ def test_clone_and_dup assert_equal ["a", "b", "c"], d end - if RUBY_VERSION < '2.7' + if RUBY_VERSION < "2.7" def test_dup_and_clone_replicate_taint a = FileList["a", "b", "c"] a.taint diff --git a/test/test_rake_task.rb b/test/test_rake_task.rb index fa4099b07..bffe2cb59 100644 --- a/test/test_rake_task.rb +++ b/test/test_rake_task.rb @@ -126,7 +126,7 @@ def test_can_triple_invoke_after_exception_with_reenable next if !raise_exception raise_exception = false - raise 'Some error' + raise "Some error" end assert_raises(RuntimeError) { t1.invoke } diff --git a/test/test_rake_test_task.rb b/test/test_rake_test_task.rb index fdb844607..b5b587410 100644 --- a/test/test_rake_test_task.rb +++ b/test/test_rake_test_task.rb @@ -171,20 +171,20 @@ def test_task_prerequisites_deps end def test_task_order_only_prerequisites - t = task(a: 'b') { + t = task(a: "b") { :aaa - } | 'c' - b, c = task('b'), task('c') - assert_equal ['b'], t.prerequisites - assert_equal ['c'], t.order_only_prerequisites + } | "c" + b, c = task("b"), task("c") + assert_equal ["b"], t.prerequisites + assert_equal ["c"], t.order_only_prerequisites assert_equal [b, c], t.prerequisite_tasks end def test_task_order_only_prerequisites_key - t = task 'a' => 'b', order_only: ['c'] - b, c = task('b'), task('c') - assert_equal ['b'], t.prerequisites - assert_equal ['c'], t.order_only_prerequisites + t = task "a" => "b", order_only: ["c"] + b, c = task("b"), task("c") + assert_equal ["b"], t.prerequisites + assert_equal ["c"], t.order_only_prerequisites assert_equal [b, c], t.prerequisite_tasks end end