Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling ScatteredSetup Rubocop rule #9980

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,6 @@ RSpec/RepeatedExampleGroupBody:
RSpec/RepeatedExampleGroupDescription:
Enabled: false

# Offense count: 36
# This cop supports safe autocorrection (--autocorrect).
RSpec/ScatteredSetup:
Exclude:
- 'bundler/spec/dependabot/bundler/file_fetcher_spec.rb'
- 'cargo/spec/dependabot/cargo/file_fetcher_spec.rb'
- 'common/spec/dependabot/clients/bitbucket_spec.rb'
- 'common/spec/dependabot/git_commit_checker_spec.rb'
- 'common/spec/dependabot/metadata_finders/base/commits_finder_spec.rb'
- 'composer/spec/dependabot/composer/update_checker_spec.rb'
- 'docker/spec/dependabot/docker/file_parser_spec.rb'
- 'elm/spec/dependabot/elm/file_fetcher_spec.rb'
- 'go_modules/spec/dependabot/go_modules/file_fetcher_spec.rb'
- 'gradle/spec/dependabot/gradle/update_checker/multi_dependency_updater_spec.rb'
- 'hex/spec/dependabot/hex/file_fetcher_spec.rb'
- 'npm_and_yarn/spec/dependabot/npm_and_yarn/metadata_finder_spec.rb'
- 'nuget/spec/dependabot/nuget/file_fetcher_spec.rb'
- 'python/spec/dependabot/python/file_fetcher_spec.rb'

# Offense count: 10
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
Expand Down
3 changes: 1 addition & 2 deletions bundler/spec/dependabot/bundler/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@

it_behaves_like "a dependency file fetcher"

before { allow(file_fetcher_instance).to receive(:commit).and_return("sha") }

before do
allow(file_fetcher_instance).to receive(:commit).and_return("sha")
stub_request(:get, File.join(url, ".ruby-version?ref=sha"))
.with(headers: { "Authorization" => "token token" })
.to_return(
Expand Down
3 changes: 1 addition & 2 deletions cargo/spec/dependabot/cargo/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@

it_behaves_like "a dependency file fetcher"

before { allow(file_fetcher_instance).to receive(:commit).and_return("sha") }

before do
allow(file_fetcher_instance).to receive(:commit).and_return("sha")
stub_request(:get, url + "Cargo.toml?ref=sha")
.with(headers: { "Authorization" => "token token" })
.to_return(
Expand Down
3 changes: 0 additions & 3 deletions common/spec/dependabot/clients/bitbucket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
stub_request(:get, default_reviewers_url)
.with(headers: { "Authorization" => "Bearer #{access_token}" })
.to_return(status: 200, body: fixture("bitbucket", "default_reviewers_with_data.json"))
end

before do
stub_request(:get, current_user_url)
.with(headers: { "Authorization" => "Bearer #{access_token}" })
.to_return(status: 401, body: fixture("bitbucket", "current_user_no_access.json"))
Expand Down
19 changes: 8 additions & 11 deletions common/spec/dependabot/git_commit_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,14 @@
allow_any_instance_of(DummyPackageManager::MetadataFinder)
.to receive(:look_up_source)
.and_return(Dependabot::Source.from_url(source_url))
stub_request(:get, service_pack_url)
.to_return(
status: 200,
body: fixture("git", "upload_packs", upload_pack_fixture),
headers: {
"content-type" => "application/x-git-upload-pack-advertisement"
}
)
end

let(:source_url) { "https://bitbucket.org/gocardless/business" }
Expand All @@ -309,17 +317,6 @@
"gocardless/business/commits/?exclude=v1.5.0&include=df9f605"
end

before do
stub_request(:get, service_pack_url)
.to_return(
status: 200,
body: fixture("git", "upload_packs", upload_pack_fixture),
headers: {
"content-type" => "application/x-git-upload-pack-advertisement"
}
)
end

context "when not included in a release" do
before do
stub_request(:get, bitbucket_url)
Expand Down
111 changes: 45 additions & 66 deletions common/spec/dependabot/metadata_finders/base/commits_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,48 +180,39 @@

before do
allow(builder)
.to receive(:fetch_dependency_tags)
.and_return(
%w(
@pollyjs/utils@0.1.0
@pollyjs/persister@0.2.0
@pollyjs/persister@0.1.0
@pollyjs/node-server@0.2.0
@pollyjs/node-server@0.1.0
@pollyjs/node-server@0.0.2
@pollyjs/node-server@0.0.1
@pollyjs/ember-cli@0.2.1
@pollyjs/ember-cli@0.2.0
@pollyjs/ember-cli@0.1.0
@pollyjs/ember-cli@0.0.2
@pollyjs/ember-cli@0.0.1
@pollyjs/ember@0.2.1
@pollyjs/ember@0.2.0
@pollyjs/ember@0.1.0
@pollyjs/ember@0.0.2
@pollyjs/ember@0.0.1
@pollyjs/core@0.3.0
@pollyjs/core@0.2.0
@pollyjs/core@0.1.0
@pollyjs/core@0.0.2
@pollyjs/core@0.0.1
@pollyjs/cli@0.1.1
@pollyjs/cli@0.1.0
@pollyjs/cli@0.0.2
@pollyjs/cli@0.0.1
@pollyjs/adapter@0.3.0
@pollyjs/adapter@0.2.0
@pollyjs/adapter@0.1.0
@pollyjs/adapter@0.0.2
@pollyjs/adapter@0.0.1
)
)
end

before do
allow(builder)
.to receive(:reliable_source_directory?)
.and_return(true)
.to receive_messages(fetch_dependency_tags: %w(
@pollyjs/utils@0.1.0
@pollyjs/persister@0.2.0
@pollyjs/persister@0.1.0
@pollyjs/node-server@0.2.0
@pollyjs/node-server@0.1.0
@pollyjs/node-server@0.0.2
@pollyjs/node-server@0.0.1
@pollyjs/ember-cli@0.2.1
@pollyjs/ember-cli@0.2.0
@pollyjs/ember-cli@0.1.0
@pollyjs/ember-cli@0.0.2
@pollyjs/ember-cli@0.0.1
@pollyjs/ember@0.2.1
@pollyjs/ember@0.2.0
@pollyjs/ember@0.1.0
@pollyjs/ember@0.0.2
@pollyjs/ember@0.0.1
@pollyjs/core@0.3.0
@pollyjs/core@0.2.0
@pollyjs/core@0.1.0
@pollyjs/core@0.0.2
@pollyjs/core@0.0.1
@pollyjs/cli@0.1.1
@pollyjs/cli@0.1.0
@pollyjs/cli@0.0.2
@pollyjs/cli@0.0.1
@pollyjs/adapter@0.3.0
@pollyjs/adapter@0.2.0
@pollyjs/adapter@0.1.0
@pollyjs/adapter@0.0.2
@pollyjs/adapter@0.0.1
), reliable_source_directory?: true)
end

it do
Expand Down Expand Up @@ -935,30 +926,18 @@

before do
allow(builder)
.to receive(:fetch_dependency_tags)
.and_return(
%w(
@pollyjs/ember-cli@0.2.1
@pollyjs/ember-cli@0.2.0
@pollyjs/ember-cli@0.1.0
@pollyjs/ember-cli@0.0.2
@pollyjs/ember-cli@0.0.1
@pollyjs/ember@0.2.1
@pollyjs/ember@0.2.0
@pollyjs/ember@0.1.0
@pollyjs/ember@0.0.2
@pollyjs/ember@0.0.1
)
)
end

before do
allow(builder)
.to receive(:reliable_source_directory?)
.and_return(true)
end

before do
.to receive_messages(fetch_dependency_tags: %w(
@pollyjs/ember-cli@0.2.1
@pollyjs/ember-cli@0.2.0
@pollyjs/ember-cli@0.1.0
@pollyjs/ember-cli@0.0.2
@pollyjs/ember-cli@0.0.1
@pollyjs/ember@0.2.1
@pollyjs/ember@0.2.0
@pollyjs/ember@0.1.0
@pollyjs/ember@0.0.2
@pollyjs/ember@0.0.1
), reliable_source_directory?: true)
stub_request(
:get,
"https://api.github.com/repos/netflix/pollyjs/commits?" \
Expand Down
3 changes: 1 addition & 2 deletions composer/spec/dependabot/composer/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,8 @@
}]
end

before { `composer clear-cache --quiet` }

before do
`composer clear-cache --quiet`
url = "https://php.fury.io/dependabot-throwaway/packages.json"
stub_request(:get, url)
.to_return(status: 200, body: fixture("gemfury_response.json"))
Expand Down
9 changes: 2 additions & 7 deletions docker/spec/dependabot/docker/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@

stub_request(:head, repo_url + "manifests/12.04.5")
.and_return(status: 200, body: "", headers: digest_headers)
end

before do
auth_url = "https://auth.docker.io/token?service=registry.docker.io"
stub_request(:get, auth_url)
.and_return(status: 200, body: { token: "token" }.to_json)
Expand Down Expand Up @@ -248,9 +245,8 @@
fixture("docker", "registry_tags", "small_ubuntu.json")
end

before { digest_headers["docker_content_digest"] = "nomatch" }

before do
digest_headers["docker_content_digest"] = "nomatch"
ubuntu_url = "https://registry.hub.docker.com/v2/library/ubuntu/"
stub_request(:head, /#{Regexp.quote(ubuntu_url)}manifests/)
.and_return(status: 200, body: "", headers: digest_headers)
Expand Down Expand Up @@ -797,9 +793,8 @@
fixture("docker", "registry_tags", "small_ubuntu.json")
end

before { digest_headers["docker_content_digest"] = "nomatch" }

before do
digest_headers["docker_content_digest"] = "nomatch"
ubuntu_url = "https://registry.hub.docker.com/v2/library/ubuntu/"
stub_request(:head, /#{Regexp.quote(ubuntu_url)}manifests/)
.and_return(status: 200, body: "", headers: digest_headers)
Expand Down
3 changes: 1 addition & 2 deletions elm/spec/dependabot/elm/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@

it_behaves_like "a dependency file fetcher"

before { allow(file_fetcher_instance).to receive(:commit).and_return("sha") }

before do
allow(file_fetcher_instance).to receive(:commit).and_return("sha")
stub_request(:get, url + "?ref=sha")
.with(headers: { "Authorization" => "token token" })
.to_return(
Expand Down
2 changes: 0 additions & 2 deletions go_modules/spec/dependabot/go_modules/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

it_behaves_like "a dependency file fetcher"

after { FileUtils.rm_rf(repo_contents_path) }

after do
FileUtils.rm_rf(repo_contents_path)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@
status: 200,
body: fixture("maven_central_metadata", "with_release.xml")
)
end

before do
stub_request(:get, jcenter_metadata_url_protoc)
.to_return(
status: 200,
Expand Down
3 changes: 1 addition & 2 deletions hex/spec/dependabot/hex/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@

it_behaves_like "a dependency file fetcher"

before { allow(file_fetcher_instance).to receive(:commit).and_return("sha") }

before do
allow(file_fetcher_instance).to receive(:commit).and_return("sha")
stub_request(:get, url + "?ref=sha")
.with(headers: { "Authorization" => "token token" })
.to_return(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@
end

context "when the npm link 404s" do
before { stub_request(:get, npm_url).to_return(status: 404) }
before { stub_request(:get, npm_url + "/latest").to_return(status: 404) }
before { stub_request(:get, npm_url + "/latest").to_return(status: 404) }
before do
stub_request(:get, npm_url).to_return(status: 404)
stub_request(:get, npm_url + "/latest").to_return(status: 404)
stub_request(:get, npm_url + "/latest").to_return(status: 404)
end

let(:npm_latest_version_response) { nil }
let(:npm_all_versions_response) { fixture("npm_responses", "etag.json") }
Expand Down
2 changes: 0 additions & 2 deletions nuget/spec/dependabot/nuget/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

it_behaves_like "a dependency file fetcher"

before { allow(file_fetcher_instance).to receive(:commit).and_return("sha") }

before do
allow(file_fetcher_instance).to receive(:commit).and_return("sha")

Expand Down
3 changes: 0 additions & 3 deletions python/spec/dependabot/python/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,6 @@
body: fixture("github", "contents_python_pipfile.json"),
headers: { "content-type" => "application/json" }
)
end

before do
stub_request(:get, url + "Pipfile.lock?ref=sha")
.with(headers: { "Authorization" => "token token" })
.to_return(
Expand Down
Loading