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
6 changes: 5 additions & 1 deletion lib/puppet-lint.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# rubocop:disable Naming/FileName

# encoding: utf-8

require 'set'
Expand All @@ -12,6 +14,7 @@
require 'puppet-lint/monkeypatches'

class PuppetLint::NoCodeError < StandardError; end

class PuppetLint::NoFix < StandardError; end

# Parser Syntax Errors
Expand All @@ -20,6 +23,7 @@ class PuppetLint::SyntaxError < StandardError

def initialize(token)
@token = token
super
end
end

Expand Down Expand Up @@ -59,7 +63,7 @@ class PuppetLint
# Public: Initialise a new PuppetLint object.
def initialize
@code = nil
@statistics = { :error => 0, :warning => 0, :fixed => 0, :ignored => 0 }
@statistics = { error: 0, warning: 0, fixed: 0, ignored: 0 }
@manifest = ''
end

Expand Down
9 changes: 5 additions & 4 deletions lib/puppet-lint/bin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ def run
puts JSON.pretty_generate(all_problems)
end

return return_val
return_val
rescue PuppetLint::NoCodeError
puts 'puppet-lint: no file specified or specified file does not exist'
puts "puppet-lint: try 'puppet-lint --help' for more information"
return 1
1
end
end

Expand All @@ -133,7 +133,7 @@ def report_sarif(problems, base_path, base_path_uri)
new_rule = { 'id' => message[:check] }
new_rule['fullDescription'] = { 'text' => message[:description] } unless message[:description].nil?
new_rule['fullDescription'] = { 'text' => 'Check for any syntax error and record an error of each instance found.' } if new_rule['fullDescription'].nil? && message[:check] == :syntax
new_rule['defaultConfiguration'] = { 'level' => message[:KIND].downcase } if %w[error warning].include?(message[:KIND].downcase)
new_rule['defaultConfiguration'] = { 'level' => message[:KIND].downcase } if ['error', 'warning'].include?(message[:KIND].downcase)
new_rule['helpUri'] = message[:help_uri] unless message[:help_uri].nil?
rules << new_rule
end
Expand All @@ -142,7 +142,8 @@ def report_sarif(problems, base_path, base_path_uri)
'ruleId' => message[:check],
'ruleIndex' => rule_index,
'message' => { 'text' => message[:message] },
'locations' => [{ 'physicalLocation' => { 'artifactLocation' => { 'uri' => relative_path, 'uriBaseId' => 'ROOTPATH' }, 'region' => { 'startLine' => message[:line], 'startColumn' => message[:column] } } }],
'locations' => [{ 'physicalLocation' => { 'artifactLocation' => { 'uri' => relative_path, 'uriBaseId' => 'ROOTPATH' },
'region' => { 'startLine' => message[:line], 'startColumn' => message[:column] } } }],
}
results << result
end
Expand Down
10 changes: 5 additions & 5 deletions lib/puppet-lint/checkplugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fix_problems
begin
fix(problem)
problem[:kind] = :fixed
rescue PuppetLint::NoFix # rubocop:disable Lint/HandleExceptions
rescue PuppetLint::NoFix
# noop
end
end
Expand Down Expand Up @@ -179,10 +179,10 @@ def manifest_lines
# Returns a Hash of default problem information.
def default_info
@default_info ||= {
:check => self.class.const_get('NAME'),
:fullpath => fullpath,
:path => path,
:filename => filename,
check: self.class.const_get('NAME'),
fullpath: fullpath,
path: path,
filename: filename,
}
end

Expand Down
32 changes: 16 additions & 16 deletions lib/puppet-lint/checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def load_data(path, content)
end

problems << {
:kind => :error,
:check => :syntax,
:message => message,
:line => e.line_no,
:column => e.column,
:fullpath => PuppetLint::Data.fullpath,
:path => PuppetLint::Data.path,
:filename => PuppetLint::Data.filename,
kind: :error,
check: :syntax,
message: message,
line: e.line_no,
column: e.column,
fullpath: PuppetLint::Data.fullpath,
path: PuppetLint::Data.path,
filename: PuppetLint::Data.filename,
}
PuppetLint::Data.tokens = []
end
Expand Down Expand Up @@ -73,14 +73,14 @@ def run(fileinfo, data)
@problems
rescue PuppetLint::SyntaxError => e
@problems << {
:kind => :error,
:check => :syntax,
:message => 'Syntax error',
:fullpath => File.expand_path(fileinfo, ENV['PWD']),
:filename => File.basename(fileinfo),
:path => fileinfo,
:line => e.token.line,
:column => e.token.column,
kind: :error,
check: :syntax,
message: 'Syntax error',
fullpath: File.expand_path(fileinfo, ENV['PWD']),
filename: File.basename(fileinfo),
path: fileinfo,
line: e.token.line,
column: e.token.column,
}

@problems
Expand Down
Loading