mirror of
https://github.com/inspec/inspec
synced 2025-02-16 22:18:38 +00:00
Merge pull request #5724 from inspec/cw/disable-cookstyle-on-windows
Disable CookStyle integration on Windows
This commit is contained in:
commit
baa6331203
4 changed files with 21 additions and 3 deletions
|
@ -122,8 +122,13 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
end
|
||||
puts
|
||||
|
||||
enable_offenses = !Inspec.locally_windows? # See 5723
|
||||
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
|
||||
item_msg = lambda { |item|
|
||||
pos = [item[:file], item[:line], item[:column]].compact.join(":")
|
||||
|
@ -135,7 +140,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
|
||||
puts
|
||||
|
||||
unless result[:offenses].empty?
|
||||
if enable_offenses && !result[:offenses].empty?
|
||||
puts "Offenses:\n"
|
||||
result[:offenses].each { |item| ui.cyan(" #{Inspec::UI::GLYPHS[:script_x]} #{item_msg.call(item)}\n\n") }
|
||||
end
|
||||
|
@ -143,7 +148,11 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
offenses = ui.cyan("#{result[:offenses].length} offenses", print: false)
|
||||
errors = ui.red("#{result[:errors].length} errors", 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
|
||||
|
||||
|
|
|
@ -18,4 +18,9 @@ module Inspec
|
|||
require "etc" unless defined?(Etc)
|
||||
Etc.getpwuid.dir
|
||||
end
|
||||
|
||||
def self.locally_windows?
|
||||
require "rbconfig" unless defined?(RbConfig)
|
||||
RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
|
||||
end
|
||||
end
|
||||
|
|
|
@ -450,6 +450,8 @@ module Inspec
|
|||
|
||||
def cookstyle_linting_check
|
||||
msgs = []
|
||||
return msgs if Inspec.locally_windows? # See #5723
|
||||
|
||||
output = cookstyle_rake_output.split("Offenses:").last
|
||||
msgs = output.split("\n").select { |x| x =~ /[A-Z]:/ } unless output.nil?
|
||||
msgs
|
||||
|
|
|
@ -120,12 +120,14 @@ describe "inspec check" do
|
|||
|
||||
describe "inspec check also check for cookstyle offenses" do
|
||||
it "finds no offenses in a complete profile" do
|
||||
skip if windows? # see #5723
|
||||
out = inspec("check #{profile_path}/complete-profile")
|
||||
_(out.stdout).must_match(/No errors, warnings, or offenses/)
|
||||
assert_exit_code 0, out
|
||||
end
|
||||
|
||||
it "fails and returns offenses in a profile" do
|
||||
skip if windows? # see #5723
|
||||
out = inspec("check #{profile_path}/inputs/metadata-basic")
|
||||
_(out.stdout).must_match(/1 offenses/)
|
||||
assert_exit_code 1, out
|
||||
|
|
Loading…
Add table
Reference in a new issue