mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
Use only inspec cops of cookstyle gem
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
parent
bedde88849
commit
ab1d423a35
3 changed files with 9 additions and 4 deletions
1
Gemfile
1
Gemfile
|
@ -20,6 +20,7 @@ end
|
|||
# but our runtime dep is still 3.9+
|
||||
gem "rspec", ">= 3.10"
|
||||
|
||||
# checks code offenses with inspec check
|
||||
gem "cookstyle"
|
||||
|
||||
group :omnibus do
|
||||
|
|
|
@ -389,7 +389,7 @@ module Inspec
|
|||
def cookstyle_linting_check
|
||||
msgs = []
|
||||
output = cookstyle_rake_output.split("Offenses:").last
|
||||
msgs = output.split("\n").select { |x| (x.include? "R:") || (x.include? "C:") } unless output.nil?
|
||||
msgs = output.split("\n").select { |x| x =~ /[A-Z]:/ } unless output.nil?
|
||||
msgs
|
||||
end
|
||||
|
||||
|
@ -399,7 +399,11 @@ module Inspec
|
|||
require "rubocop/rake_task"
|
||||
begin
|
||||
RuboCop::RakeTask.new(:cookstyle_lint) do |spec|
|
||||
spec.options += ["--display-cop-names", "--parallel"]
|
||||
spec.options += [
|
||||
"--display-cop-names",
|
||||
"--parallel",
|
||||
"--only=InSpec/Deprecations,InSpec/Deprecations/AttributeHelper,InSpec/Deprecations/AttributeDefault",
|
||||
]
|
||||
spec.patterns += Dir.glob("#{@target}/**/*").reject { |f| File.directory?(f) || (f.include? "inspec.lock") }
|
||||
spec.fail_on_error = false
|
||||
end
|
||||
|
|
|
@ -126,8 +126,8 @@ describe "inspec check" do
|
|||
end
|
||||
|
||||
it "fails and returns offenses in a profile" do
|
||||
out = inspec("check #{profile_path}/control-tags")
|
||||
_(out.stdout).must_match(/29 offenses/)
|
||||
out = inspec("check #{profile_path}/inputs/metadata-basic")
|
||||
_(out.stdout).must_match(/1 offenses/)
|
||||
assert_exit_code 1, out
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue