Skip to content

Commit e8ed038

Browse files
Copilotpavera
andcommitted
Fix lint errors and update yarn_lockfile_updater test
- Remove unnecessary rubocop:disable/enable Metrics/PerceivedComplexity - Convert if block to modifier style per Style/IfUnlessModifier - Update yarn_lockfile_updater_spec to expect MisconfiguredTooling (with the FF removed, single-dep scenarios no longer raise "Expected content to change!" — the yarn updater now correctly detects the misconfigured .yarnrc.yml) Co-authored-by: pavera <660677+pavera@users.noreply.github.com>
1 parent 2f4a74f commit e8ed038

3 files changed

Lines changed: 3 additions & 13 deletions

File tree

bun/lib/dependabot/bun/file_updater/package_json_updater.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ def updated_package_json
4141
sig { returns(T::Array[Dependabot::Dependency]) }
4242
attr_reader :dependencies
4343

44-
# rubocop:disable Metrics/PerceivedComplexity
45-
4644
sig { returns(T.nilable(String)) }
4745
def updated_package_json_content
4846
# checks if we are updating single dependency in package.json
@@ -65,9 +63,7 @@ def updated_package_json_content
6563
# The other dependency is not present in package.json so we don't have to update it — this is
6664
# most likely a transitive dependency which only needs an update in the lockfile. We avoid
6765
# throwing an exception and let the update continue.
68-
if content == new_content && unique_deps_count > 1
69-
raise "Expected content to change!"
70-
end
66+
raise "Expected content to change!" if content == new_content && unique_deps_count > 1
7167

7268
content = new_content
7369
end
@@ -86,7 +82,6 @@ def updated_package_json_content
8682
content
8783
end
8884
end
89-
# rubocop:enable Metrics/PerceivedComplexity
9085
sig do
9186
params(
9287
dependency: Dependabot::Dependency,

npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/package_json_updater.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ def updated_package_json
4141
sig { returns(T::Array[Dependabot::Dependency]) }
4242
attr_reader :dependencies
4343

44-
# rubocop:disable Metrics/PerceivedComplexity
45-
4644
sig { returns(T.nilable(String)) }
4745
def updated_package_json_content
4846
# checks if we are updating single dependency in package.json
@@ -65,9 +63,7 @@ def updated_package_json_content
6563
# The other dependency is not present in package.json so we don't have to update it — this is
6664
# most likely a transitive dependency which only needs an update in the lockfile. We avoid
6765
# throwing an exception and let the update continue.
68-
if content == new_content && unique_deps_count > 1
69-
raise "Expected content to change!"
70-
end
66+
raise "Expected content to change!" if content == new_content && unique_deps_count > 1
7167

7268
content = new_content
7369
end
@@ -86,7 +82,6 @@ def updated_package_json_content
8682
content
8783
end
8884
end
89-
# rubocop:enable Metrics/PerceivedComplexity
9085
sig do
9186
params(
9287
dependency: Dependabot::Dependency,

npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142

143143
it "raises a helpful error" do
144144
expect { updated_yarn_lock_content }
145-
.to raise_error("Expected content to change!")
145+
.to raise_error(Dependabot::MisconfiguredTooling)
146146
end
147147
end
148148

0 commit comments

Comments
 (0)