From 8d1b032ced019e0ac109b266ac7be22df8749c7c Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 7 Jun 2024 09:07:20 +0200 Subject: [PATCH] enable percent w rule --- spec/datadog/ci/codeowners/matcher_spec.rb | 100 +++++++++--------- spec/datadog/ci/codeowners/parser_spec.rb | 8 +- .../contrib/minitest/instrumentation_spec.rb | 18 ++-- .../instrumentation_spec.rb | 4 +- .../ci/contrib/rspec/instrumentation_spec.rb | 8 +- .../contrib/selenium/instrumentation_spec.rb | 2 +- spec/datadog/ci/itr/runner_spec.rb | 2 +- static-analysis.datadog.yml | 3 - tasks/release_gem.rake | 2 +- 9 files changed, 72 insertions(+), 75 deletions(-) diff --git a/spec/datadog/ci/codeowners/matcher_spec.rb b/spec/datadog/ci/codeowners/matcher_spec.rb index 1687ad56..8e340c14 100644 --- a/spec/datadog/ci/codeowners/matcher_spec.rb +++ b/spec/datadog/ci/codeowners/matcher_spec.rb @@ -46,8 +46,8 @@ end it "returns the list of owners" do - expect(matcher.list_owners("/path/to/file.rb")).to eq(["@owner1", "@owner2"]) - expect(matcher.list_owners("/path/to/another_file.rb")).to eq(["@owner3"]) + expect(matcher.list_owners("/path/to/file.rb")).to eq(%w[@owner1 @owner2]) + expect(matcher.list_owners("/path/to/another_file.rb")).to eq(%w[@owner3]) end end @@ -75,8 +75,8 @@ end it "returns the list of owners" do - expect(matcher.list_owners("/path/to/file.rb")).to eq(["@owner1"]) - expect(matcher.list_owners("/path/to/another_file.rb")).to eq(["@owner2"]) + expect(matcher.list_owners("/path/to/file.rb")).to eq(%w[@owner1]) + expect(matcher.list_owners("/path/to/another_file.rb")).to eq(%w[@owner2]) end end @@ -92,8 +92,8 @@ end it "returns the list of owners" do - expect(matcher.list_owners("/path/to/file.rb")).to eq(["@owner1"]) - expect(matcher.list_owners("/path/to/another_file.rb")).to eq(["@owner2"]) + expect(matcher.list_owners("/path/to/file.rb")).to eq(%w[@owner1]) + expect(matcher.list_owners("/path/to/another_file.rb")).to eq(%w[@owner2]) end end @@ -106,8 +106,8 @@ end it "returns the list of owners for the matching pattern" do - expect(matcher.list_owners("/path/to/file.rb")).to eq(["@owner2"]) - expect(matcher.list_owners("/path/to/another_file.rb")).to eq(["@owner1"]) + expect(matcher.list_owners("/path/to/file.rb")).to eq(%w[@owner2]) + expect(matcher.list_owners("/path/to/another_file.rb")).to eq(%w[@owner1]) end end @@ -121,9 +121,9 @@ end it "returns the list of owners" do - expect(matcher.list_owners("/path/to/file.js")).to eq(["@jsowner"]) - expect(matcher.list_owners("main.go")).to eq(["@Datadog/goowner"]) - expect(matcher.list_owners("/main.go")).to eq(["@Datadog/goowner"]) + expect(matcher.list_owners("/path/to/file.js")).to eq(%w[@jsowner]) + expect(matcher.list_owners("main.go")).to eq(%w[@Datadog/goowner]) + expect(matcher.list_owners("/main.go")).to eq(%w[@Datadog/goowner]) expect(matcher.list_owners("file.rb")).to be_nil expect(matcher.list_owners("AbstractFactory.java")).to eq([]) end @@ -142,13 +142,13 @@ end it "returns the list of owners" do - expect(matcher.list_owners("/build/logs/logs.txt")).to eq(["@buildlogsowner"]) - expect(matcher.list_owners("build/logs/2022/logs.txt")).to eq(["@buildlogsowner"]) - expect(matcher.list_owners("/build/logs/2022/12/logs.txt")).to eq(["@buildlogsowner"]) - expect(matcher.list_owners("build/logs/2022/12/logs.txt")).to eq(["@buildlogsowner"]) + expect(matcher.list_owners("/build/logs/logs.txt")).to eq(%w[@buildlogsowner]) + expect(matcher.list_owners("build/logs/2022/logs.txt")).to eq(%w[@buildlogsowner]) + expect(matcher.list_owners("/build/logs/2022/12/logs.txt")).to eq(%w[@buildlogsowner]) + expect(matcher.list_owners("build/logs/2022/12/logs.txt")).to eq(%w[@buildlogsowner]) - expect(matcher.list_owners("/service/build/logs/logs.txt")).to eq(["@owner"]) - expect(matcher.list_owners("service/build/build.pkg")).to eq(["@owner"]) + expect(matcher.list_owners("/service/build/logs/logs.txt")).to eq(%w[@owner]) + expect(matcher.list_owners("service/build/build.pkg")).to eq(%w[@owner]) end end @@ -165,14 +165,14 @@ end it "returns the list of owners" do - expect(matcher.list_owners("docs/getting-started.md")).to eq(["docs@example.com"]) - expect(matcher.list_owners("docs/build-app/troubleshooting.md")).to eq(["@owner"]) + expect(matcher.list_owners("docs/getting-started.md")).to eq(%w[docs@example.com]) + expect(matcher.list_owners("docs/build-app/troubleshooting.md")).to eq(%w[@owner]) - expect(matcher.list_owners("some/folder/docs/getting-started.md")).to eq(["docs@example.com"]) - expect(matcher.list_owners("some/folder/docs/build-app/troubleshooting.md")).to eq(["@owner"]) + expect(matcher.list_owners("some/folder/docs/getting-started.md")).to eq(%w[docs@example.com]) + expect(matcher.list_owners("some/folder/docs/build-app/troubleshooting.md")).to eq(%w[@owner]) - expect(matcher.list_owners("/root/docs/getting-started.md")).to eq(["docs@example.com"]) - expect(matcher.list_owners("/root/folder/docs/build-app/troubleshooting.md")).to eq(["@owner"]) + expect(matcher.list_owners("/root/docs/getting-started.md")).to eq(%w[docs@example.com]) + expect(matcher.list_owners("/root/folder/docs/build-app/troubleshooting.md")).to eq(%w[@owner]) end end @@ -188,14 +188,14 @@ end it "returns the list of owners" do - expect(matcher.list_owners("/apps/file.txt")).to eq(["@octocat"]) - expect(matcher.list_owners("/some/folder/apps/file.txt")).to eq(["@octocat"]) - expect(matcher.list_owners("some/folder/apps/1/file.txt")).to eq(["@octocat"]) - expect(matcher.list_owners("some/folder/apps/1/2/file.txt")).to eq(["@octocat"]) - - expect(matcher.list_owners("file.txt")).to eq(["@owner"]) - expect(matcher.list_owners("/file.txt")).to eq(["@owner"]) - expect(matcher.list_owners("some/folder/file.txt")).to eq(["@owner"]) + expect(matcher.list_owners("/apps/file.txt")).to eq(%w[@octocat]) + expect(matcher.list_owners("/some/folder/apps/file.txt")).to eq(%w[@octocat]) + expect(matcher.list_owners("some/folder/apps/1/file.txt")).to eq(%w[@octocat]) + expect(matcher.list_owners("some/folder/apps/1/2/file.txt")).to eq(%w[@octocat]) + + expect(matcher.list_owners("file.txt")).to eq(%w[@owner]) + expect(matcher.list_owners("/file.txt")).to eq(%w[@owner]) + expect(matcher.list_owners("some/folder/file.txt")).to eq(%w[@owner]) end end @@ -212,14 +212,14 @@ end it "returns the list of owners" do - expect(matcher.list_owners("/build/logs/logs.txt")).to eq(["@octocat"]) - expect(matcher.list_owners("/scripts/logs/logs.txt")).to eq(["@octocat"]) - expect(matcher.list_owners("/deeply/nested/logs/logs.txt")).to eq(["@octocat"]) - expect(matcher.list_owners("/logs/logs.txt")).to eq(["@octocat"]) - - expect(matcher.list_owners("file.txt")).to eq(["@owner"]) - expect(matcher.list_owners("/file.txt")).to eq(["@owner"]) - expect(matcher.list_owners("some/folder/file.txt")).to eq(["@owner"]) + expect(matcher.list_owners("/build/logs/logs.txt")).to eq(%w[@octocat]) + expect(matcher.list_owners("/scripts/logs/logs.txt")).to eq(%w[@octocat]) + expect(matcher.list_owners("/deeply/nested/logs/logs.txt")).to eq(%w[@octocat]) + expect(matcher.list_owners("/logs/logs.txt")).to eq(%w[@octocat]) + + expect(matcher.list_owners("file.txt")).to eq(%w[@owner]) + expect(matcher.list_owners("/file.txt")).to eq(%w[@owner]) + expect(matcher.list_owners("some/folder/file.txt")).to eq(%w[@owner]) end end @@ -237,14 +237,14 @@ end it "returns the list of owners" do - expect(matcher.list_owners("/apps/logs.txt")).to eq(["@octocat"]) - expect(matcher.list_owners("/apps/1/logs.txt")).to eq(["@octocat"]) - expect(matcher.list_owners("/apps/deeply/nested/logs/logs.txt")).to eq(["@octocat"]) + expect(matcher.list_owners("/apps/logs.txt")).to eq(%w[@octocat]) + expect(matcher.list_owners("/apps/1/logs.txt")).to eq(%w[@octocat]) + expect(matcher.list_owners("/apps/deeply/nested/logs/logs.txt")).to eq(%w[@octocat]) expect(matcher.list_owners("apps/github")).to eq([]) expect(matcher.list_owners("apps/github/codeowners")).to eq([]) - expect(matcher.list_owners("other/file.txt")).to eq(["@owner"]) + expect(matcher.list_owners("other/file.txt")).to eq(%w[@owner]) end end @@ -264,16 +264,16 @@ end it "returns the list of owners" do - expect(matcher.list_owners("data-models/model")).to eq(["@data-science-team"]) - expect(matcher.list_owners("data-models/search/model")).to eq(["@data-science-team"]) + expect(matcher.list_owners("data-models/model")).to eq(%w[@data-science-team]) + expect(matcher.list_owners("data-models/search/model")).to eq(%w[@data-science-team]) - expect(matcher.list_owners("README.md")).to eq(["@docs-team"]) - expect(matcher.list_owners("/README.md")).to eq(["@docs-team"]) + expect(matcher.list_owners("README.md")).to eq(%w[@docs-team]) + expect(matcher.list_owners("/README.md")).to eq(%w[@docs-team]) - expect(matcher.list_owners("apps/main.go")).to eq(["@dev-team"]) - expect(matcher.list_owners(".gitignore")).to eq(["@dev-team"]) + expect(matcher.list_owners("apps/main.go")).to eq(%w[@dev-team]) + expect(matcher.list_owners(".gitignore")).to eq(%w[@dev-team]) - expect(matcher.list_owners("spec/helpers_spec.rb")).to eq(["@qa-team"]) + expect(matcher.list_owners("spec/helpers_spec.rb")).to eq(%w[@qa-team]) end end end diff --git a/spec/datadog/ci/codeowners/parser_spec.rb b/spec/datadog/ci/codeowners/parser_spec.rb index 75b67cd8..f1f81222 100644 --- a/spec/datadog/ci/codeowners/parser_spec.rb +++ b/spec/datadog/ci/codeowners/parser_spec.rb @@ -18,7 +18,7 @@ let(:root_file_path) { "#{fixtures_location}/default-codeowners" } it "returns a Matcher instance with default codeowners file path" do - expect(matcher.list_owners("foo/bar.rb")).to eq(["@default"]) + expect(matcher.list_owners("foo/bar.rb")).to eq(%w[@default]) end end @@ -26,7 +26,7 @@ let(:root_file_path) { "#{fixtures_location}/github-codeowners" } it "returns a Matcher instance with github codeowners file path" do - expect(matcher.list_owners("foo/bar.rb")).to eq(["@github"]) + expect(matcher.list_owners("foo/bar.rb")).to eq(%w[@github]) end end @@ -34,7 +34,7 @@ let(:root_file_path) { "#{fixtures_location}/gitlab-codeowners" } it "returns a Matcher instance with gitlab codeowners file path" do - expect(matcher.list_owners("foo/bar.rb")).to eq(["@gitlab"]) + expect(matcher.list_owners("foo/bar.rb")).to eq(%w[@gitlab]) end end @@ -42,7 +42,7 @@ let(:root_file_path) { "#{fixtures_location}/docs-codeowners" } it "returns a Matcher instance with docs codeowners file path" do - expect(matcher.list_owners("foo/bar.rb")).to eq(["@docs"]) + expect(matcher.list_owners("foo/bar.rb")).to eq(%w[@docs]) end end end diff --git a/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb index a1196b81..11dd578c 100644 --- a/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb @@ -504,7 +504,7 @@ def test_pass_other it "skips a single test" do expect(test_spans).to have(2).items - expect(test_spans).to have_tag_values_no_order(:status, ["skip", "pass"]) + expect(test_spans).to have_tag_values_no_order(:status, %w[skip pass]) expect(first_test_span).to have_test_tag(:itr_skipped_by_itr, "true") expect(test_spans.last).not_to have_test_tag(:itr_skipped_by_itr) @@ -663,11 +663,11 @@ def test_b_2 expect(test_spans).to have_tag_values_no_order( :name, - [ - "test_a_1", - "test_a_2", - "test_b_1", - "test_b_2" + %w[ + test_a_1 + test_a_2 + test_b_1 + test_b_2 ] ) expect(test_spans).to have_unique_tag_values_count(:test_suite_id, 4) @@ -719,7 +719,7 @@ def test_b_2 it "skips given tests" do expect(test_spans).to have(4).items - expect(test_spans).to have_tag_values_no_order(:status, ["skip", "skip", "skip", "pass"]) + expect(test_spans).to have_tag_values_no_order(:status, %w[skip skip skip pass]) skipped = test_spans.select { |span| span.get_tag("status") == "skip" } expect(skipped).to all have_test_tag(:itr_skipped_by_itr, "true") @@ -795,7 +795,7 @@ def test_1 it "runs all tests in unskippable suite and sets forced run tag" do expect(test_spans).to have(3).items - expect(test_spans).to have_tag_values_no_order(:status, ["pass", "pass", "skip"]) + expect(test_spans).to have_tag_values_no_order(:status, %w[pass pass skip]) unskippable = test_spans.select { |span| span.get_tag("test.status") == "pass" } expect(unskippable).to all have_test_tag(:itr_forced_run, "true") @@ -831,7 +831,7 @@ def test_2 it "runs unskippable test and sets forced run tag" do expect(test_spans).to have(2).items - expect(test_spans).to have_tag_values_no_order(:status, ["pass", "skip"]) + expect(test_spans).to have_tag_values_no_order(:status, %w[pass skip]) unskippable = test_spans.select { |span| span.get_tag("test.status") == "pass" } expect(unskippable).to all have_test_tag(:itr_forced_run, "true") diff --git a/spec/datadog/ci/contrib/minitest_shoulda_context/instrumentation_spec.rb b/spec/datadog/ci/contrib/minitest_shoulda_context/instrumentation_spec.rb index 27c78fbf..595c2f6f 100644 --- a/spec/datadog/ci/contrib/minitest_shoulda_context/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/minitest_shoulda_context/instrumentation_spec.rb @@ -30,7 +30,7 @@ expect([test_session_span, test_module_span]).to all have_pass_status expect(test_suite_spans).to have(1).item - expect(test_suite_spans).to have_tag_values_no_order(:status, ["pass"]) + expect(test_suite_spans).to have_tag_values_no_order(:status, %w[pass]) expect(test_suite_spans).to have_tag_values_no_order( :suite, @@ -40,7 +40,7 @@ ) expect(test_spans).to have(3).items - expect(test_spans).to have_tag_values_no_order(:status, ["pass", "pass", "skip"]) + expect(test_spans).to have_tag_values_no_order(:status, %w[pass pass skip]) expect(test_spans).to all have_test_tag(:test_suite_id) expect(test_spans).to have_unique_tag_values_count(:test_suite_id, 1) diff --git a/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb b/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb index e7cac9f5..f58b39a7 100644 --- a/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb @@ -690,7 +690,7 @@ def rspec_skipped_session_run rspec_session_run(with_failed_test: true) expect(test_spans).to have(2).items - expect(test_spans).to have_tag_values_no_order(:status, ["skip", "fail"]) + expect(test_spans).to have_tag_values_no_order(:status, %w[skip fail]) itr_skipped_test = test_spans.find { |span| span.name == "nested foo" } expect(itr_skipped_test).to have_test_tag(:itr_skipped_by_itr, "true") @@ -736,7 +736,7 @@ def rspec_skipped_session_run rspec_session_run(with_failed_test: true, unskippable: {test: true}) expect(test_spans).to have(2).items - expect(test_spans).to have_tag_values_no_order(:status, ["skip", "pass"]) + expect(test_spans).to have_tag_values_no_order(:status, %w[skip pass]) itr_unskippable_test = test_spans.find { |span| span.name == "nested foo" } expect(itr_unskippable_test).not_to have_test_tag(:itr_skipped_by_itr) @@ -755,7 +755,7 @@ def rspec_skipped_session_run rspec_session_run(with_failed_test: true, unskippable: {context: true}) expect(test_spans).to have(2).items - expect(test_spans).to have_tag_values_no_order(:status, ["fail", "pass"]) + expect(test_spans).to have_tag_values_no_order(:status, %w[fail pass]) expect(test_spans).to all have_test_tag(:itr_forced_run, "true") expect(test_session_span).to have_test_tag(:itr_tests_skipped, "false") @@ -768,7 +768,7 @@ def rspec_skipped_session_run rspec_session_run(with_failed_test: true, unskippable: {suite: true}) expect(test_spans).to have(2).items - expect(test_spans).to have_tag_values_no_order(:status, ["fail", "pass"]) + expect(test_spans).to have_tag_values_no_order(:status, %w[fail pass]) expect(test_spans).to all have_test_tag(:itr_forced_run, "true") expect(test_session_span).to have_test_tag(:itr_tests_skipped, "false") diff --git a/spec/datadog/ci/contrib/selenium/instrumentation_spec.rb b/spec/datadog/ci/contrib/selenium/instrumentation_spec.rb index eb77668e..a7ec2b99 100644 --- a/spec/datadog/ci/contrib/selenium/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/selenium/instrumentation_spec.rb @@ -19,7 +19,7 @@ create_session: nil, browser: "mockbrowser", capabilities: double("capabilities", browser_version: "mockversion", "[]": "mockcapabilities"), - window_handles: ["window"], + window_handles: %w[window], switch_to_window: true, manage: manager, find_elements_by: [], diff --git a/spec/datadog/ci/itr/runner_spec.rb b/spec/datadog/ci/itr/runner_spec.rb index 897f7416..0f7b450c 100644 --- a/spec/datadog/ci/itr/runner_spec.rb +++ b/spec/datadog/ci/itr/runner_spec.rb @@ -77,7 +77,7 @@ expect(runner.skipping_tests?).to be true expect(runner.correlation_id).to eq("42") - expect(runner.skippable_tests).to eq(Set.new(["suite.test."])) + expect(runner.skippable_tests).to eq(Set.new(%W[suite.test.])) expect(git_worker).to have_received(:wait_until_done) end diff --git a/static-analysis.datadog.yml b/static-analysis.datadog.yml index 9a7ffd51..71c1f579 100644 --- a/static-analysis.datadog.yml +++ b/static-analysis.datadog.yml @@ -10,9 +10,6 @@ rulesets: hash-fetch: ignore: - '**' - percent-w: - ignore: - - spec/**/* no-optional-hash-params: ignore: - '**' diff --git a/tasks/release_gem.rake b/tasks/release_gem.rake index 5c80260b..5a969547 100644 --- a/tasks/release_gem.rake +++ b/tasks/release_gem.rake @@ -1,4 +1,4 @@ -Rake::Task["build"].enhance(["build:pre_check"]) +Rake::Task["build"].enhance(%w[build:pre_check]) desc "Checks executed before gem is built" task :"build:pre_check" do