Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
brrygrdn committed Jul 31, 2023
1 parent 7f4b158 commit ddc5951
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion common/lib/dependabot/config/ignore_condition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class IgnoreCondition
PATCH_VERSION_TYPE = "version-update:semver-patch",
MINOR_VERSION_TYPE = "version-update:semver-minor",
MAJOR_VERSION_TYPE = "version-update:semver-major"
]
].freeze

ALL_VERSIONS = ">= 0"

Expand Down
26 changes: 15 additions & 11 deletions common/lib/dependabot/dependency_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,20 @@ def highest_semver_allowed
def generate_ignore_condition!
return NullIgnoreCondition.new unless experimental_rules_enabled?

ignored_update_types = case highest_semver_allowed
ignored_update_types = ignored_update_types_for_rules

return NullIgnoreCondition.new unless ignored_update_types.any?

Dependabot.logger.debug("The #{name} group has set ignores for update-type(s): #{ignored_update_types}")

Dependabot::Config::IgnoreCondition.new(
dependency_name: ANY_DEPENDENCY_NAME,
update_types: ignored_update_types
)
end

def ignored_update_types_for_rules
case highest_semver_allowed
when SEMVER_MAJOR
[]
when SEMVER_MINOR
Expand All @@ -111,17 +124,8 @@ def generate_ignore_condition!
]
else
raise ArgumentError,
"The #{name} group has an unexpected value for highest-semver-allowed: #{rules["highest-semver-allowed"]}"
"The #{name} group has an unexpected value for highest-semver-allowed: #{rules['highest-semver-allowed']}"
end

return NullIgnoreCondition.new unless ignored_update_types.any?

Dependabot.logger.debug("The #{name} group has set ignores for update-type(s): #{ignored_update_types}")

Dependabot::Config::IgnoreCondition.new(
dependency_name: ANY_DEPENDENCY_NAME,
update_types: ignored_update_types
)
end

def experimental_rules_enabled?
Expand Down
22 changes: 11 additions & 11 deletions updater/spec/dependabot/dependency_group_engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
{
"name" => "group",
"rules" => {
"patterns" => ["dummy-pkg-*"],
"patterns" => ["dummy-pkg-*"]
}
}
]
Expand Down Expand Up @@ -315,20 +315,20 @@
{
"name" => "major",
"rules" => {
"patterns" => [
"dummy-pkg-a",
"dummy-pkg-b"
],
"patterns" => %w(
dummy-pkg-a
dummy-pkg-b
),
"highest-semver-allowed" => "major"
}
},
{
"name" => "patch",
"rules" => {
"patterns" => [
"dummy-pkg-b",
"dummy-pkg-c"
],
"patterns" => %w(
dummy-pkg-b
dummy-pkg-c
),
"highest-semver-allowed" => "patch"
}
}
Expand All @@ -337,7 +337,7 @@

it "does not attempt individual updates on dependencies upgraded to major in at least one group" do
expect(dependency_group_engine.ungrouped_dependencies.map(&:name)).
to match_array(["dummy-pkg-c", "ungrouped_pkg"])
to match_array(%w(dummy-pkg-c ungrouped_pkg))
end
end
end
Expand All @@ -350,7 +350,7 @@
{
"name" => "group",
"rules" => {
"patterns" => ["dummy-pkg-*"],
"patterns" => ["dummy-pkg-*"]
}
}
]
Expand Down

0 comments on commit ddc5951

Please sign in to comment.