59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/rubocop/cop/chef/style/use_platform_helpers.rb', line 59
def on_send(node)
platform_equals?(node) do |type, operator, plat|
add_offense(node, severity: :refactor) do |corrector|
corrected_string = (operator == :!= ? '!' : '') + "#{type.value}?('#{plat.value}')"
corrector.replace(node, corrected_string)
end
end
platform_include?(node) do |plats, type|
add_offense(node, severity: :refactor) do |corrector|
platforms = plats.values.map { |x| x.str_type? ? "'#{x.value}'" : x.source }
corrected_string = "#{type.value}?(#{platforms.join(', ')})"
corrector.replace(node, corrected_string)
end
end
platform_eql?(node) do |type, plat|
add_offense(node, severity: :refactor) do |corrector|
corrected_string = "#{type.value}?('#{plat.value}')"
corrector.replace(node, corrected_string)
end
end
end
|