Skip to content

Commit 327bd50

Browse files
committed
(GH-272) Fail gracefully for Puppet Lint configuration
Previously the Puppet-Lint configuration could raise an error, thereby stopping any puppet lint rules from working. This was due to puppet-lint.rc files containing command params which were invalide due to puppet-lint plugin gems not being loaded e.g. --no-trailing_comma-check This commit changes the document validator to use the default configuration if an error occurs loading the configuration.
1 parent c486ec6 commit 327bd50

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/puppet-languageserver/manifest/validation_provider.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ def self.validate(session_state, content, options = {})
4545
if module_root.nil?
4646
linter_options = PuppetLint::OptParser.build
4747
else
48-
Dir.chdir(module_root.to_s) { linter_options = PuppetLint::OptParser.build }
48+
begin
49+
Dir.chdir(module_root.to_s) { linter_options = PuppetLint::OptParser.build }
50+
rescue OptionParser::InvalidOption => e
51+
PuppetLanguageServer.log_message(:error, "(#{name}) Error reading Puppet Lint configuration. Using default: #{e}")
52+
linter_options = PuppetLint::OptParser.build
53+
end
4954
end
5055
linter_options.parse!([])
5156

0 commit comments

Comments
 (0)