puppet-lint 2.3.3 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +35 -0
- data/README.md +6 -2
- data/Rakefile +10 -1
- data/lib/puppet-lint.rb +10 -1
- data/lib/puppet-lint/bin.rb +9 -2
- data/lib/puppet-lint/checks.rb +13 -0
- data/lib/puppet-lint/data.rb +2 -0
- data/lib/puppet-lint/lexer.rb +14 -12
- data/lib/puppet-lint/optparser.rb +24 -5
- data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +1 -1
- data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +1 -1
- data/lib/puppet-lint/plugins/check_classes/inherits_across_namespaces.rb +1 -1
- data/lib/puppet-lint/plugins/check_classes/names_containing_uppercase.rb +1 -1
- data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +1 -1
- data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +1 -1
- data/lib/puppet-lint/plugins/check_classes/right_to_left_relationship.rb +1 -1
- data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +1 -1
- data/lib/puppet-lint/plugins/check_comments/slash_comments.rb +1 -1
- data/lib/puppet-lint/plugins/check_comments/star_comments.rb +1 -1
- data/lib/puppet-lint/plugins/check_conditionals/case_without_default.rb +1 -1
- data/lib/puppet-lint/plugins/check_conditionals/selector_inside_resource.rb +1 -1
- data/lib/puppet-lint/plugins/check_documentation/documentation.rb +1 -1
- data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +1 -1
- data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +1 -1
- data/lib/puppet-lint/plugins/check_resources/file_mode.rb +1 -1
- data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +1 -1
- data/lib/puppet-lint/plugins/check_resources/unquoted_resource_title.rb +1 -1
- data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +1 -1
- data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +1 -1
- data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +1 -1
- data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +1 -1
- data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +1 -1
- data/lib/puppet-lint/plugins/check_whitespace/2sp_soft_tabs.rb +1 -1
- data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +1 -1
- data/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb +1 -1
- data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +1 -1
- data/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb +1 -1
- data/lib/puppet-lint/tasks/gemfile_rewrite.rb +20 -0
- data/lib/puppet-lint/tasks/puppet-lint.rb +2 -2
- data/lib/puppet-lint/tasks/release_test.rb +50 -4
- data/lib/puppet-lint/version.rb +1 -1
- data/spec/puppet-lint/bin_spec.rb +37 -0
- data/spec/puppet-lint/data_spec.rb +18 -0
- data/spec/puppet-lint/lexer_spec.rb +28 -0
- metadata +83 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c2f7f4e8237599a2215c6e0b7b80126c6ed43cc2
|
4
|
+
data.tar.gz: 91aa136ffbc1370e60d999d9d0f591df2fbbb0f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e109be5cd7d30e0660fbc0b839d69e1bcd19870b12a31889076999deb2a0d7fe8519e28e874be556c6ebe9345a5df6a968acbf0c87ba1438d14f63bbb836264e
|
7
|
+
data.tar.gz: 8d65ef648c28a084e13b2450f0bebb69e2ee9ca937a6fee09ad5762c309da27f2496fbb7adf5b6bcc3117e3a2b4a65b790681073ab3956661a508d7586503fcf
|
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,40 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [2.3.5](https://github.com/rodjek/puppet-lint/tree/2.3.5) (2018-03-27)
|
4
|
+
[Full Changelog](https://github.com/rodjek/puppet-lint/compare/2.3.4...2.3.5)
|
5
|
+
|
6
|
+
**Fixed bugs:**
|
7
|
+
|
8
|
+
- v2.3.4 breakage - 'wrong number of arguments' when using Rake task [\#812](https://github.com/rodjek/puppet-lint/issues/812)
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- Make PuppetLint::OptParser.build argument optional [\#813](https://github.com/rodjek/puppet-lint/pull/813) ([rodjek](https://github.com/rodjek))
|
13
|
+
|
14
|
+
## [2.3.4](https://github.com/rodjek/puppet-lint/tree/2.3.4) (2018-03-26)
|
15
|
+
[Full Changelog](https://github.com/rodjek/puppet-lint/compare/2.3.3...2.3.4)
|
16
|
+
|
17
|
+
**Implemented enhancements:**
|
18
|
+
|
19
|
+
- Allow ignoring default configurations files on the command line [\#787](https://github.com/rodjek/puppet-lint/issues/787)
|
20
|
+
- Implement --list-checks feature, to list the names of all available checks from the cli. [\#804](https://github.com/rodjek/puppet-lint/pull/804) ([xraystyle](https://github.com/xraystyle))
|
21
|
+
- Option to disable loading default configurations files [\#789](https://github.com/rodjek/puppet-lint/pull/789) ([dioni21](https://github.com/dioni21))
|
22
|
+
- Allow passing ignore\_paths from cli [\#783](https://github.com/rodjek/puppet-lint/pull/783) ([keymone](https://github.com/keymone))
|
23
|
+
|
24
|
+
**Fixed bugs:**
|
25
|
+
|
26
|
+
- Bad value for range [\#801](https://github.com/rodjek/puppet-lint/issues/801)
|
27
|
+
- puppet-lint doesn't handle CRLFs very well [\#778](https://github.com/rodjek/puppet-lint/issues/778)
|
28
|
+
- Configuration's ignore\_paths is not respected [\#774](https://github.com/rodjek/puppet-lint/issues/774)
|
29
|
+
- Error when including class and missing a colon [\#507](https://github.com/rodjek/puppet-lint/issues/507)
|
30
|
+
|
31
|
+
**Merged pull requests:**
|
32
|
+
|
33
|
+
- Handle single colon in resource name syntax error [\#809](https://github.com/rodjek/puppet-lint/pull/809) ([rodjek](https://github.com/rodjek))
|
34
|
+
- \(\#778\) Don't include line ending in single line comment token values [\#782](https://github.com/rodjek/puppet-lint/pull/782) ([rodjek](https://github.com/rodjek))
|
35
|
+
- Fix setting ignore\_paths in Rake task [\#777](https://github.com/rodjek/puppet-lint/pull/777) ([alzabo](https://github.com/alzabo))
|
36
|
+
- Add support for passing backslash separated paths to puppet-lint [\#769](https://github.com/rodjek/puppet-lint/pull/769) ([rodjek](https://github.com/rodjek))
|
37
|
+
|
3
38
|
## [2.3.3](https://github.com/rodjek/puppet-lint/tree/2.3.3) (2017-09-28)
|
4
39
|
[Full Changelog](https://github.com/rodjek/puppet-lint/compare/2.3.2...2.3.3)
|
5
40
|
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Status](https://secure.travis-ci.org/rodjek/puppet-lint.png)](http://travis-ci.o
|
|
5
5
|
[](http://inch-ci.org/github/rodjek/puppet-lint)
|
6
6
|
|
7
7
|
Puppet Lint tests Puppet code against the recommended [Puppet language style
|
8
|
-
guide](http://
|
8
|
+
guide](http://puppet.com/docs/puppet/latest/style_guide.html). Puppet Lint validates only code style; it does not validate syntax. To test syntax, use Puppet's `puppet parser validate` command.
|
9
9
|
|
10
10
|
## Compatibility warning
|
11
11
|
|
@@ -45,6 +45,10 @@ puppet-lint --fix /modules
|
|
45
45
|
|
46
46
|
Puppet Lint options allow you to modify which checks to run. You can disable any of the checks temporarily or permanently, or you can limit testing to specific checks.
|
47
47
|
|
48
|
+
#### List all available checks
|
49
|
+
|
50
|
+
To list all available checks along with basic usage documentation, use the `--list-checks` option.
|
51
|
+
|
48
52
|
#### Run specific checks
|
49
53
|
|
50
54
|
To run only specific checks, use the `--only-checks` option, with a comma-separated list of arguments specifying which checks to make:
|
@@ -65,7 +69,7 @@ You can disable specific Lint checks on the command line, disable them permanent
|
|
65
69
|
|
66
70
|
#### Disable checks on the command line
|
67
71
|
|
68
|
-
To disable any of the checks when running the `puppet-lint` command, add a `--no-<
|
72
|
+
To disable any of the checks when running the `puppet-lint` command, add a `--no-<check_name>-check` flag to the command. For example, to skip the 140-character check, run:
|
69
73
|
|
70
74
|
```
|
71
75
|
puppet-lint --no-140chars-check modules/
|
data/Rakefile
CHANGED
@@ -12,7 +12,8 @@ begin
|
|
12
12
|
GitHubChangelogGenerator::RakeTask.new(:changelog) do |config|
|
13
13
|
version = PuppetLint::VERSION
|
14
14
|
config.future_release = version.to_s
|
15
|
-
config.exclude_labels = %w[duplicate question invalid wontfix release-pr]
|
15
|
+
config.exclude_labels = %w[duplicate question invalid wontfix release-pr documentation]
|
16
|
+
config.enhancement_labels = %w[feature]
|
16
17
|
end
|
17
18
|
rescue LoadError
|
18
19
|
$stderr.puts 'Changelog generation requires Ruby 2.0 or higher'
|
@@ -23,6 +24,14 @@ begin
|
|
23
24
|
|
24
25
|
RuboCop::RakeTask.new(:rubocop) do |task|
|
25
26
|
task.options = %w[-D -E]
|
27
|
+
task.patterns = [
|
28
|
+
'lib/**/*.rb',
|
29
|
+
'spec/**/*.rb',
|
30
|
+
'bin/*',
|
31
|
+
'*.gemspec',
|
32
|
+
'Gemfile',
|
33
|
+
'Rakefile',
|
34
|
+
]
|
26
35
|
end
|
27
36
|
rescue LoadError
|
28
37
|
$stderr.puts 'Rubocop is not available for this version of Ruby.'
|
data/lib/puppet-lint.rb
CHANGED
@@ -13,6 +13,15 @@ require 'puppet-lint/monkeypatches'
|
|
13
13
|
class PuppetLint::NoCodeError < StandardError; end
|
14
14
|
class PuppetLint::NoFix < StandardError; end
|
15
15
|
|
16
|
+
# Parser Syntax Errors
|
17
|
+
class PuppetLint::SyntaxError < StandardError
|
18
|
+
attr_reader :token
|
19
|
+
|
20
|
+
def initialize(token)
|
21
|
+
@token = token
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
16
25
|
# Public: The public interface to puppet-lint.
|
17
26
|
class PuppetLint
|
18
27
|
# Public: Gets/Sets the String manifest code to be checked.
|
@@ -75,7 +84,7 @@ class PuppetLint
|
|
75
84
|
return unless File.exist?(path)
|
76
85
|
|
77
86
|
@path = path
|
78
|
-
File.open(path, '
|
87
|
+
File.open(path, 'rb:UTF-8') do |f|
|
79
88
|
@code = f.read
|
80
89
|
end
|
81
90
|
|
data/lib/puppet-lint/bin.rb
CHANGED
@@ -19,9 +19,8 @@ class PuppetLint::Bin
|
|
19
19
|
#
|
20
20
|
# Returns an Integer exit code to be passed back to the shell.
|
21
21
|
def run
|
22
|
-
opts = PuppetLint::OptParser.build
|
23
|
-
|
24
22
|
begin
|
23
|
+
opts = PuppetLint::OptParser.build(@args)
|
25
24
|
opts.parse!(@args)
|
26
25
|
rescue OptionParser::InvalidOption => e
|
27
26
|
puts "puppet-lint: #{e.message}"
|
@@ -34,6 +33,11 @@ class PuppetLint::Bin
|
|
34
33
|
return 0
|
35
34
|
end
|
36
35
|
|
36
|
+
if PuppetLint.configuration.list_checks
|
37
|
+
puts PuppetLint.configuration.checks
|
38
|
+
return 0
|
39
|
+
end
|
40
|
+
|
37
41
|
if @args[0].nil?
|
38
42
|
puts 'puppet-lint: no file specified'
|
39
43
|
puts "puppet-lint: try 'puppet-lint --help' for more information"
|
@@ -42,6 +46,7 @@ class PuppetLint::Bin
|
|
42
46
|
|
43
47
|
begin
|
44
48
|
path = @args[0]
|
49
|
+
path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
45
50
|
path = if File.directory?(path)
|
46
51
|
Dir.glob("#{path}/**/*.pp")
|
47
52
|
else
|
@@ -51,9 +56,11 @@ class PuppetLint::Bin
|
|
51
56
|
PuppetLint.configuration.with_filename = true if path.length > 1
|
52
57
|
|
53
58
|
return_val = 0
|
59
|
+
ignore_paths = PuppetLint.configuration.ignore_paths
|
54
60
|
|
55
61
|
puts '[' if PuppetLint.configuration.json
|
56
62
|
path.each do |f|
|
63
|
+
next if ignore_paths.any? { |p| File.fnmatch(p, f) }
|
57
64
|
l = PuppetLint.new
|
58
65
|
l.file = f
|
59
66
|
l.run
|
data/lib/puppet-lint/checks.rb
CHANGED
@@ -66,6 +66,19 @@ class PuppetLint::Checks
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
@problems
|
70
|
+
rescue PuppetLint::SyntaxError => e
|
71
|
+
@problems << {
|
72
|
+
:kind => :error,
|
73
|
+
:check => :syntax,
|
74
|
+
:message => 'Syntax error',
|
75
|
+
:fullpath => File.expand_path(fileinfo, ENV['PWD']),
|
76
|
+
:filename => File.basename(fileinfo),
|
77
|
+
:path => fileinfo,
|
78
|
+
:line => e.token.line,
|
79
|
+
:column => e.token.column,
|
80
|
+
}
|
81
|
+
|
69
82
|
@problems
|
70
83
|
rescue => e
|
71
84
|
$stdout.puts <<-END.gsub(%r{^ {6}}, '')
|
data/lib/puppet-lint/data.rb
CHANGED
@@ -176,6 +176,8 @@ class PuppetLint::Data
|
|
176
176
|
end_token = colon_token.next_token_of([:SEMIC, :RBRACE])
|
177
177
|
end_idx = tokens.index(end_token)
|
178
178
|
|
179
|
+
raise PuppetLint::SyntaxError, colon_token if end_idx.nil?
|
180
|
+
|
179
181
|
result << {
|
180
182
|
:start => start_idx + 1,
|
181
183
|
:end => end_idx,
|
data/lib/puppet-lint/lexer.rb
CHANGED
@@ -172,6 +172,8 @@ class PuppetLint
|
|
172
172
|
# \p{Zs} == ASCII + Unicode non-linebreaking whitespace
|
173
173
|
WHITESPACE_RE = RUBY_VERSION == '1.8.7' ? %r{[\t\v\f ]} : %r{[\t\v\f\p{Zs}]}
|
174
174
|
|
175
|
+
LINE_END_RE = %r{(?:\r\n|\r|\n)}
|
176
|
+
|
175
177
|
# Internal: Access the internal token storage.
|
176
178
|
#
|
177
179
|
# Returns an Array of PuppetLint::Lexer::Toxen objects.
|
@@ -222,7 +224,7 @@ class PuppetLint
|
|
222
224
|
|
223
225
|
elsif chunk.start_with?('"')
|
224
226
|
str_contents = slurp_string(code[i + 1..-1])
|
225
|
-
lines_parsed = code[0..i].split(
|
227
|
+
lines_parsed = code[0..i].split(LINE_END_RE)
|
226
228
|
interpolate_string(str_contents, lines_parsed.count, lines_parsed.last.length)
|
227
229
|
length = str_contents.size + 1
|
228
230
|
|
@@ -231,12 +233,12 @@ class PuppetLint
|
|
231
233
|
tokens << new_token(:HEREDOC_OPEN, heredoc_name)
|
232
234
|
length = heredoc_name.size + 3
|
233
235
|
|
234
|
-
elsif comment = chunk[%r{\A(
|
236
|
+
elsif comment = chunk[%r{\A(#[^\r\n]*)#{LINE_END_RE}?}, 1]
|
235
237
|
length = comment.size
|
236
238
|
comment.sub!(%r{#}, '')
|
237
239
|
tokens << new_token(:COMMENT, comment)
|
238
240
|
|
239
|
-
elsif slash_comment = chunk[%r{\A(
|
241
|
+
elsif slash_comment = chunk[%r{\A(//[^\r\n]*)#{LINE_END_RE}?}, 1]
|
240
242
|
length = slash_comment.size
|
241
243
|
slash_comment.sub!(%r{//}, '')
|
242
244
|
tokens << new_token(:SLASH_COMMENT, slash_comment)
|
@@ -254,13 +256,13 @@ class PuppetLint
|
|
254
256
|
length = str_content.size + 1
|
255
257
|
tokens << new_token(:REGEX, str_content[0..-2])
|
256
258
|
|
257
|
-
elsif eolindent = chunk[%r{\A(
|
258
|
-
eol = eolindent[%r{\A(
|
259
|
+
elsif eolindent = chunk[%r{\A(#{LINE_END_RE}#{WHITESPACE_RE}+)}m, 1]
|
260
|
+
eol = eolindent[%r{\A(#{LINE_END_RE})}m, 1]
|
259
261
|
tokens << new_token(:NEWLINE, eol)
|
260
262
|
length = eol.size
|
261
263
|
|
262
264
|
if heredoc_queue.empty?
|
263
|
-
indent = eolindent[%r{\A
|
265
|
+
indent = eolindent[%r{\A#{LINE_END_RE}+(#{WHITESPACE_RE}+)}m, 1]
|
264
266
|
tokens << new_token(:INDENT, indent)
|
265
267
|
length += indent.size
|
266
268
|
else
|
@@ -275,7 +277,7 @@ class PuppetLint
|
|
275
277
|
length = whitespace.size
|
276
278
|
tokens << new_token(:WHITESPACE, whitespace)
|
277
279
|
|
278
|
-
elsif eol = chunk[%r{\A(
|
280
|
+
elsif eol = chunk[%r{\A(#{LINE_END_RE})}, 1]
|
279
281
|
length = eol.size
|
280
282
|
tokens << new_token(:NEWLINE, eol)
|
281
283
|
|
@@ -283,7 +285,7 @@ class PuppetLint
|
|
283
285
|
heredoc_tag = heredoc_queue.shift
|
284
286
|
heredoc_name = heredoc_tag[%r{\A"?(.+?)"?(:.+?)?(/.*)?\Z}, 1]
|
285
287
|
str_contents = StringScanner.new(code[(i + length)..-1]).scan_until(%r{\|?\s*-?\s*#{heredoc_name}})
|
286
|
-
_ = code[0..(i + length)].split(
|
288
|
+
_ = code[0..(i + length)].split(LINE_END_RE)
|
287
289
|
interpolate_heredoc(str_contents, heredoc_tag)
|
288
290
|
length += str_contents.size
|
289
291
|
end
|
@@ -386,7 +388,7 @@ class PuppetLint
|
|
386
388
|
@line_no += 1
|
387
389
|
@column = 1
|
388
390
|
else
|
389
|
-
lines = token.to_manifest.split(
|
391
|
+
lines = token.to_manifest.split(LINE_END_RE, -1)
|
390
392
|
@line_no += lines.length - 1
|
391
393
|
if lines.length > 1
|
392
394
|
# if the token renders to multiple lines, set the column state to the
|
@@ -438,7 +440,7 @@ class PuppetLint
|
|
438
440
|
else
|
439
441
|
token_column = column + (ss.pos - value.size)
|
440
442
|
tokens << new_token(:DQPOST, value, :line => line, :column => token_column)
|
441
|
-
line += value.scan(
|
443
|
+
line += value.scan(LINE_END_RE).size
|
442
444
|
@column = column + ss.pos + 1
|
443
445
|
@line_no = line
|
444
446
|
end
|
@@ -449,7 +451,7 @@ class PuppetLint
|
|
449
451
|
else
|
450
452
|
token_column = column + (ss.pos - value.size)
|
451
453
|
tokens << new_token(:DQMID, value, :line => line, :column => token_column)
|
452
|
-
line += value.scan(
|
454
|
+
line += value.scan(LINE_END_RE).size
|
453
455
|
end
|
454
456
|
if ss.scan(%r{\{}).nil?
|
455
457
|
var_name = ss.scan(%r{(::)?(\w+(-\w+)*::)*\w+(-\w+)*})
|
@@ -461,7 +463,7 @@ class PuppetLint
|
|
461
463
|
tokens << new_token(:UNENC_VARIABLE, var_name, :line => line, :column => token_column)
|
462
464
|
end
|
463
465
|
else
|
464
|
-
line += value.scan(
|
466
|
+
line += value.scan(LINE_END_RE).size
|
465
467
|
contents = ss.scan_until(%r{\}})[0..-2]
|
466
468
|
raw = contents.dup
|
467
469
|
if contents.match(%r{\A(::)?([\w-]+::)*[\w-]+(\[.+?\])*}) && !contents.match(%r{\A\w+\(})
|
@@ -17,14 +17,19 @@ class PuppetLint::OptParser
|
|
17
17
|
# Public: Initialise a new puppet-lint OptionParser.
|
18
18
|
#
|
19
19
|
# Returns an OptionParser object.
|
20
|
-
def self.build
|
21
|
-
|
20
|
+
def self.build(args = [])
|
21
|
+
noconfig = false
|
22
|
+
opt_parser = OptionParser.new do |opts|
|
22
23
|
opts.banner = HELP_TEXT
|
23
24
|
|
24
25
|
opts.on('--version', 'Display the current version.') do
|
25
26
|
PuppetLint.configuration.display_version = true
|
26
27
|
end
|
27
28
|
|
29
|
+
opts.on('--no-config', 'Do not load default puppet-lint option files.') do
|
30
|
+
noconfig = true
|
31
|
+
end
|
32
|
+
|
28
33
|
opts.on('-c', '--config FILE', 'Load puppet-lint options from file.') do |file|
|
29
34
|
opts.load(file)
|
30
35
|
end
|
@@ -94,6 +99,10 @@ class PuppetLint::OptParser
|
|
94
99
|
PuppetLint.configuration.json = true
|
95
100
|
end
|
96
101
|
|
102
|
+
opts.on('--list-checks', 'List available check names.') do
|
103
|
+
PuppetLint.configuration.list_checks = true
|
104
|
+
end
|
105
|
+
|
97
106
|
opts.separator('')
|
98
107
|
opts.separator(' Checks:')
|
99
108
|
|
@@ -108,6 +117,10 @@ class PuppetLint::OptParser
|
|
108
117
|
end
|
109
118
|
end
|
110
119
|
|
120
|
+
opts.on('--ignore-paths PATHS', 'A comma separated list of patterns to ignore') do |paths|
|
121
|
+
PuppetLint.configuration.ignore_paths = paths.split(',')
|
122
|
+
end
|
123
|
+
|
111
124
|
PuppetLint.configuration.checks.each do |check|
|
112
125
|
opts.on("--no-#{check}-check", "Skip the #{check} check.") do
|
113
126
|
PuppetLint.configuration.send("disable_#{check}")
|
@@ -119,13 +132,19 @@ class PuppetLint::OptParser
|
|
119
132
|
PuppetLint.configuration.send("enable_#{check}")
|
120
133
|
end
|
121
134
|
end
|
135
|
+
end
|
122
136
|
|
123
|
-
|
137
|
+
opt_parser.parse!(args) unless args.empty?
|
138
|
+
|
139
|
+
unless noconfig
|
140
|
+
opt_parser.load('/etc/puppet-lint.rc')
|
124
141
|
if ENV.key?('HOME') && File.readable?(ENV['HOME'])
|
125
142
|
home_dotfile_path = File.expand_path('~/.puppet-lint.rc')
|
126
|
-
|
143
|
+
opt_parser.load(home_dotfile_path) if File.readable?(home_dotfile_path)
|
127
144
|
end
|
128
|
-
|
145
|
+
opt_parser.load('.puppet-lint.rc')
|
129
146
|
end
|
147
|
+
|
148
|
+
opt_parser
|
130
149
|
end
|
131
150
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Test the manifest tokens for chaining arrow that is
|
2
2
|
# on the line of the left operand when the right operand is on another line.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#chaining-arrow-syntax
|
5
5
|
PuppetLint.new_check(:arrow_on_right_operand_line) do
|
6
6
|
def check
|
7
7
|
tokens.select { |r| Set[:IN_EDGE, :IN_EDGE_SUB].include?(r.type) }.each do |token|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# not in an appropriately named file for the autoloader to detect and record
|
3
3
|
# an error of each instance found.
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#separate-files
|
6
6
|
PuppetLint.new_check(:autoloader_layout) do
|
7
7
|
def check
|
8
8
|
return if fullpath.nil? || fullpath == ''
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Test the manifest tokens for any classes that inherit across
|
2
2
|
# namespaces and record a warning for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#class-inheritance
|
5
5
|
PuppetLint.new_check(:inherits_across_namespaces) do
|
6
6
|
def check
|
7
7
|
class_indexes.each do |class_idx|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Public: Find and warn about module names with illegal uppercase characters.
|
2
2
|
#
|
3
|
-
# https://
|
3
|
+
# https://puppet.com/docs/puppet/latest/modules_fundamentals.html#allowed-module-names
|
4
4
|
# Provides a fix. [puppet-lint #554]
|
5
5
|
PuppetLint.new_check(:names_containing_uppercase) do
|
6
6
|
def check
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Test the manifest tokens for any classes or defined types that are
|
2
2
|
# defined inside another class.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#nested-classes-or-defined-types
|
5
5
|
PuppetLint.new_check(:nested_classes_or_defines) do
|
6
6
|
TOKENS = Set[:CLASS, :DEFINE]
|
7
7
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# types that take parameters and record a warning if there are any optional
|
3
3
|
# parameters listed before required parameters.
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#display-order-of-parameters
|
6
6
|
PuppetLint.new_check(:parameter_order) do
|
7
7
|
def check
|
8
8
|
(class_indexes + defined_type_indexes).each do |class_idx|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Test the manifest tokens for any right-to-left (<-) chaining
|
2
2
|
# operators and record a warning for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#chaining-arrow-syntax
|
5
5
|
PuppetLint.new_check(:right_to_left_relationship) do
|
6
6
|
def check
|
7
7
|
tokens.select { |r| r.type == :OUT_EDGE }.each do |token|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# defined in the local scope and record a warning for each variable that has
|
5
5
|
# not.
|
6
6
|
#
|
7
|
-
# https://
|
7
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#namespacing-variables
|
8
8
|
PuppetLint.new_check(:variable_scope) do
|
9
9
|
DEFAULT_SCOPE_VARS = Set[
|
10
10
|
'name',
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Check the manifest tokens for any comments started with slashes
|
2
2
|
# (//) and record a warning for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#comments
|
5
5
|
PuppetLint.new_check(:slash_comments) do
|
6
6
|
def check
|
7
7
|
tokens.select { |token|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Check the manifest tokens for any comments encapsulated with
|
2
2
|
# slash-asterisks (/* */) and record a warning for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#comments
|
5
5
|
PuppetLint.new_check(:star_comments) do
|
6
6
|
def check
|
7
7
|
tokens.select { |token|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Test the manifest tokens for any case statements that do not
|
2
2
|
# contain a "default" case and record a warning for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#defaults-for-case-statements-and-selectors
|
5
5
|
PuppetLint.new_check(:case_without_default) do
|
6
6
|
def check
|
7
7
|
case_indexes = []
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Test the manifest tokens for any selectors embedded within resource
|
2
2
|
# declarations and record a warning for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#keep-resource-declarations-simple
|
5
5
|
PuppetLint.new_check(:selector_inside_resource) do
|
6
6
|
def check
|
7
7
|
resource_indexes.each do |resource|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# have a comment directly above it (hopefully, explaining the usage of it) and
|
3
3
|
# record a warning for each instance found.
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#public-and-private
|
6
6
|
PuppetLint.new_check(:documentation) do
|
7
7
|
COMMENT_TOKENS = Set[:COMMENT, :MLCOMMENT, :SLASH_COMMENT]
|
8
8
|
WHITESPACE_TOKENS = Set[:WHITESPACE, :NEWLINE, :INDENT]
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# and if found, check that it is the first parameter listed. If it is not
|
3
3
|
# the first parameter, record a warning.
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#attribute-ordering
|
6
6
|
PuppetLint.new_check(:ensure_first_param) do
|
7
7
|
def check
|
8
8
|
resource_indexes.each do |resource|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# parameter and record a warning if the value of that parameter looks like
|
3
3
|
# a symlink target (starts with a '/').
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#symbolic-links
|
6
6
|
PuppetLint.new_check(:ensure_not_symlink_target) do
|
7
7
|
def check
|
8
8
|
resource_indexes.each do |resource|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# parameter and if found, record a warning if the value of that parameter is
|
3
3
|
# not a 4 digit octal value (0755) or a symbolic mode ('o=rwx,g+r').
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#file-modes
|
6
6
|
PuppetLint.new_check(:file_mode) do
|
7
7
|
MSG = 'mode should be represented as a 4 digit octal value or symbolic mode'.freeze
|
8
8
|
SYM_RE = '([ugoa]*[-=+][-=+rstwxXugo]*)(,[ugoa]*[-=+][-=+rstwxXugo]*)*'.freeze
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# parameter and if found, record a warning if the value of that parameter is
|
3
3
|
# not a quoted string.
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#file-modes
|
6
6
|
PuppetLint.new_check(:unquoted_file_mode) do
|
7
7
|
TOKEN_TYPES = Set[:NAME, :NUMBER]
|
8
8
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Check the manifest tokens for any resource titles / namevars that
|
2
2
|
# are not quoted and record a warning for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#resource-names
|
5
5
|
PuppetLint.new_check(:unquoted_resource_title) do
|
6
6
|
def check
|
7
7
|
title_tokens.each do |token|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# contain any variables or common escape characters and record a warning for
|
3
3
|
# each instance found.
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#quoting
|
6
6
|
PuppetLint.new_check(:double_quoted_strings) do
|
7
7
|
ESCAPE_CHAR_RE = %r{(\\\$|\\"|\\'|'|\r|\t|\\t|\n|\\n|\\\\)}
|
8
8
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Check the manifest tokens for double quoted strings that contain
|
2
2
|
# a single variable only and record a warning for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#quoting
|
5
5
|
PuppetLint.new_check(:only_variable_string) do
|
6
6
|
VAR_TYPES = Set[:VARIABLE, :UNENC_VARIABLE]
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Check the manifest tokens for any single quoted strings containing
|
2
2
|
# a enclosed variable and record an error for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#quoting
|
5
5
|
PuppetLint.new_check(:single_quote_string_with_variables) do
|
6
6
|
def check
|
7
7
|
tokens.select { |r|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# not been enclosed by braces ({}) and record a warning for each instance
|
3
3
|
# found.
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#quoting
|
6
6
|
PuppetLint.new_check(:variables_not_enclosed) do
|
7
7
|
def check
|
8
8
|
tokens.select { |r|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# to this rule are lines containing URLs and template() calls which would hurt
|
4
4
|
# readability if split.
|
5
5
|
#
|
6
|
-
# https://
|
6
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace
|
7
7
|
PuppetLint.new_check(:'140chars') do
|
8
8
|
def check
|
9
9
|
manifest_lines.each_with_index do |line, idx|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Check the manifest tokens for any indentation not using 2 space soft
|
2
2
|
# tabs and record an error for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace
|
5
5
|
PuppetLint.new_check(:'2sp_soft_tabs') do
|
6
6
|
def check
|
7
7
|
tokens.select { |r|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# characters. This is DISABLED by default and behaves like the default
|
3
3
|
# 140chars check by excepting URLs and template() calls.
|
4
4
|
#
|
5
|
-
# https://
|
5
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace (older version)
|
6
6
|
PuppetLint.new_check(:'80chars') do
|
7
7
|
def check
|
8
8
|
manifest_lines.each_with_index do |line, idx|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Check the manifest tokens for any arrows (=>) in a grouping ({}) that
|
2
2
|
# are not aligned with other arrows in that grouping.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace
|
5
5
|
PuppetLint.new_check(:arrow_alignment) do
|
6
6
|
COMMENT_TYPES = Set[:COMMENT, :SLASH_COMMENT, :MLCOMMENT]
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Check the raw manifest string for lines containing hard tab
|
2
2
|
# characters and record an error for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace
|
5
5
|
PuppetLint.new_check(:hard_tabs) do
|
6
6
|
WHITESPACE_TYPES = Set[:INDENT, :WHITESPACE]
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Public: Check the manifest tokens for lines ending with whitespace and record
|
2
2
|
# an error for each instance found.
|
3
3
|
#
|
4
|
-
# https://
|
4
|
+
# https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace
|
5
5
|
PuppetLint.new_check(:trailing_whitespace) do
|
6
6
|
def check
|
7
7
|
tokens.select { |token|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'parser/current'
|
2
|
+
|
3
|
+
# Simple rewriter using whitequark/parser that rewrites the "gem 'puppet-lint'"
|
4
|
+
# entry in the module's Gemfile (if present) to instead use the local
|
5
|
+
# puppet-lint working directory.
|
6
|
+
class GemfileRewrite < Parser::TreeRewriter
|
7
|
+
def on_send(node)
|
8
|
+
_, method_name, *args = *node
|
9
|
+
|
10
|
+
if method_name == :gem
|
11
|
+
gem_name = args.first
|
12
|
+
if gem_name.type == :str && gem_name.children.first == 'puppet-lint'
|
13
|
+
puppet_lint_root = File.expand_path(File.join(__FILE__, '..', '..', '..', '..'))
|
14
|
+
replace(node.location.expression, "gem 'puppet-lint', :path => '#{puppet_lint_root}'")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
@@ -64,8 +64,8 @@ class PuppetLint
|
|
64
64
|
PuppetLint.configuration.send("#{config}=".to_sym, value) unless value.nil?
|
65
65
|
end
|
66
66
|
|
67
|
-
if PuppetLint.configuration.ignore_paths
|
68
|
-
@ignore_paths
|
67
|
+
if PuppetLint.configuration.ignore_paths && @ignore_paths.empty?
|
68
|
+
@ignore_paths = PuppetLint.configuration.ignore_paths
|
69
69
|
end
|
70
70
|
|
71
71
|
if PuppetLint.configuration.pattern
|
@@ -27,6 +27,33 @@ def run_cmd(message, *cmd)
|
|
27
27
|
[output.strip, status.success?]
|
28
28
|
end
|
29
29
|
|
30
|
+
def with_puppet_lint_head
|
31
|
+
print(' Updating Gemfile to use puppet-lint HEAD... ')
|
32
|
+
|
33
|
+
buffer = Parser::Source::Buffer.new('Gemfile')
|
34
|
+
buffer.source = File.read('Gemfile')
|
35
|
+
parser = Parser::CurrentRuby.new
|
36
|
+
ast = parser.parse(buffer)
|
37
|
+
|
38
|
+
modified_gemfile = GemfileRewrite.new.rewrite(buffer, ast)
|
39
|
+
if modified_gemfile == buffer.source
|
40
|
+
puppet_lint_root = File.expand_path(File.join(__FILE__, '..', '..', '..', '..'))
|
41
|
+
File.open('Gemfile', 'a') do |f|
|
42
|
+
f.puts "gem 'puppet-lint', :path => '#{puppet_lint_root}'"
|
43
|
+
end
|
44
|
+
else
|
45
|
+
File.open('Gemfile', 'w') do |f|
|
46
|
+
f.puts modified_gemfile
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
puts 'Done'
|
51
|
+
|
52
|
+
Bundler.with_clean_env { yield }
|
53
|
+
|
54
|
+
run_cmd('Restoring Gemfile', 'git', 'checkout', '--', 'Gemfile')
|
55
|
+
end
|
56
|
+
|
30
57
|
task :release_test do
|
31
58
|
branch = if ENV['APPVEYOR']
|
32
59
|
ENV['APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH']
|
@@ -41,6 +68,13 @@ task :release_test do
|
|
41
68
|
exit
|
42
69
|
end
|
43
70
|
|
71
|
+
if RUBY_VERSION.start_with?('1')
|
72
|
+
puts 'Unable to run release_tests on Ruby < 2.0'
|
73
|
+
exit
|
74
|
+
end
|
75
|
+
|
76
|
+
require 'puppet-lint/tasks/gemfile_rewrite'
|
77
|
+
|
44
78
|
modules_to_test = [
|
45
79
|
'puppetlabs/puppetlabs-apt',
|
46
80
|
'puppetlabs/puppetlabs-tomcat',
|
@@ -72,10 +106,22 @@ task :release_test do
|
|
72
106
|
end
|
73
107
|
|
74
108
|
Dir.chdir(module_dir) do
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
109
|
+
with_puppet_lint_head do
|
110
|
+
_, success = run_cmd('Installing dependencies', 'bundle', 'install', '--path', File.join('..', 'vendor', 'gems'))
|
111
|
+
next unless success
|
112
|
+
|
113
|
+
output, success = run_cmd('Running puppet-lint CLI', 'bundle', 'exec', 'puppet-lint', '--relative', '--no-documentation-check', 'manifests')
|
114
|
+
unless output.empty?
|
115
|
+
output.split("\n").each do |line|
|
116
|
+
puts " #{line}"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
output, success = run_cmd('Running puppet-lint Rake task', 'bundle', 'exec', 'rake', 'lint')
|
121
|
+
unless output.empty?
|
122
|
+
output.split("\n").each do |line|
|
123
|
+
puts " #{line}"
|
124
|
+
end
|
79
125
|
end
|
80
126
|
end
|
81
127
|
end
|
data/lib/puppet-lint/version.rb
CHANGED
@@ -55,6 +55,30 @@ describe PuppetLint::Bin do
|
|
55
55
|
its(:stdout) { is_expected.to eq("puppet-lint #{PuppetLint::VERSION}") }
|
56
56
|
end
|
57
57
|
|
58
|
+
context 'when asked to display available checks' do
|
59
|
+
let(:args) { '--list-checks' }
|
60
|
+
all_checks = PuppetLint.configuration.checks.map(&:to_s)
|
61
|
+
|
62
|
+
its(:exitstatus) { is_expected.to eq(0) }
|
63
|
+
|
64
|
+
all_checks.each do |c|
|
65
|
+
it "includes check #{c} in its output" do
|
66
|
+
expect(subject.stdout).to include c
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'when passed a backslash separated path on Windows', :if => Gem.win_platform? do
|
72
|
+
let(:args) do
|
73
|
+
[
|
74
|
+
'spec\fixtures\test\manifests',
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
78
|
+
its(:exitstatus) { is_expected.to eq(1) }
|
79
|
+
its(:stdout) { is_expected.to match(%r{spec/fixtures/test/manifests/warning\.pp - WARNING: optional}m) }
|
80
|
+
end
|
81
|
+
|
58
82
|
context 'when passed multiple files' do
|
59
83
|
let(:args) do
|
60
84
|
[
|
@@ -82,6 +106,19 @@ describe PuppetLint::Bin do
|
|
82
106
|
its(:stderr) { is_expected.to eq('Try running `puppet parser validate <file>`') }
|
83
107
|
end
|
84
108
|
|
109
|
+
context 'when passed ignore paths option' do
|
110
|
+
let(:args) do
|
111
|
+
[
|
112
|
+
'--ignore-paths',
|
113
|
+
'spec/*',
|
114
|
+
'spec/fixtures/test/manifests/malformed.pp',
|
115
|
+
]
|
116
|
+
end
|
117
|
+
|
118
|
+
its(:exitstatus) { is_expected.to eq(0) }
|
119
|
+
its(:stdout) { is_expected.to eq('') }
|
120
|
+
end
|
121
|
+
|
85
122
|
context 'when limited to errors only' do
|
86
123
|
let(:args) do
|
87
124
|
[
|
@@ -4,6 +4,24 @@ describe PuppetLint::Data do
|
|
4
4
|
subject(:data) { PuppetLint::Data }
|
5
5
|
let(:lexer) { PuppetLint::Lexer.new }
|
6
6
|
|
7
|
+
describe '.resource_indexes' do
|
8
|
+
before(:each) do
|
9
|
+
data.tokens = lexer.tokenise(manifest)
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when a namespaced class name contains a single colon' do
|
13
|
+
let(:manifest) { 'class foo:bar { }' }
|
14
|
+
|
15
|
+
it 'raises a SyntaxError' do
|
16
|
+
expect {
|
17
|
+
data.resource_indexes
|
18
|
+
}.to raise_error(PuppetLint::SyntaxError) { |error|
|
19
|
+
expect(error.token).to eq(data.tokens[3])
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
7
25
|
describe '.insert' do
|
8
26
|
let(:manifest) { '$x = $a' }
|
9
27
|
let(:new_token) { PuppetLint::Lexer::Token.new(:PLUS, '+', 0, 0) }
|
@@ -1338,6 +1338,20 @@ END
|
|
1338
1338
|
expect(token.type).to eq(:COMMENT)
|
1339
1339
|
expect(token.value).to eq(' bar baz')
|
1340
1340
|
end
|
1341
|
+
|
1342
|
+
it 'should not include DOS line endings in the comment value' do
|
1343
|
+
tokens = @lexer.tokenise("foo # bar baz\r\n")
|
1344
|
+
|
1345
|
+
expect(tokens[2]).to have_attributes(:type => :COMMENT, :value => ' bar baz')
|
1346
|
+
expect(tokens[3]).to have_attributes(:type => :NEWLINE, :value => "\r\n")
|
1347
|
+
end
|
1348
|
+
|
1349
|
+
it 'should not include Unix line endings in the comment value' do
|
1350
|
+
tokens = @lexer.tokenise("foo # bar baz\n")
|
1351
|
+
|
1352
|
+
expect(tokens[2]).to have_attributes(:type => :COMMENT, :value => ' bar baz')
|
1353
|
+
expect(tokens[3]).to have_attributes(:type => :NEWLINE, :value => "\n")
|
1354
|
+
end
|
1341
1355
|
end
|
1342
1356
|
|
1343
1357
|
context ':MLCOMMENT' do
|
@@ -1360,6 +1374,20 @@ END
|
|
1360
1374
|
expect(token.type).to eq(:SLASH_COMMENT)
|
1361
1375
|
expect(token.value).to eq(' bar baz')
|
1362
1376
|
end
|
1377
|
+
|
1378
|
+
it 'should not include DOS line endings in the comment value' do
|
1379
|
+
tokens = @lexer.tokenise("foo // bar baz\r\n")
|
1380
|
+
|
1381
|
+
expect(tokens[2]).to have_attributes(:type => :SLASH_COMMENT, :value => ' bar baz')
|
1382
|
+
expect(tokens[3]).to have_attributes(:type => :NEWLINE, :value => "\r\n")
|
1383
|
+
end
|
1384
|
+
|
1385
|
+
it 'should not include Unix line endings in the comment value' do
|
1386
|
+
tokens = @lexer.tokenise("foo // bar baz\n")
|
1387
|
+
|
1388
|
+
expect(tokens[2]).to have_attributes(:type => :SLASH_COMMENT, :value => ' bar baz')
|
1389
|
+
expect(tokens[3]).to have_attributes(:type => :NEWLINE, :value => "\n")
|
1390
|
+
end
|
1363
1391
|
end
|
1364
1392
|
|
1365
1393
|
context ':SSTRING' do
|
metadata
CHANGED
@@ -1,40 +1,29 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 3
|
9
|
-
- 3
|
10
|
-
version: 2.3.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.5
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Tim Sharpe
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2017-09-28 00:00:00 +10:00
|
19
|
-
default_executable:
|
11
|
+
date: 2018-03-27 00:00:00.000000000 Z
|
20
12
|
dependencies: []
|
21
|
-
|
22
13
|
description: |-
|
23
14
|
Checks your Puppet manifests against the Puppetlabs
|
24
15
|
style guide and alerts you to any discrepancies.
|
25
16
|
email: tim@sharpe.id.au
|
26
|
-
executables:
|
17
|
+
executables:
|
27
18
|
- puppet-lint
|
28
19
|
extensions: []
|
29
|
-
|
30
20
|
extra_rdoc_files: []
|
31
|
-
|
32
|
-
|
33
|
-
- .
|
34
|
-
- .
|
35
|
-
- .
|
36
|
-
- .
|
37
|
-
- .travis.yml
|
21
|
+
files:
|
22
|
+
- ".gitignore"
|
23
|
+
- ".rspec"
|
24
|
+
- ".rubocop.yml"
|
25
|
+
- ".rubocop_todo.yml"
|
26
|
+
- ".travis.yml"
|
38
27
|
- CHANGELOG.md
|
39
28
|
- Gemfile
|
40
29
|
- LICENSE
|
@@ -90,6 +79,7 @@ files:
|
|
90
79
|
- lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb
|
91
80
|
- lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb
|
92
81
|
- lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb
|
82
|
+
- lib/puppet-lint/tasks/gemfile_rewrite.rb
|
93
83
|
- lib/puppet-lint/tasks/puppet-lint.rb
|
94
84
|
- lib/puppet-lint/tasks/release_test.rb
|
95
85
|
- lib/puppet-lint/version.rb
|
@@ -151,39 +141,84 @@ files:
|
|
151
141
|
- spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb
|
152
142
|
- spec/puppet-lint_spec.rb
|
153
143
|
- spec/spec_helper.rb
|
154
|
-
has_rdoc: true
|
155
144
|
homepage: https://github.com/rodjek/puppet-lint/
|
156
145
|
licenses: []
|
157
|
-
|
146
|
+
metadata: {}
|
158
147
|
post_install_message:
|
159
148
|
rdoc_options: []
|
160
|
-
|
161
|
-
require_paths:
|
149
|
+
require_paths:
|
162
150
|
- lib
|
163
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
-
|
165
|
-
requirements:
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
166
153
|
- - ">="
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
version: "0"
|
172
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
-
none: false
|
174
|
-
requirements:
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
175
158
|
- - ">="
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
|
178
|
-
segments:
|
179
|
-
- 0
|
180
|
-
version: "0"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
181
161
|
requirements: []
|
182
|
-
|
183
162
|
rubyforge_project:
|
184
|
-
rubygems_version:
|
163
|
+
rubygems_version: 2.6.13
|
185
164
|
signing_key:
|
186
|
-
specification_version:
|
165
|
+
specification_version: 4
|
187
166
|
summary: Ensure your Puppet manifests conform with the Puppetlabs style guide
|
188
|
-
test_files:
|
189
|
-
|
167
|
+
test_files:
|
168
|
+
- spec/fixtures/test/manifests/fail.pp
|
169
|
+
- spec/fixtures/test/manifests/ignore.pp
|
170
|
+
- spec/fixtures/test/manifests/ignore_multiple_block.pp
|
171
|
+
- spec/fixtures/test/manifests/ignore_multiple_line.pp
|
172
|
+
- spec/fixtures/test/manifests/ignore_reason.pp
|
173
|
+
- spec/fixtures/test/manifests/init.pp
|
174
|
+
- spec/fixtures/test/manifests/malformed.pp
|
175
|
+
- spec/fixtures/test/manifests/mismatched_control_comment.pp
|
176
|
+
- spec/fixtures/test/manifests/unterminated_control_comment.pp
|
177
|
+
- spec/fixtures/test/manifests/url_interpolation.pp
|
178
|
+
- spec/fixtures/test/manifests/warning.pp
|
179
|
+
- spec/puppet-lint/bin_spec.rb
|
180
|
+
- spec/puppet-lint/checks_spec.rb
|
181
|
+
- spec/puppet-lint/configuration_spec.rb
|
182
|
+
- spec/puppet-lint/data_spec.rb
|
183
|
+
- spec/puppet-lint/ignore_overrides_spec.rb
|
184
|
+
- spec/puppet-lint/lexer/token_spec.rb
|
185
|
+
- spec/puppet-lint/lexer_spec.rb
|
186
|
+
- spec/puppet-lint/plugins/check_classes/arrow_on_right_operand_line_spec.rb
|
187
|
+
- spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb
|
188
|
+
- spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb
|
189
|
+
- spec/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb
|
190
|
+
- spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb
|
191
|
+
- spec/puppet-lint/plugins/check_classes/name_contains_uppercase_spec.rb
|
192
|
+
- spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb
|
193
|
+
- spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb
|
194
|
+
- spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb
|
195
|
+
- spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb
|
196
|
+
- spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb
|
197
|
+
- spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb
|
198
|
+
- spec/puppet-lint/plugins/check_comments/star_comments_spec.rb
|
199
|
+
- spec/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb
|
200
|
+
- spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb
|
201
|
+
- spec/puppet-lint/plugins/check_documentation/documentation_spec.rb
|
202
|
+
- spec/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb
|
203
|
+
- spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb
|
204
|
+
- spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb
|
205
|
+
- spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb
|
206
|
+
- spec/puppet-lint/plugins/check_resources/file_mode_spec.rb
|
207
|
+
- spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb
|
208
|
+
- spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb
|
209
|
+
- spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb
|
210
|
+
- spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb
|
211
|
+
- spec/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb
|
212
|
+
- spec/puppet-lint/plugins/check_strings/quoted_booleans_spec.rb
|
213
|
+
- spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb
|
214
|
+
- spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb
|
215
|
+
- spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb
|
216
|
+
- spec/puppet-lint/plugins/check_variables/variable_is_lowercase_spec.rb
|
217
|
+
- spec/puppet-lint/plugins/check_whitespace/140chars_spec.rb
|
218
|
+
- spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb
|
219
|
+
- spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb
|
220
|
+
- spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb
|
221
|
+
- spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb
|
222
|
+
- spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb
|
223
|
+
- spec/puppet-lint_spec.rb
|
224
|
+
- spec/spec_helper.rb
|