puppet-lint-trailing_comma-check 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NGRlYjY3ODg3NjAzZTM4YmNjM2JiNWM3ZGExZTJmYWUxMmY4NTAwZA==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54c8aa1aee4468b15ba95fb44d739f5bf8cb7aa6701d2ef356b6fac6521c586c
|
4
|
+
data.tar.gz: 4d7d7d5e31bb93253e68421761f2f949d03123bbedb7c75aba7b6a2037503a6e
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YzJhY2ZlZDBiNDE2NTZlOWY3ZDQ4MDdjYzdlZjAzOGVkYmI1MzA2NWEyYTBl
|
11
|
-
OTMwMWZhNzc2NDUwZTdlOGY3MDU3Yzg2ZWFhYjk5NDk5NGMwNTM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OTEwNDY2YjEwMjIwMzIxZWJjN2ExZjkwZDM4MTUzMTRkYWFkZmFmYjEwYmVm
|
14
|
-
MzAwZmM3NjQwYmZjMTAwNzY2NzJiYmEwMjg0MmY5MjQwOTEyMTk1YzhjMjZl
|
15
|
-
MzY2NzhmYzc5M2ExZGY4ZTZlMjJiZDAwYzEzOWE3OGEzNjU3YWI=
|
6
|
+
metadata.gz: fdf70e104a01928c9eafdc0c71d7fc866552d4e8db6fcbf72403e93120f3c918bcf2321abca54051a8c3f0f290b1ede13482aab9b7b5293cbb374dd149bff226
|
7
|
+
data.tar.gz: dbb02bce63093fa298adbf933e16f06de60a10e6030b2931957110b3f8c5680a4bc62acb5ae0fb3fd229a406ebee107171ebf5f54e63130c06dd671fbb3d723a
|
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
puppet-lint-trailing_comma-check
|
2
2
|
=================================
|
3
3
|
|
4
|
-
[![
|
4
|
+
[![License](https://img.shields.io/github/license/voxpupuli/puppet-lint-trailing_comma-check.svg)](https://github.com/voxpupuli/puppet-lint-trailing_comma-check/blob/master/LICENSE)
|
5
|
+
[![Build Status](https://img.shields.io/travis/voxpupuli/puppet-lint-trailing_comma-check.svg)](https://travis-ci.org/voxpupuli/puppet-lint-trailing_comma-check)
|
5
6
|
[![Gem Version](https://img.shields.io/gem/v/puppet-lint-trailing_comma-check.svg)](https://rubygems.org/gems/puppet-lint-trailing_comma-check)
|
6
7
|
[![Gem Downloads](https://img.shields.io/gem/dt/puppet-lint-trailing_comma-check.svg)](https://rubygems.org/gems/puppet-lint-trailing_comma-check)
|
7
|
-
[![Coverage Status](https://
|
8
|
-
[![
|
8
|
+
[![Coverage Status](https://coveralls.io/repos/github/voxpupuli/puppet-lint-trailing_comma-check/badge.svg?branch=master)](https://coveralls.io/github/voxpupuli/puppet-lint-trailing_comma-check?branch=master)
|
9
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/voxpupuli/puppet-lint-trailing_comma-check.svg)](https://gemnasium.com/github.com/voxpupuli/puppet-lint-trailing_comma-check)
|
9
10
|
[![Donated by Camptocamp](https://img.shields.io/badge/donated%20by-camptocamp-fb7047.svg)](#transfer-notice)
|
10
11
|
|
11
12
|
A puppet-lint plugin to check for missing trailing commas.
|
@@ -57,7 +57,12 @@ PuppetLint.new_check(:trailing_comma) do
|
|
57
57
|
defaults = []
|
58
58
|
tokens.each_with_index do |token, token_idx|
|
59
59
|
if token.type == :CLASSREF && token.next_code_token && \
|
60
|
-
token.next_code_token.type == :LBRACE
|
60
|
+
token.next_code_token.type == :LBRACE && \
|
61
|
+
token.prev_code_token && \
|
62
|
+
# Ensure that we aren't matching a function return type:
|
63
|
+
token.prev_code_token.type != :RSHIFT && \
|
64
|
+
# Or a conditional matching a type:
|
65
|
+
token.prev_code_token.type != :MATCH
|
61
66
|
real_idx = 0
|
62
67
|
|
63
68
|
tokens[token_idx+1..-1].each_with_index do |cur_token, cur_token_idx|
|
@@ -81,6 +86,7 @@ PuppetLint.new_check(:trailing_comma) do
|
|
81
86
|
if lbo_token && lbo_token.type != except_type && \
|
82
87
|
elem[:tokens][-1].type != :SEMIC && \
|
83
88
|
lbo_token.type != :COMMA && \
|
89
|
+
lbo_token.type != :HEREDOC && \
|
84
90
|
lbo_token.next_token.type == :NEWLINE
|
85
91
|
notify :warning, {
|
86
92
|
:message => 'missing trailing comma after last element',
|
@@ -89,6 +95,17 @@ PuppetLint.new_check(:trailing_comma) do
|
|
89
95
|
:token => lbo_token.next_token,
|
90
96
|
}
|
91
97
|
end
|
98
|
+
if lbo_token && lbo_token.type == :HEREDOC && \
|
99
|
+
lbo_token.prev_code_token.type != :COMMA && \
|
100
|
+
lbo_token.prev_code_token.next_token.type == :NEWLINE
|
101
|
+
notify :warning, {
|
102
|
+
:message => 'missing trailing comma after last element',
|
103
|
+
:line => lbo_token.prev_code_token.next_token.line,
|
104
|
+
:column => lbo_token.prev_code_token.next_token.column,
|
105
|
+
:token => lbo_token.prev_code_token.next_token,
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
92
109
|
end
|
93
110
|
|
94
111
|
def check
|
@@ -55,6 +55,17 @@ describe 'trailing_comma' do
|
|
55
55
|
'/etc/baz.conf', '/etc/baz.conf.d'
|
56
56
|
],
|
57
57
|
}
|
58
|
+
|
59
|
+
function myfunc (
|
60
|
+
Mymod::Mytype $arg1,
|
61
|
+
String[1] $arg2,
|
62
|
+
) >> Mymod::Mytype {
|
63
|
+
notice('foo')
|
64
|
+
}
|
65
|
+
|
66
|
+
if $var =~ Sensitive {
|
67
|
+
$foo = $var.unwrap
|
68
|
+
}
|
58
69
|
EOS
|
59
70
|
}
|
60
71
|
|
@@ -130,6 +141,48 @@ describe 'trailing_comma' do
|
|
130
141
|
expect(problems).to contain_warning(msg).on_line(41).in_column(25)
|
131
142
|
end
|
132
143
|
end
|
144
|
+
|
145
|
+
context 'with heredoc' do
|
146
|
+
context 'with trailing comma' do
|
147
|
+
let(:code) {
|
148
|
+
<<-EOS
|
149
|
+
file { '/tmp/test.txt':
|
150
|
+
ensure => 'file',
|
151
|
+
content => @(EOT),
|
152
|
+
Hello
|
153
|
+
World
|
154
|
+
EOT
|
155
|
+
}
|
156
|
+
EOS
|
157
|
+
}
|
158
|
+
|
159
|
+
it 'should not detect any problems' do
|
160
|
+
expect(problems).to have(0).problems
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'without trailing comma' do
|
165
|
+
let(:code) {
|
166
|
+
<<-EOS
|
167
|
+
file { '/tmp/test.txt':
|
168
|
+
ensure => 'file',
|
169
|
+
content => @(EOT)
|
170
|
+
Hello
|
171
|
+
World
|
172
|
+
EOT
|
173
|
+
}
|
174
|
+
EOS
|
175
|
+
}
|
176
|
+
|
177
|
+
it 'should detect a problem' do
|
178
|
+
expect(problems).to have(1).problems
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should create a warning' do
|
182
|
+
expect(problems).to contain_warning(msg).on_line(3).in_column(30)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
133
186
|
end
|
134
187
|
|
135
188
|
context 'with fix enabled' do
|
@@ -326,5 +379,65 @@ describe 'trailing_comma' do
|
|
326
379
|
)
|
327
380
|
end
|
328
381
|
end
|
382
|
+
|
383
|
+
context 'with heredoc' do
|
384
|
+
context 'with trailing comma' do
|
385
|
+
let(:code) {
|
386
|
+
<<-EOS
|
387
|
+
file { '/tmp/test.txt':
|
388
|
+
ensure => 'file',
|
389
|
+
content => @(EOT),
|
390
|
+
Hello
|
391
|
+
World
|
392
|
+
EOT
|
393
|
+
}
|
394
|
+
EOS
|
395
|
+
}
|
396
|
+
|
397
|
+
it 'should not detect any problems' do
|
398
|
+
expect(problems).to have(0).problems
|
399
|
+
end
|
400
|
+
|
401
|
+
it 'should not modify the manifest' do
|
402
|
+
expect(manifest).to eq(code)
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
context 'without trailing comma' do
|
407
|
+
let(:code) {
|
408
|
+
<<-EOS
|
409
|
+
file { '/tmp/test.txt':
|
410
|
+
ensure => 'file',
|
411
|
+
content => @(EOT)
|
412
|
+
Hello
|
413
|
+
World
|
414
|
+
EOT
|
415
|
+
}
|
416
|
+
EOS
|
417
|
+
}
|
418
|
+
|
419
|
+
it 'should detect a problem' do
|
420
|
+
expect(problems).to have(1).problems
|
421
|
+
end
|
422
|
+
|
423
|
+
it 'should create a warning' do
|
424
|
+
expect(problems).to contain_fixed(msg).on_line(3).in_column(30)
|
425
|
+
end
|
426
|
+
|
427
|
+
it 'should add trailing commas' do
|
428
|
+
expect(manifest).to eq(
|
429
|
+
<<-EOS
|
430
|
+
file { '/tmp/test.txt':
|
431
|
+
ensure => 'file',
|
432
|
+
content => @(EOT),
|
433
|
+
Hello
|
434
|
+
World
|
435
|
+
EOT
|
436
|
+
}
|
437
|
+
EOS
|
438
|
+
)
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
329
442
|
end
|
330
443
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,122 +1,121 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-trailing_comma-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Community
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
|
-
- - <
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.0'
|
30
|
-
- - <
|
30
|
+
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '3.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rspec
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - ~>
|
37
|
+
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '3.0'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - ~>
|
44
|
+
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '3.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec-its
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - ~>
|
51
|
+
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '1.0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - ~>
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '1.0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rspec-collection_matchers
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - ~>
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '1.0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - ~>
|
72
|
+
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '1.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: mime-types
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
88
|
+
version: '0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: coveralls
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '0
|
95
|
+
version: '0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- -
|
100
|
+
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0
|
102
|
+
version: '0'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rake
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
-
description:
|
118
|
-
|
119
|
-
'
|
117
|
+
description: |2
|
118
|
+
A puppet-lint plugin to check for missing trailing commas.
|
120
119
|
email: raphael.pinson@camptocamp.com
|
121
120
|
executables: []
|
122
121
|
extensions: []
|
@@ -127,7 +126,7 @@ files:
|
|
127
126
|
- lib/puppet-lint/plugins/check_trailing_comma.rb
|
128
127
|
- spec/puppet-lint/plugins/check_trailing_comma/check_trailing_comma_spec.rb
|
129
128
|
- spec/spec_helper.rb
|
130
|
-
homepage: https://github.com/
|
129
|
+
homepage: https://github.com/voxpupuli/puppet-lint-trailing_comma-check
|
131
130
|
licenses:
|
132
131
|
- Apache-2.0
|
133
132
|
metadata: {}
|
@@ -137,17 +136,17 @@ require_paths:
|
|
137
136
|
- lib
|
138
137
|
required_ruby_version: !ruby/object:Gem::Requirement
|
139
138
|
requirements:
|
140
|
-
- -
|
139
|
+
- - ">="
|
141
140
|
- !ruby/object:Gem::Version
|
142
|
-
version: '0'
|
141
|
+
version: '2.0'
|
143
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
143
|
requirements:
|
145
|
-
- -
|
144
|
+
- - ">="
|
146
145
|
- !ruby/object:Gem::Version
|
147
146
|
version: '0'
|
148
147
|
requirements: []
|
149
148
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.7.7
|
151
150
|
signing_key:
|
152
151
|
specification_version: 4
|
153
152
|
summary: A puppet-lint plugin to check for missing trailing commas.
|