From ba798db1ab954ccadc3a72d0caf80db76acc2cba Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Sun, 5 Apr 2026 10:48:34 -0400 Subject: [PATCH 1/3] Exclude extensions from Style/OneClassPerFile This commit excludes files that modify classes from other Libraries from the Style/OneClassPerFile Rubocop check as the use of multiple class entries is intentional. Signed-off-by: Charlie Sharpsteen --- .rubocop.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index d8027ad5..5d58596a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -666,6 +666,13 @@ Style/NumericLiterals: Style/ObjectThen: Enabled: true +# Extensions to other Ruby libraries purposefully declare +# multiple classes. +Style/OneClassPerFile: + Exclude: + - lib/git/* + - lib/vanagon/extensions/**/* + Style/OneLineConditional: Enabled: true From 4e9267eb4f28388056aa37ce02cb8faf9e452285 Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Sun, 5 Apr 2026 10:54:36 -0400 Subject: [PATCH 2/3] Lint: remove redundant map(&:to_s) before join This commit updates `rules.rb` to satisfy Rubocop Style/MapJoin by removing explicit stringification before calling `.join`. The call to `.map(&:to_s)` is redundant as the documented behavior of `Array#join` is: > - Uses `element.to_s` if element is not a `kind_of?(Array)` > https://docs.ruby-lang.org/en/3.2/Array.html#method-i-join Signed-off-by: Charlie Sharpsteen --- lib/vanagon/component/rules.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vanagon/component/rules.rb b/lib/vanagon/component/rules.rb index 68684bf2..0aa6d97f 100644 --- a/lib/vanagon/component/rules.rb +++ b/lib/vanagon/component/rules.rb @@ -225,7 +225,7 @@ def component_rule # Generate a Makefile fragment that contains all of the rules for the component. # @return [String] def format - rules.map(&:to_s).join("\n") + rules.join("\n") end alias to_s format From ab6d8e982c47a09922cc4e03d30dcc1322c5e73a Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Sun, 5 Apr 2026 11:01:44 -0400 Subject: [PATCH 3/3] Lint: Use to_h { ... } instead of each_with_object This commit updates the `hashable` extension to satisfy the Rubocop Style/ReduceToHash check. Signed-off-by: Charlie Sharpsteen --- lib/vanagon/extensions/hashable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vanagon/extensions/hashable.rb b/lib/vanagon/extensions/hashable.rb index e59a1694..a544880f 100644 --- a/lib/vanagon/extensions/hashable.rb +++ b/lib/vanagon/extensions/hashable.rb @@ -7,8 +7,8 @@ module HashableAttributes # @return [Hash] Converts an object to a hash with keys representing # each attribute (as symbols) and their corresponding values def to_hash - instance_variables.each_with_object({}) do |var, hash| - hash[var.to_s.delete("@")] = instance_variable_get(var) + instance_variables.to_h do |var| + [var.to_s.delete("@"), instance_variable_get(var)] end end alias_method :to_h, :to_hash