Skip to content

Commit

Permalink
enable percent w rule
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Jun 7, 2024
1 parent f58bb35 commit 8d1b032
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 75 deletions.
100 changes: 50 additions & 50 deletions spec/datadog/ci/codeowners/matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -165,14 +165,14 @@
end

it "returns the list of owners" do
expect(matcher.list_owners("docs/getting-started.md")).to eq(["[email protected]"])
expect(matcher.list_owners("docs/build-app/troubleshooting.md")).to eq(["@owner"])
expect(matcher.list_owners("docs/getting-started.md")).to eq(%w[[email protected]])
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(["[email protected]"])
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[[email protected]])
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(["[email protected]"])
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[[email protected]])
expect(matcher.list_owners("/root/folder/docs/build-app/troubleshooting.md")).to eq(%w[@owner])
end
end

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/datadog/ci/codeowners/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@
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

context "when a codeowners file exists in a .github subdirectory" do
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

context "when a codeowners file exists in a .gitlab subdirectory" do
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

context "when a codeowners file exists in a docs subdirectory" do
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
Expand Down
18 changes: 9 additions & 9 deletions spec/datadog/ci/contrib/minitest/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions spec/datadog/ci/contrib/rspec/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/ci/contrib/selenium/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/ci/itr/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions static-analysis.datadog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ rulesets:
hash-fetch:
ignore:
- '**'
percent-w:
ignore:
- spec/**/*
no-optional-hash-params:
ignore:
- '**'
2 changes: 1 addition & 1 deletion tasks/release_gem.rake
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 8d1b032

Please sign in to comment.