File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -22,4 +22,20 @@ task :console do
2222 IRB . start
2323end
2424
25- task default : %i{ spec }
25+ task default : %i{ style spec }
26+
27+ desc "Check Linting and code style."
28+ task :style do
29+ require "rubocop/rake_task"
30+ require "cookstyle/chefstyle"
31+
32+ if RbConfig ::CONFIG [ "host_os" ] =~ /mswin|mingw|cygwin/
33+ # Windows-specific command, rubocop erroneously reports the CRLF in each file which is removed when your PR is uploaeded to GitHub.
34+ # This is a workaround to ignore the CRLF from the files before running cookstyle.
35+ sh "cookstyle --chefstyle -c .rubocop.yml --except Layout/EndOfLine"
36+ else
37+ sh "cookstyle --chefstyle -c .rubocop.yml"
38+ end
39+ rescue LoadError
40+ puts "Rubocop or Cookstyle gems are not installed. bundle install first to make sure all dependencies are installed."
41+ end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
12#--
23# Author:: Daniel DeLeo (<[email protected] >) 34# Copyright:: Copyright (c) Chef Software Inc.
@@ -239,7 +240,7 @@ def timeout
239240 def format_for_exception
240241 return "Command execution failed. STDOUT/STDERR suppressed for sensitive resource" if sensitive
241242
242- msg = ""
243+ msg = String . new
243244 msg << "#{ @terminate_reason } \n " if @terminate_reason
244245 msg << "---- Begin output of #{ command } ----\n "
245246 msg << "STDOUT: #{ stdout . strip } \n "
@@ -269,7 +270,9 @@ def exitstatus
269270 # within +timeout+ seconds (default: 600s)
270271 def run_command
271272 if logger
272- log_message = ( log_tag . nil? ? "" : "#{ @log_tag } " ) << "sh(#{ @command } )"
273+ prefix = log_tag . nil? ? "" : "#{ @log_tag } "
274+ log_message = prefix + "sh(#{ @command } )"
275+ # log_message = (log_tag.nil? ? "" : "#{@log_tag} ") << "sh(#{@command})"
273276 logger . send ( log_level , log_message )
274277 end
275278 super
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
12#
23# Author:: Daniel DeLeo (<[email protected] >) 34# Copyright:: Copyright (c) Chef Software Inc.
You can’t perform that action at this time.
0 commit comments