Disable cookstyle integration when local system is Windows

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2021-11-13 01:43:59 -05:00
parent 8aad4abe0c
commit 6ecbc67642
2 changed files with 14 additions and 3 deletions

View file

@ -122,8 +122,13 @@ class Inspec::InspecCLI < Inspec::BaseCLI
end end
puts puts
enable_offenses = !Inspec.locally_windows? # See 5723
if result[:errors].empty? && result[:warnings].empty? && result[:offenses].empty? if result[:errors].empty? && result[:warnings].empty? && result[:offenses].empty?
ui.plain_line("No errors, warnings, or offenses") if enable_offenses
ui.plain_line("No errors, warnings, or offenses")
else
ui.plain_line("No errors or warnings")
end
else else
item_msg = lambda { |item| item_msg = lambda { |item|
pos = [item[:file], item[:line], item[:column]].compact.join(":") pos = [item[:file], item[:line], item[:column]].compact.join(":")
@ -135,7 +140,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
puts puts
unless result[:offenses].empty? if enable_offenses && !result[:offenses].empty?
puts "Offenses:\n" puts "Offenses:\n"
result[:offenses].each { |item| ui.cyan(" #{Inspec::UI::GLYPHS[:script_x]} #{item_msg.call(item)}\n\n") } result[:offenses].each { |item| ui.cyan(" #{Inspec::UI::GLYPHS[:script_x]} #{item_msg.call(item)}\n\n") }
end end
@ -143,7 +148,11 @@ class Inspec::InspecCLI < Inspec::BaseCLI
offenses = ui.cyan("#{result[:offenses].length} offenses", print: false) offenses = ui.cyan("#{result[:offenses].length} offenses", print: false)
errors = ui.red("#{result[:errors].length} errors", print: false) errors = ui.red("#{result[:errors].length} errors", print: false)
warnings = ui.yellow("#{result[:warnings].length} warnings", print: false) warnings = ui.yellow("#{result[:warnings].length} warnings", print: false)
ui.plain_line("Summary: #{errors}, #{warnings}, #{offenses}") if enable_offenses
ui.plain_line("Summary: #{errors}, #{warnings}, #{offenses}")
else
ui.plain_line("Summary: #{errors}, #{warnings}")
end
end end
end end

View file

@ -450,6 +450,8 @@ module Inspec
def cookstyle_linting_check def cookstyle_linting_check
msgs = [] msgs = []
return msgs if Inspec.locally_windows? # See #5723
output = cookstyle_rake_output.split("Offenses:").last output = cookstyle_rake_output.split("Offenses:").last
msgs = output.split("\n").select { |x| x =~ /[A-Z]:/ } unless output.nil? msgs = output.split("\n").select { |x| x =~ /[A-Z]:/ } unless output.nil?
msgs msgs