diff options
author | Tim Smith <tsmith84@gmail.com> | 2021-04-01 11:29:38 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2021-04-01 11:29:38 -0700 |
commit | af0f5e3b2d527de1abd3d6db69a12678ad338f98 (patch) | |
tree | 1173f25e4a7c8e876e1b8faace7895d2dfd13aa0 /lib/chef/formatters | |
parent | 5c7afb6fc445241c3dcd5767a90215b6a74deda9 (diff) | |
download | chef-af0f5e3b2d527de1abd3d6db69a12678ad338f98.tar.gz |
Resolve our chefstyle warningsredundant_begins
Now that knife has been moved we can resolve the current warnings
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/formatters')
-rw-r--r-- | lib/chef/formatters/error_inspectors/resource_failure_inspector.rb | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb index 8ddae24e6d..4010bd72d5 100644 --- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb @@ -64,36 +64,34 @@ class Chef def recipe_snippet return nil if dynamic_resource? - @snippet ||= begin - if (file = parse_source) && (line = parse_line(file)) - return nil unless ::File.exist?(file) + @snippet ||= if (file = parse_source) && (line = parse_line(file)) + return nil unless ::File.exist?(file) - lines = IO.readlines(file) + lines = IO.readlines(file) - relevant_lines = ["# In #{file}\n\n"] + relevant_lines = ["# In #{file}\n\n"] - current_line = line - 1 - current_line = 0 if current_line < 0 - nesting = 0 + current_line = line - 1 + current_line = 0 if current_line < 0 + nesting = 0 - loop do + loop do - # low rent parser. try to gracefully handle nested blocks in resources - nesting += 1 if /\s+do\s*/.match?(lines[current_line]) - nesting -= 1 if /end\s*$/.match?(lines[current_line]) + # low rent parser. try to gracefully handle nested blocks in resources + nesting += 1 if /\s+do\s*/.match?(lines[current_line]) + nesting -= 1 if /end\s*$/.match?(lines[current_line]) - relevant_lines << format_line(current_line, lines[current_line]) + relevant_lines << format_line(current_line, lines[current_line]) - break if lines[current_line + 1].nil? - break if current_line >= (line + 50) - break if nesting <= 0 + break if lines[current_line + 1].nil? + break if current_line >= (line + 50) + break if nesting <= 0 - current_line += 1 - end - relevant_lines << format_line(current_line + 1, lines[current_line + 1]) if lines[current_line + 1] - relevant_lines.join("") - end - end + current_line += 1 + end + relevant_lines << format_line(current_line + 1, lines[current_line + 1]) if lines[current_line + 1] + relevant_lines.join("") + end end def dynamic_resource? |