Skip to content

Commit

Permalink
Merge pull request #876 from chef/prevent_failure
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Smith <tsmith@chef.io>
  • Loading branch information
tas50 authored Jul 30, 2021
2 parents b80c157 + b09f14b commit adbd707
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class ResourceWithoutUnifiedTrue < Base
def_node_search :provides, '(send nil? :provides ...)'

def on_new_investigation
# gracefully fail if the resource is empty
return if processed_source.ast.nil?

# Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
return if unified_mode?(processed_source.ast)
range = source_range(processed_source.buffer, 1, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
RUBY
end

it "doesn't register an offense when the custom resource file is empty" do
expect_no_offenses('')
end

context 'with TargetChefVersion set before 15.3' do
let(:config) { target_chef_version(15.2) }

Expand Down

0 comments on commit adbd707

Please sign in to comment.