Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/puppet-lint/checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,20 @@ def load_data(path, content)
#
# Returns an Array of problem Hashes.
def run(fileinfo, data)
load_data(fileinfo, data)

checks_run = []
if File.extname(fileinfo).downcase.match?(%r{\.ya?ml$})
PuppetLint::Data.path = fileinfo
PuppetLint::Data.manifest_lines = data.split("\n", -1)

enabled_checks.select { |check| YAML_COMPATIBLE_CHECKS.include?(check) }.each do |check|
klass = PuppetLint.configuration.check_object[check].new
# FIXME: shadowing #problems
problems = klass.run
checks_run << [klass, problems]
end
else
load_data(fileinfo, data)

enabled_checks.each do |check|
klass = PuppetLint.configuration.check_object[check].new
# FIXME: shadowing #problems
Expand Down
7 changes: 7 additions & 0 deletions spec/acceptance/puppet_lint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@
expect(result[:stdout]).to have_warnings(2)
end
end

context 'with a YAML file provided' do
it 'returns zero errors' do
result = puppet_lint([File.join(manifest_root, 'parseable.yaml')])
expect(result[:stdout]).to have_errors(0)
end
end
end
3 changes: 3 additions & 0 deletions spec/fixtures/test/manifests/parseable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
heredoc: |
contains $
5 changes: 0 additions & 5 deletions spec/unit/puppet-lint/checks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,6 @@
allow(File).to receive(:extname).with(fileinfo).and_return('.yaml')
end

it 'loads the yaml data' do
expect(instance).to receive(:load_data).with(fileinfo, data).and_call_original # rubocop: disable RSpec/SubjectStub
instance.run(fileinfo, data)
end

context 'when there are checks enabled' do
let(:enabled_checks) { [:legacy_facts] }
let(:enabled_check_classes) { enabled_checks.map { |r| PuppetLint.configuration.check_object[r] } }
Expand Down