Skip to content

Commit b028af7

Browse files
authored
Merge pull request #54 from puppetlabs/maint-rubocop_updates
(MAINT) Rubocop updates
2 parents 5c8d18c + dfa3b47 commit b028af7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1436
-1399
lines changed

lib/puppet-lint.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# rubocop:disable Naming/FileName
2+
13
# encoding: utf-8
24

35
require 'set'
@@ -12,6 +14,7 @@
1214
require 'puppet-lint/monkeypatches'
1315

1416
class PuppetLint::NoCodeError < StandardError; end
17+
1518
class PuppetLint::NoFix < StandardError; end
1619

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

2124
def initialize(token)
2225
@token = token
26+
super
2327
end
2428
end
2529

@@ -59,7 +63,7 @@ class PuppetLint
5963
# Public: Initialise a new PuppetLint object.
6064
def initialize
6165
@code = nil
62-
@statistics = { :error => 0, :warning => 0, :fixed => 0, :ignored => 0 }
66+
@statistics = { error: 0, warning: 0, fixed: 0, ignored: 0 }
6367
@manifest = ''
6468
end
6569

lib/puppet-lint/bin.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ def run
104104
puts JSON.pretty_generate(all_problems)
105105
end
106106

107-
return return_val
107+
return_val
108108
rescue PuppetLint::NoCodeError
109109
puts 'puppet-lint: no file specified or specified file does not exist'
110110
puts "puppet-lint: try 'puppet-lint --help' for more information"
111-
return 1
111+
1
112112
end
113113
end
114114

@@ -133,7 +133,7 @@ def report_sarif(problems, base_path, base_path_uri)
133133
new_rule = { 'id' => message[:check] }
134134
new_rule['fullDescription'] = { 'text' => message[:description] } unless message[:description].nil?
135135
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
136-
new_rule['defaultConfiguration'] = { 'level' => message[:KIND].downcase } if %w[error warning].include?(message[:KIND].downcase)
136+
new_rule['defaultConfiguration'] = { 'level' => message[:KIND].downcase } if ['error', 'warning'].include?(message[:KIND].downcase)
137137
new_rule['helpUri'] = message[:help_uri] unless message[:help_uri].nil?
138138
rules << new_rule
139139
end
@@ -142,7 +142,8 @@ def report_sarif(problems, base_path, base_path_uri)
142142
'ruleId' => message[:check],
143143
'ruleIndex' => rule_index,
144144
'message' => { 'text' => message[:message] },
145-
'locations' => [{ 'physicalLocation' => { 'artifactLocation' => { 'uri' => relative_path, 'uriBaseId' => 'ROOTPATH' }, 'region' => { 'startLine' => message[:line], 'startColumn' => message[:column] } } }],
145+
'locations' => [{ 'physicalLocation' => { 'artifactLocation' => { 'uri' => relative_path, 'uriBaseId' => 'ROOTPATH' },
146+
'region' => { 'startLine' => message[:line], 'startColumn' => message[:column] } } }],
146147
}
147148
results << result
148149
end

lib/puppet-lint/checkplugin.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def fix_problems
4141
begin
4242
fix(problem)
4343
problem[:kind] = :fixed
44-
rescue PuppetLint::NoFix # rubocop:disable Lint/HandleExceptions
44+
rescue PuppetLint::NoFix
4545
# noop
4646
end
4747
end
@@ -179,10 +179,10 @@ def manifest_lines
179179
# Returns a Hash of default problem information.
180180
def default_info
181181
@default_info ||= {
182-
:check => self.class.const_get('NAME'),
183-
:fullpath => fullpath,
184-
:path => path,
185-
:filename => filename,
182+
check: self.class.const_get('NAME'),
183+
fullpath: fullpath,
184+
path: path,
185+
filename: filename,
186186
}
187187
end
188188

lib/puppet-lint/checks.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ def load_data(path, content)
3232
end
3333

3434
problems << {
35-
:kind => :error,
36-
:check => :syntax,
37-
:message => message,
38-
:line => e.line_no,
39-
:column => e.column,
40-
:fullpath => PuppetLint::Data.fullpath,
41-
:path => PuppetLint::Data.path,
42-
:filename => PuppetLint::Data.filename,
35+
kind: :error,
36+
check: :syntax,
37+
message: message,
38+
line: e.line_no,
39+
column: e.column,
40+
fullpath: PuppetLint::Data.fullpath,
41+
path: PuppetLint::Data.path,
42+
filename: PuppetLint::Data.filename,
4343
}
4444
PuppetLint::Data.tokens = []
4545
end
@@ -73,14 +73,14 @@ def run(fileinfo, data)
7373
@problems
7474
rescue PuppetLint::SyntaxError => e
7575
@problems << {
76-
:kind => :error,
77-
:check => :syntax,
78-
:message => 'Syntax error',
79-
:fullpath => File.expand_path(fileinfo, ENV['PWD']),
80-
:filename => File.basename(fileinfo),
81-
:path => fileinfo,
82-
:line => e.token.line,
83-
:column => e.token.column,
76+
kind: :error,
77+
check: :syntax,
78+
message: 'Syntax error',
79+
fullpath: File.expand_path(fileinfo, ENV['PWD']),
80+
filename: File.basename(fileinfo),
81+
path: fileinfo,
82+
line: e.token.line,
83+
column: e.token.column,
8484
}
8585

8686
@problems

0 commit comments

Comments
 (0)