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 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 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