Class: RuboCop::Cop::Chromebrew::CompatibilityAll
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Chromebrew::CompatibilityAll
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/chromebrew/compatibility_all.rb
Overview
Compatibility value which match all architectures should be replaced with ‘all’.
Constant Summary collapse
- MSG =
"Compatibility properties which match all architectures should be replaced with 'all'"
Instance Method Summary collapse
Instance Method Details
#compatibility?(node) ⇒ Object
19 20 21 22 |
# File 'lib/rubocop/cop/chromebrew/compatibility_all.rb', line 19 def_node_matcher :compatibility?, <<~PATTERN (send nil? :compatibility (str $_)) PATTERN |
#on_send(node) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubocop/cop/chromebrew/compatibility_all.rb', line 24 def on_send(node) # Check that we're operating on the compatibility property. value = compatibility?(node) return unless value architectures = %w[aarch64 armv7l i686 x86_64] # Check if the compatibility value includes all four architectures. return unless architectures.all? { |arch| value.include?(arch) } # If requested, replace the offending compatibility value with 'all'. add_offense(node.children.last) do |corrector| corrector.replace(node.children.last, "'all'") end end |