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

Enable All RSpec empty line cops #9791

Merged
merged 6 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Enable RSpec/EmptyLineAfterHook
  • Loading branch information
robaiken committed May 21, 2024
commit 836855b55dc2ebb7174bfd2d9633ba6b273f4485
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ RSpec/DescribedClass:
- 'updater/spec/dependabot/api_client_spec.rb'
- 'updater/spec/dependabot/job_spec.rb'

# Offense count: 114
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowConsecutiveOneLiners.
RSpec/EmptyLineAfterHook:
Enabled: false

# Offense count: 288
# This cop supports safe autocorrection (--autocorrect).
RSpec/EmptyLineAfterSubject:
Expand Down
1 change: 1 addition & 0 deletions bundler/helpers/v2/spec/ruby_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@ui = Bundler.ui
Bundler.ui = Bundler::UI::Silent.new
end

after { Bundler.ui = @ui }

it "updates to the most recent version" do
Expand Down
1 change: 1 addition & 0 deletions bundler/spec/dependabot/bundler/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
end

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

before do
stub_request(:get, File.join(url, ".ruby-version?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
stub_request(:get, rubygems_url + "versions/business.json")
.to_return(status: 200, body: rubygems_response)
end

its([:version]) { is_expected.to eq(Gem::Version.new("1.6.0.beta")) }
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

context "with a SHA-1 version" do
before { gemfile_requirement.merge!(source: { type: "git" }) }

let(:updated_source) { { type: "git" } }

its([:requirement]) { is_expected.to eq("~> 1.5.0") }
Expand All @@ -87,6 +88,7 @@
before do
gemfile_requirement.merge!(source: { type: "git", ref: "v1.2.0" })
end

its([:source]) { is_expected.to eq(updated_source) }
end
end
Expand Down Expand Up @@ -248,6 +250,7 @@

context "with multiple Gemfile declarations" do
before { requirements << child_gemfile_requirement }

let(:child_gemfile_requirement) do
gemfile_requirement.merge(file: "backend/Gemfile")
end
Expand Down
2 changes: 2 additions & 0 deletions bundler/spec/dependabot/bundler/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
headers: git_header
)
end

let(:upload_pack_fixture) { "business" }

it "fetches the latest SHA-1 hash of the latest version tag" do
Expand Down Expand Up @@ -899,6 +900,7 @@
headers: git_header
)
end

let(:upload_pack_fixture) { "business" }

it "fetches the latest SHA-1 hash of the latest version tag" do
Expand Down
6 changes: 6 additions & 0 deletions cargo/spec/dependabot/cargo/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
let(:json_header) { { "content-type" => "application/json" } }

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

before do
stub_request(:get, url + "Cargo.toml?ref=sha")
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -247,6 +248,7 @@
.with(headers: { "Authorization" => "token token" })
.to_return(status: 200, body: parent_fixture, headers: json_header)
end

let(:parent_fixture) do
fixture("github", "contents_cargo_manifest_path_deps.json")
end
Expand All @@ -257,6 +259,7 @@
.with(headers: { "Authorization" => "token token" })
.to_return(status: 200, body: path_dep_fixture, headers: json_header)
end

let(:path_dep_fixture) do
fixture("github", "contents_cargo_manifest.json")
end
Expand Down Expand Up @@ -476,6 +479,7 @@
.with(headers: { "Authorization" => "token token" })
.to_return(status: 200, body: parent_fixture, headers: json_header)
end

let(:parent_fixture) do
fixture("github", "contents_cargo_manifest_workspace_root.json")
end
Expand All @@ -486,6 +490,7 @@
.with(headers: { "Authorization" => "token token" })
.to_return(status: 200, body: child_fixture, headers: json_header)
end

let(:child_fixture) do
fixture("github", "contents_cargo_manifest_workspace_child.json")
end
Expand Down Expand Up @@ -676,6 +681,7 @@
.with(headers: { "Authorization" => "token token" })
.to_return(status: 200, body: member_fixture, headers: json_header)
end

let(:parent_fixture) do
fixture("github", "contents_cargo_manifest_workspace_excluded_dependencies_root.json")
end
Expand Down
1 change: 1 addition & 0 deletions cargo/spec/dependabot/cargo/metadata_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
body: crates_response
)
end

let(:crates_response) do
fixture("crates_io_responses", crates_fixture_name)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@

context "with a support file (e.g., a path dependency manifest)" do
before { manifest.support_file = true }

let(:dependency_version) { nil }

it "does not update the requirement" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
stub_request(:get, crates_url)
.to_return(status: 404, body: crates_response)
end

let(:crates_fixture_name) { "not_found.json" }

it { is_expected.to be_nil }
Expand Down Expand Up @@ -314,6 +315,7 @@
stub_request(:get, sparse_registry_url)
.to_return(status: 404, body: sparse_registry_response)
end

let(:crates_fixture_name) { "not_found.json" }

it { is_expected.to be_nil }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
let(:updated_source) { { type: "git", ref: "v1.5.0" } }

before { cargo_req.merge!(source: { type: "git", ref: "v1.2.0" }) }

its([:source]) { is_expected.to eq(updated_source) }
end
end
Expand Down
1 change: 1 addition & 0 deletions cargo/spec/dependabot/cargo/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
before do
stub_request(:get, crates_url).to_return(status: 200, body: crates_response)
end

let(:crates_url) { "https://crates.io/api/v1/crates/#{dependency_name}" }
let(:crates_response) { fixture("crates_io_responses", crates_fixture_name) }
let(:crates_fixture_name) { "#{dependency_name}.json" }
Expand Down
1 change: 1 addition & 0 deletions common/spec/dependabot/clients/azure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@
before do
@request_body = "request body"
end

it "with failure count <= max_retries" do
# Request succeeds on third attempt
stub_request(:post, base_url)
Expand Down
1 change: 1 addition & 0 deletions common/spec/dependabot/clients/bitbucket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
.with(headers: { "Authorization" => "Bearer #{access_token}" })
.to_return(status: 200, body: fixture("bitbucket", "current_user.json"))
end

let(:access_token) { "access_token" }
let(:credentials) do
[Dependabot::Credential.new({
Expand Down
5 changes: 5 additions & 0 deletions common/spec/dependabot/file_fetchers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
Dependabot::Clients::CodeCommit
).to receive(:cc_client).and_return(stubbed_cc_client)
end

let(:repo_contents_path) { nil }

let(:child_class) do
Expand Down Expand Up @@ -1238,6 +1239,7 @@ def fetch_files
file_content: "foo"
)
end

let(:directory) { "app/" }

it "gets the file" do
Expand All @@ -1259,6 +1261,7 @@ def fetch_files
file_content: "foo"
)
end

let(:directory) { "/app" }

it "gets the file" do
Expand All @@ -1280,6 +1283,7 @@ def fetch_files
file_content: "foo"
)
end

let(:directory) { "a/pp" }

it "gets the file" do
Expand Down Expand Up @@ -1375,6 +1379,7 @@ def fetch_files
# `git clone` against a file:// URL that is filled by the test
let(:repo_path) { Dir.mktmpdir }
after { FileUtils.rm_rf(repo_path) }

let(:fill_repo) { nil }

before do
Expand Down
10 changes: 10 additions & 0 deletions common/spec/dependabot/git_commit_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
}
)
end

let(:upload_pack_fixture) { "no_tags" }

context "but no tags on GitHub" do
Expand Down Expand Up @@ -296,6 +297,7 @@
.to receive(:look_up_source)
.and_return(Dependabot::Source.from_url(source_url))
end

let(:source_url) { "https://bitbucket.org/gocardless/business" }
let(:service_pack_url) do
"https://bitbucket.org/gocardless/business.git/info/refs" \
Expand All @@ -315,6 +317,7 @@
}
)
end

let(:upload_pack_fixture) { "business" }

context "when not included in a release" do
Expand Down Expand Up @@ -468,6 +471,7 @@
.with(anything, "git ls-remote #{git_url}")
.and_return(["", "", exit_status])
end

let(:ref) { "my_ref" }

it "raises a helpful error" do
Expand All @@ -491,6 +495,7 @@
stub_request(:get, url + "/info/refs?service=git-upload-pack")
.to_raise(Excon::Error::Timeout)
end

let(:ref) { "my_ref" }

it "raises a helpful error" do
Expand All @@ -505,6 +510,7 @@
stub_request(:get, url + "/info/refs?service=git-upload-pack")
.to_raise(Excon::Error::Timeout)
end

let(:ref) { "my_ref" }

it "raises a generic error (that won't be misinterpreted)" do
Expand Down Expand Up @@ -881,6 +887,7 @@
}
)
end

let(:upload_pack_fixture) { "monolog" }

it { is_expected.to eq(true) }
Expand Down Expand Up @@ -950,6 +957,7 @@
}
)
end

let(:upload_pack_fixture) { "no_tags" }

context "with no tags on GitHub" do
Expand Down Expand Up @@ -1388,6 +1396,7 @@
}
)
end

let(:upload_pack_fixture) { "actions-checkout" }

context "that is a tag" do
Expand Down Expand Up @@ -1446,6 +1455,7 @@
}
)
end

let(:upload_pack_fixture) { "actions-checkout-moving-v2" }

context "for a moving major tag" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
body: changelog_body,
headers: { "Content-Type" => "application/json" })
end

let(:changelog_body) { fixture("github", "changelog_contents.json") }

context "with a changelog" do
Expand Down Expand Up @@ -430,6 +431,7 @@
body: changelog_body,
headers: { "Content-Type" => "application/json" })
end

let(:changelog_body) { fixture("github", "changelog_contents.json") }

it "gets the right URL" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
}
)
end

let(:service_pack_url) do
"https://github.com/gocardless/business.git/info/refs" \
"?service=git-upload-pack"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@

context "when authentication fails" do
before { stub_request(:get, github_url).to_return(status: 404) }

it { is_expected.to be_nil }
end

Expand Down
1 change: 1 addition & 0 deletions common/spec/dependabot/metadata_finders/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
}]
end
before { allow(finder).to receive(:source).and_return(source) }

let(:source) do
Dependabot::Source.new(
provider: "github",
Expand Down
2 changes: 2 additions & 0 deletions common/spec/dependabot/pull_request_creator/github_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@
headers: json_header
)
end

let(:base_commit) { "basecommitsha" }

it "creates a PR" do
Expand Down Expand Up @@ -946,6 +947,7 @@
headers: json_header)
stub_request(:post, "#{repo_api_url}/issues/1347/comments")
end

let(:expected_comment_body) do
"Dependabot tried to add `@greysteil` as a reviewer to this PR, " \
"but received the following error from GitHub:\n\n" \
Expand Down
2 changes: 2 additions & 0 deletions common/spec/dependabot/pull_request_creator/labeler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
body: fixture("github", labels_fixture_name),
headers: json_header)
end

let(:labels_fixture_name) { "labels_with_dependencies.json" }

context "when the 'dependencies' label doesn't yet exist" do
Expand Down Expand Up @@ -512,6 +513,7 @@
body: fixture("github", labels_fixture_name),
headers: json_header)
end

let(:labels_fixture_name) { "labels_with_dependencies.json" }

context "when a 'dependencies' label exists" do
Expand Down
Loading