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
Next Next commit
Enable RSpec/EmptyLineAfterExample
  • Loading branch information
robaiken committed May 21, 2024
commit 0eaa3ff3d9b48e0c191c1b56a279943a391f81bc
21 changes: 0 additions & 21 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,6 @@ RSpec/DescribedClass:
- 'updater/spec/dependabot/api_client_spec.rb'
- 'updater/spec/dependabot/job_spec.rb'

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

# Offense count: 25
# This cop supports safe autocorrection (--autocorrect).
RSpec/EmptyLineAfterExampleGroup:
Exclude:
- 'common/spec/dependabot/pull_request_creator/message_builder_spec.rb'
- 'composer/spec/dependabot/composer/file_fetcher_spec.rb'
- 'docker/spec/dependabot/docker/file_updater_spec.rb'
- 'github_actions/spec/dependabot/github_actions/file_updater_spec.rb'
- 'gradle/spec/dependabot/gradle/file_updater_spec.rb'
- 'npm_and_yarn/spec/dependabot/npm_and_yarn/update_checker_spec.rb'
- 'pub/spec/dependabot/pub/requirements_spec.rb'
- 'pub/spec/dependabot/pub/update_checker_spec.rb'
- 'terraform/spec/dependabot/terraform/requirement_spec.rb'
- 'terraform/spec/dependabot/terraform/requirements_updater_spec.rb'

# Offense count: 2162
# This cop supports safe autocorrection (--autocorrect).
RSpec/EmptyLineAfterFinalLet:
Expand Down
9 changes: 9 additions & 0 deletions bundler/spec/dependabot/bundler/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("1530024bd6a68d36ac18e04836ce110e0d433c36")
end
Expand All @@ -205,6 +206,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("1530024bd6a68d36ac18e04836ce110e0d433c36")
end
Expand All @@ -228,6 +230,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("997d1a6ee76a1f254fd72ce16acbc8d347fcaee3")
end
Expand All @@ -253,6 +256,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("d31e445215b5af70c1604715d97dd953e868380e")
end
Expand All @@ -278,6 +282,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("d31e445215b5af70c1604715d97dd953e868380e")
end
Expand Down Expand Up @@ -362,6 +367,7 @@
let(:dependency_files) { bundler_project_dependency_files("subdependency") }

its(:length) { is_expected.to eq(2) }

it "is included" do
expect(dependencies.map(&:name)).to include("i18n")
end
Expand All @@ -371,6 +377,7 @@
let(:dependency_files) { bundler_project_dependency_files("platform_windows") }

its(:length) { is_expected.to eq(1) }

it "is not included" do
expect(dependencies.map(&:name)).to_not include("statesman")
end
Expand Down Expand Up @@ -760,6 +767,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("business") }
its(:version) { is_expected.to be_nil }

its(:requirements) do
is_expected.to match_array(expected_requirements)
end
Expand Down Expand Up @@ -821,6 +829,7 @@
let(:dependency_files) { bundler_project_dependency_files("platform_windows_no_lockfile") }

its(:length) { is_expected.to eq(1) }

it "is not included" do
expect(dependencies.map(&:name)).to_not include("statesman")
end
Expand Down
2 changes: 2 additions & 0 deletions common/spec/dependabot/file_fetchers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ def fetch_files
it { is_expected.to be_a(Dependabot::DependencyFile) }
its(:content) { is_expected.to include("octokit") }
its(:type) { is_expected.to include("symlink") }

its(:symlink_target) do
is_expected.to include("symlinked/requirements.txt")
end
Expand Down Expand Up @@ -1470,6 +1471,7 @@ def optional

it { is_expected.to be_a(Dependabot::DependencyFile) }
its(:type) { is_expected.to include("symlink") }

its(:symlink_target) do
is_expected.to include("symlinked/requirements.txt")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
let(:dependency_set) { described_class.new(case_sensitive: true) }

it { is_expected.to be_a(described_class) }

its(:dependencies) do
is_expected.to eq([existing_dependency, dependency])
end
Expand All @@ -111,6 +112,7 @@
end

it { is_expected.to be_a(described_class) }

its(:dependencies) do
is_expected.to match_array([existing_dependency, dependency])
end
Expand Down
2 changes: 2 additions & 0 deletions common/spec/dependabot/git_commit_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,11 @@
let(:upload_pack_fixture) { "business" }

its([:tag]) { is_expected.to eq("v1.13.0") }

its([:commit_sha]) do
is_expected.to eq("7bb4e41ce5164074a0920d5b5770d196b4d90104")
end

its([:tag_sha]) do
is_expected.to eq("37f41032a0f191507903ebbae8a5c0cb945d7585")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3460,6 +3460,7 @@ def commits_details(base:, head:)
it "returns a Message" do
expect(message).to be_a(Dependabot::PullRequestCreator::Message)
end

its(:pr_name) { is_expected.to eq(pr_name) }
its(:pr_message) { is_expected.to eq(pr_message) }
its(:commit_message) { is_expected.to eq(commit_message) }
Expand Down
11 changes: 11 additions & 0 deletions composer/spec/dependabot/composer/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to eq("1.0.2") }

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -68,6 +69,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to eq("1.0.2") }

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -96,9 +98,11 @@
subject { dependencies.first }

it { is_expected.to be_a(Dependabot::Dependency) }

its(:name) do
is_expected.to eq("wpackagist-plugin/ga-google-analytics")
end

its(:version) { is_expected.to eq("20180828") }
end
end
Expand All @@ -116,6 +120,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to eq("1.0.1") }

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -196,9 +201,11 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }

its(:version) do
is_expected.to eq("5267b03b1e4861c4657ede17a88f13ef479db482")
end

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -276,6 +283,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("path_dep/path_dep") }
its(:version) { is_expected.to eq("1.0.1") }

its(:requirements) do
is_expected.to eq(
[{
Expand All @@ -300,6 +308,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to be_nil }

its(:requirements) do
is_expected.to eq(
[{
Expand All @@ -325,6 +334,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to be_nil }

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -356,6 +366,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to be_nil }

its(:requirements) do
is_expected.to eq(
[{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
end

it { is_expected.to eq(Gem::Version.new("2.2.0")) }

it "doesn't hit the main registry (since requested not to)" do
finder.latest_version
expect(WebMock).to_not have_requested(:get, packagist_url)
Expand Down
9 changes: 9 additions & 0 deletions docker/spec/dependabot/docker/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,12 @@
is_expected.to include "FROM python:3.10.6@sha256:8d1f943ceaaf3b3ce05df5c0926e7958836b048b" \
"700176bf9c56d8f37ac13fca AS base\n"
end

its(:content) do
is_expected.to include "FROM python:3.10.6-slim@sha256:c8ef926b002a8371fff6b4f40142dcc6d6f" \
"7e217f7afce2c2d1ed2e6c28e2b7c AS production\n"
end

its(:content) { is_expected.to include "ENV PIP_NO_CACHE_DIR=off \\\n" }
end
end
Expand Down Expand Up @@ -357,6 +359,7 @@
is_expected
.to include("FROM registry-host.io:5000/myreg/ubuntu:17.10\n")
end

its(:content) { is_expected.to include "RUN apt-get update" }
end
end
Expand Down Expand Up @@ -395,6 +398,7 @@
is_expected
.to include("FROM docker.io/myreg/ubuntu:17.10\n")
end

its(:content) { is_expected.to include "RUN apt-get update" }
end
end
Expand Down Expand Up @@ -524,6 +528,7 @@
is_expected.to include("FROM registry-host.io:5000/" \
"myreg/ubuntu@sha256:3ea1ca1aa")
end

its(:content) { is_expected.to include "RUN apt-get update" }
end
end
Expand Down Expand Up @@ -675,6 +680,7 @@
is_expected.to include "FROM --platform=$BUILDPLATFORM " \
"node:10.9-alpine AS"
end

its(:content) { is_expected.to include "FROM node:10.9-alpine\n" }
its(:content) { is_expected.to include "RUN apk add" }
end
Expand Down Expand Up @@ -912,6 +918,7 @@
is_expected
.to include(" image: registry-host.io:5000/myreg/ubuntu:17.10\n")
end

its(:content) { is_expected.to include "kind: Pod" }
end
end
Expand Down Expand Up @@ -962,6 +969,7 @@
is_expected
.to include(" image: docker.io/myreg/ubuntu:17.10\n")
end

its(:content) { is_expected.to include "kind: Pod" }
end
end
Expand Down Expand Up @@ -1110,6 +1118,7 @@
is_expected.to include("image: registry-host.io:5000/" \
"myreg/ubuntu@sha256:3ea1ca1aa")
end

its(:content) { is_expected.to include "kind: Pod" }
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@
expect(subject.content).to include "#{dependency.name}@#{dependency.requirements.first.dig(:source, :ref)}"
expect(subject.content).not_to match(/#{old_sha}['"]?\s+#.*#{dependency.previous_version}/)
end

it "updates version comment" do
new_sha = dependency.requirements.first.dig(:source, :ref)
expect(subject.content).not_to match(/@#{new_sha}['"]?\s+#.*#{dependency.previous_version}\s*$/)
Expand All @@ -386,6 +387,7 @@
expect(subject.content).to include "# pin @v#{dependency.version}"
expect(subject.content).to include "# tag=v#{dependency.version}"
end

context "when previous version is older than comment" do
let(:previous_version) { "2.0.0" }

Expand All @@ -401,6 +403,7 @@
old_version = dependency.previous_requirements[1].dig(:source, :ref)
expect(subject.content).not_to match(/@#{old_version}\s+#.*#{dependency.version}/)
end

it "doesn't update version comments in the middle of sentences" do
# rubocop:disable Layout/LineLength
expect(subject.content).to include "Versions older than v#{dependency.previous_version} have a security vulnerability"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
it "updated the dependency" do
is_expected.to include(%(rsc.io/quote v1.5.2\n))
end

it "retained the previous change" do
is_expected.to include(%(rsc.io/qr v0.1.1\n))
end
Expand Down
Loading