puppet-lint-strict_indent-check 3.0.0 → 4.0.0
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 +4 -4
- data/CHANGELOG.md +27 -0
- data/README.md +4 -1
- data/lib/puppet-lint/plugins/check_strict_indent.rb +87 -17
- data/spec/fixtures/fail/heredoc_interpolated_extra.pp +5 -0
- data/spec/fixtures/fail/heredoc_interpolated_insuficient.pp +5 -0
- data/spec/fixtures/pass/doubles.pp +13 -0
- data/spec/fixtures/pass/heredocclass.pp +31 -0
- data/spec/fixtures/pass/semicolon.pp +15 -0
- data/spec/puppet-lint/plugins/check_strict_indent_spec.rb +197 -2
- data/spec/spec_helper.rb +1 -24
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fb2ac311bc0d30ef09d5975e7160f31fa7ecbb67e8498a7359d6894c6816526
|
4
|
+
data.tar.gz: 66a1bbfc4c9e494a8923d19c18ed1905a58b2645b4d4d6a65844efda0b9e9897
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0ec808b887a1f2459be4d34ce2371210b990ffec3c78a58c4e5ce3c173bea8c267697e18c6d693acbcb4e7b5a0551496fc05d8f5c6762283e530716ad40d0d7
|
7
|
+
data.tar.gz: 493240b21f3ab3a1157851f3cb1377089a9ff60454200b7bf34c68fa22ba747dda05bd16f940254305460df78a276963a5cb31e40e5ae132afc79ebfa05baf6e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,33 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [4.0.0](https://github.com/voxpupuli/puppet-lint-strict_indent-check/tree/4.0.0) (2025-08-06)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-strict_indent-check/compare/3.0.0...4.0.0)
|
8
|
+
|
9
|
+
**Breaking changes:**
|
10
|
+
|
11
|
+
- Match the indent for a single semicolon with the Puppet documentation [\#48](https://github.com/voxpupuli/puppet-lint-strict_indent-check/pull/48) ([msalway](https://github.com/msalway))
|
12
|
+
- Only indent once for doubled brackets [\#44](https://github.com/voxpupuli/puppet-lint-strict_indent-check/pull/44) ([msalway](https://github.com/msalway))
|
13
|
+
|
14
|
+
**Fixed bugs:**
|
15
|
+
|
16
|
+
- Refactor heredoc indent calculations [\#47](https://github.com/voxpupuli/puppet-lint-strict_indent-check/pull/47) ([msalway](https://github.com/msalway))
|
17
|
+
|
18
|
+
**Closed issues:**
|
19
|
+
|
20
|
+
- Ruby 3.1 test fails due to double start of SimpleCov [\#45](https://github.com/voxpupuli/puppet-lint-strict_indent-check/issues/45)
|
21
|
+
- Test workflow fails [\#41](https://github.com/voxpupuli/puppet-lint-strict_indent-check/issues/41)
|
22
|
+
- Extra indent requested with two opens on same line. [\#21](https://github.com/voxpupuli/puppet-lint-strict_indent-check/issues/21)
|
23
|
+
- Update indent behaviour when semicolon is on a separate line [\#19](https://github.com/voxpupuli/puppet-lint-strict_indent-check/issues/19)
|
24
|
+
|
25
|
+
**Merged pull requests:**
|
26
|
+
|
27
|
+
- Update README for recent changes [\#49](https://github.com/voxpupuli/puppet-lint-strict_indent-check/pull/49) ([msalway](https://github.com/msalway))
|
28
|
+
- Remove SimpleCov.start as it is done by PuppetLint's spec\_helper [\#46](https://github.com/voxpupuli/puppet-lint-strict_indent-check/pull/46) ([msalway](https://github.com/msalway))
|
29
|
+
- fix rubocop [\#42](https://github.com/voxpupuli/puppet-lint-strict_indent-check/pull/42) ([paran1](https://github.com/paran1))
|
30
|
+
- Update voxpupuli-rubocop requirement from ~\> 1.1 to ~\> 2.0 [\#36](https://github.com/voxpupuli/puppet-lint-strict_indent-check/pull/36) ([dependabot[bot]](https://github.com/apps/dependabot))
|
31
|
+
|
5
32
|
## [3.0.0](https://github.com/voxpupuli/puppet-lint-strict_indent-check/tree/3.0.0) (2023-04-21)
|
6
33
|
|
7
34
|
[Full Changelog](https://github.com/voxpupuli/puppet-lint-strict_indent-check/compare/2.1.0...3.0.0)
|
data/README.md
CHANGED
@@ -35,12 +35,15 @@ puppet-lint -l chars_per_indent_4.rb puppet-mysql/manifests/init.pp
|
|
35
35
|
|
36
36
|
## Acceptable Identation
|
37
37
|
|
38
|
-
* indent should increase by one step the line after each opened brace (square, curly, paren)
|
38
|
+
* indent should increase by one step the line after each opened brace (square, curly, paren).
|
39
39
|
* indent should decrease by one step the line of every closed brace.
|
40
|
+
* if multiple pairs of braces are opened and closed on the same two lines the indent should only increase once.
|
40
41
|
* indent should increase by one step the line after a resource title, unless it already increased due to a bracket.
|
41
42
|
* indent should decrease by one step the line after the end of a resource due to semicolon, if it was indented for resource title.
|
43
|
+
* if the semicolon is the only element on the line then the indent decreases on the semicolon line instead of the line after.
|
42
44
|
* indent should decrease by one step the line of the end of a resource due to right curly brace, if it was indented for resource title, and not ended by a semicolon.
|
43
45
|
* indent should increase by one step the line after an equals `=` or farrow `=>` that ends a line, but only for that one line.
|
46
|
+
* heredoc contents should be indented by one step.
|
44
47
|
|
45
48
|
see `spec/fixtures/pass/` for good indentation examples.
|
46
49
|
|
@@ -7,22 +7,19 @@ PuppetLint.new_check(:strict_indent) do
|
|
7
7
|
RBRACE: :LBRACE,
|
8
8
|
RBRACK: :LBRACK,
|
9
9
|
RPAREN: :LPAREN,
|
10
|
-
HEREDOC: :HEREDOC_OPEN,
|
11
|
-
HEREDOC_POST: :HEREDOC_OPEN,
|
12
10
|
}
|
13
11
|
open = {
|
14
12
|
LBRACE: [],
|
15
13
|
LBRACK: [],
|
16
14
|
LPAREN: [],
|
17
|
-
HEREDOC_OPEN: [],
|
18
15
|
}
|
19
16
|
|
20
17
|
matches = {}
|
21
18
|
|
22
19
|
tokens.each do |token|
|
23
|
-
if %i[LBRACE LBRACK LPAREN
|
20
|
+
if %i[LBRACE LBRACK LPAREN].include?(token.type)
|
24
21
|
open[token.type] << token
|
25
|
-
elsif %i[RBRACE RBRACK RPAREN
|
22
|
+
elsif %i[RBRACE RBRACK RPAREN].include?(token.type)
|
26
23
|
match = open[opening_token[token.type]].pop
|
27
24
|
unless match.nil?
|
28
25
|
matches[token] = match
|
@@ -49,15 +46,20 @@ PuppetLint.new_check(:strict_indent) do
|
|
49
46
|
end.each do |token|
|
50
47
|
temp_indent = 0
|
51
48
|
|
49
|
+
matched_open_lines = []
|
52
50
|
# indent for open groups in the previous line
|
53
51
|
open_groups = 0
|
54
52
|
prev_token = token.prev_token
|
55
53
|
while !prev_token.nil? and prev_token.type != :NEWLINE
|
56
54
|
temp_indent += 1 if prev_token.type == :HEREDOC_OPEN
|
57
|
-
if %i[LBRACE LBRACK
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
if %i[LBRACE LBRACK LPAREN].include?(prev_token.type)
|
56
|
+
if matches[prev_token].nil?
|
57
|
+
open_groups += 1
|
58
|
+
elsif matches[prev_token].line > prev_token.line and !matched_open_lines.include?(matches[prev_token].line)
|
59
|
+
# increase indent for left braces not matched in the same line or in a line we have already matched a brace to
|
60
|
+
open_groups += 1
|
61
|
+
matched_open_lines << matches[prev_token].line
|
62
|
+
end
|
61
63
|
end
|
62
64
|
prev_token = prev_token.prev_token
|
63
65
|
end
|
@@ -96,17 +98,27 @@ PuppetLint.new_check(:strict_indent) do
|
|
96
98
|
|
97
99
|
# unindent for closing brackets in the current line
|
98
100
|
next_token = token.next_token
|
101
|
+
matched_close_lines = []
|
99
102
|
while !next_token.nil? and next_token.type != :NEWLINE
|
100
103
|
if %i[RBRACE RBRACK RPAREN].include?(next_token.type)
|
101
|
-
if !matches[next_token].nil? and
|
102
|
-
|
104
|
+
if !matches[next_token].nil? and
|
105
|
+
matches[next_token].line < next_token.line and
|
106
|
+
!matched_close_lines.include?(matches[next_token].line)
|
107
|
+
# right braces matched in a previous line decrease indent unless we already matched a brace in the same line
|
103
108
|
indent -= 1
|
109
|
+
matched_close_lines << matches[next_token].line
|
104
110
|
end
|
105
111
|
if next_token.type == :RBRACE and !colon_indent.nil? && (!matches[next_token].nil? and matches[next_token].line < colon_indent)
|
106
112
|
# unindent at the end of resources if needed
|
107
113
|
indent -= 1
|
108
114
|
colon_indent = nil
|
109
115
|
end
|
116
|
+
elsif next_token.type == :SEMIC and !colon_indent.nil? and
|
117
|
+
%i[INDENT NEWLINE].include?(next_token.prev_token.type) and
|
118
|
+
(next_token.next_token.nil? or next_token.next_token.type == :NEWLINE)
|
119
|
+
# For a lone semicolon within a block decrement immediately. Use temp_indent because
|
120
|
+
# indent will be decremented in the next line by the prev_token logic above.
|
121
|
+
temp_indent -= 1
|
110
122
|
end
|
111
123
|
next_token = next_token.next_token
|
112
124
|
end
|
@@ -123,13 +135,31 @@ PuppetLint.new_check(:strict_indent) do
|
|
123
135
|
end
|
124
136
|
|
125
137
|
# get actual indent
|
126
|
-
actual =
|
127
|
-
|
138
|
+
actual = case token.next_token.type
|
139
|
+
when :INDENT
|
128
140
|
token.next_token.value.length
|
129
|
-
|
130
|
-
token.
|
131
|
-
|
132
|
-
|
141
|
+
when :HEREDOC
|
142
|
+
# Lines containing heredocs have no indent token as the indent is consumed by the heredoc token.
|
143
|
+
# However the last line of the token value is the whitespace before the pipe in the termination line.
|
144
|
+
# We use the length of this to get the indent.
|
145
|
+
if token.next_token.value.end_with?("\n")
|
146
|
+
0
|
147
|
+
else
|
148
|
+
token.next_token.value.split("\n").last.length
|
149
|
+
end
|
150
|
+
when :HEREDOC_PRE
|
151
|
+
# For interpolated heredocs the pipe whitespace is in the HEREDOC_POST token so we need scan forward
|
152
|
+
# to this and get its length.
|
153
|
+
next_token = token.next_token
|
154
|
+
while !next_token.nil? and next_token.type != :NEWLINE and next_token.type != :HEREDOC_POST
|
155
|
+
next_token = next_token.next_token
|
156
|
+
end
|
157
|
+
if next_token.type == :HEREDOC_POST
|
158
|
+
next_token.value.split("\n").last.length
|
159
|
+
else
|
160
|
+
# Should never get here return zero if we do
|
161
|
+
0
|
162
|
+
end
|
133
163
|
else
|
134
164
|
0
|
135
165
|
end
|
@@ -149,6 +179,7 @@ PuppetLint.new_check(:strict_indent) do
|
|
149
179
|
column: token.next_token.column,
|
150
180
|
token: token.next_token,
|
151
181
|
indent: expected,
|
182
|
+
actual: actual,
|
152
183
|
}
|
153
184
|
end
|
154
185
|
end
|
@@ -157,6 +188,18 @@ PuppetLint.new_check(:strict_indent) do
|
|
157
188
|
char_for_indent = ' '
|
158
189
|
if %i[INDENT WHITESPACE].include?(problem[:token].type)
|
159
190
|
problem[:token].value = char_for_indent * problem[:indent]
|
191
|
+
elsif problem[:token].type == :HEREDOC
|
192
|
+
change = problem[:indent] - problem[:actual]
|
193
|
+
indent_heredoc(problem[:token], change)
|
194
|
+
elsif problem[:token].type == :HEREDOC_PRE
|
195
|
+
change = problem[:indent] - problem[:actual]
|
196
|
+
indent_heredoc(problem[:token], change)
|
197
|
+
next_token = problem[:token].next_token
|
198
|
+
while !next_token.nil? and next_token.type != :HEREDOC_POST
|
199
|
+
indent_heredoc(next_token, change) if next_token.type == :HEREDOC_MID
|
200
|
+
next_token = next_token.next_token
|
201
|
+
end
|
202
|
+
indent_heredoc(next_token, change) if next_token.type == :HEREDOC_POST
|
160
203
|
else
|
161
204
|
tokens.insert(
|
162
205
|
tokens.find_index(problem[:token]),
|
@@ -164,4 +207,31 @@ PuppetLint.new_check(:strict_indent) do
|
|
164
207
|
)
|
165
208
|
end
|
166
209
|
end
|
210
|
+
|
211
|
+
def map_heredoc_lines(value, change, skip)
|
212
|
+
char_for_indent = ' '
|
213
|
+
value.split("\n").map! do |line|
|
214
|
+
if skip or line.empty?
|
215
|
+
skip = false
|
216
|
+
line
|
217
|
+
elsif change < 0
|
218
|
+
line[-change..]
|
219
|
+
else
|
220
|
+
(char_for_indent * change) + line
|
221
|
+
end
|
222
|
+
end.join("\n")
|
223
|
+
end
|
224
|
+
|
225
|
+
def indent_heredoc(token, change)
|
226
|
+
case token.type
|
227
|
+
when :HEREDOC
|
228
|
+
token.raw = map_heredoc_lines(token.raw, change, false)
|
229
|
+
when :HEREDOC_PRE
|
230
|
+
token.value = map_heredoc_lines(token.value, change, false)
|
231
|
+
when :HEREDOC_MID
|
232
|
+
token.value = map_heredoc_lines(token.value, change, true)
|
233
|
+
when :HEREDOC_POST
|
234
|
+
token.raw = map_heredoc_lines(token.raw, change, true)
|
235
|
+
end
|
236
|
+
end
|
167
237
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Tests for heredocs within class
|
2
|
+
class 'heredocclass' {
|
3
|
+
file { '/heredoc/file/resource/without/comma':
|
4
|
+
content => @(HERE)
|
5
|
+
This is a here doc
|
6
|
+
with two lines
|
7
|
+
| HERE
|
8
|
+
}
|
9
|
+
|
10
|
+
file { '/heredoc/file/resource/with/comma':
|
11
|
+
content => @(HERE),
|
12
|
+
This is a here doc
|
13
|
+
with two lines
|
14
|
+
| HERE
|
15
|
+
}
|
16
|
+
|
17
|
+
file { '/heredoc/in/function/in/file/resource':
|
18
|
+
content => inlineepp(@(HERE)),
|
19
|
+
This is a here doc
|
20
|
+
with two lines
|
21
|
+
| HERE
|
22
|
+
}
|
23
|
+
|
24
|
+
$variable_with_interpolation = @("EOT")
|
25
|
+
Another example
|
26
|
+
${variable}
|
27
|
+
with
|
28
|
+
${variable}
|
29
|
+
with interpolation
|
30
|
+
| EOT
|
31
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
file {
|
2
|
+
default:
|
3
|
+
ensure => file,
|
4
|
+
owner => 'root',
|
5
|
+
group => 'wheel',
|
6
|
+
mode => '0600',
|
7
|
+
;
|
8
|
+
['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
|
9
|
+
# use all defaults
|
10
|
+
;
|
11
|
+
['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
|
12
|
+
# override mode
|
13
|
+
mode => '0644',
|
14
|
+
;
|
15
|
+
}
|
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
# rubocop:disable Lint/RedundantRequireStatement
|
3
|
+
require 'pp'
|
4
|
+
# rubocop:enable Lint/RedundantRequireStatement
|
2
5
|
|
3
6
|
describe 'strict_indent' do
|
4
7
|
before do
|
@@ -6,7 +9,7 @@ describe 'strict_indent' do
|
|
6
9
|
PuppetLint.configuration.checks.reject do |check|
|
7
10
|
check == :indent
|
8
11
|
end.each do |check|
|
9
|
-
PuppetLint.configuration.send("disable_#{check}")
|
12
|
+
PuppetLint.configuration.send(:"disable_#{check}")
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
@@ -15,7 +18,7 @@ describe 'strict_indent' do
|
|
15
18
|
PuppetLint.configuration.checks.reject do |check|
|
16
19
|
check == :indent
|
17
20
|
end.each do |check|
|
18
|
-
PuppetLint.configuration.send("enable_#{check}")
|
21
|
+
PuppetLint.configuration.send(:"enable_#{check}")
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
@@ -90,4 +93,196 @@ describe 'strict_indent' do
|
|
90
93
|
expect(problems).to have(0).problems
|
91
94
|
end
|
92
95
|
end
|
96
|
+
|
97
|
+
context 'misplaced resource semicolons' do
|
98
|
+
before do
|
99
|
+
PuppetLint.configuration.fix = true
|
100
|
+
end
|
101
|
+
|
102
|
+
after do
|
103
|
+
PuppetLint.configuration.fix = false
|
104
|
+
end
|
105
|
+
|
106
|
+
let(:code) do
|
107
|
+
<<~EOF
|
108
|
+
file {
|
109
|
+
default:
|
110
|
+
ensure => file,
|
111
|
+
owner => 'root',
|
112
|
+
group => 'wheel',
|
113
|
+
mode => '0600',
|
114
|
+
;
|
115
|
+
['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
|
116
|
+
# use all defaults
|
117
|
+
;
|
118
|
+
['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
|
119
|
+
# override mode
|
120
|
+
mode => '0644',
|
121
|
+
;
|
122
|
+
}
|
123
|
+
EOF
|
124
|
+
end
|
125
|
+
|
126
|
+
let(:fixed) do
|
127
|
+
<<~EOF
|
128
|
+
file {
|
129
|
+
default:
|
130
|
+
ensure => file,
|
131
|
+
owner => 'root',
|
132
|
+
group => 'wheel',
|
133
|
+
mode => '0600',
|
134
|
+
;
|
135
|
+
['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
|
136
|
+
# use all defaults
|
137
|
+
;
|
138
|
+
['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
|
139
|
+
# override mode
|
140
|
+
mode => '0644',
|
141
|
+
;
|
142
|
+
}
|
143
|
+
EOF
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'detects three problems' do
|
147
|
+
expect(problems).to have(3).problem
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'fixes the first problem' do
|
151
|
+
expect(problems).to contain_fixed('indent should be 2 chars and is 4').on_line(7).in_column(1)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'fixes the second problem' do
|
155
|
+
expect(problems).to contain_fixed('indent should be 2 chars and is 4').on_line(10).in_column(1)
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'fixes the third problem' do
|
159
|
+
expect(problems).to contain_fixed('indent should be 2 chars and is 0').on_line(14).in_column(1)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'moves the semicolons' do
|
163
|
+
expect(manifest).to eq fixed
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
context 'misaligned heredocs' do
|
168
|
+
before do
|
169
|
+
PuppetLint.configuration.fix = true
|
170
|
+
end
|
171
|
+
|
172
|
+
after do
|
173
|
+
PuppetLint.configuration.fix = false
|
174
|
+
end
|
175
|
+
|
176
|
+
let(:code) do
|
177
|
+
<<~EOF
|
178
|
+
$over_indented = @(HERE)
|
179
|
+
This is a heredoc
|
180
|
+
that has been
|
181
|
+
|
182
|
+
indented 4 spaces
|
183
|
+
and has some
|
184
|
+
internal indenting
|
185
|
+
| HERE
|
186
|
+
|
187
|
+
$under_indented = @(HERE)
|
188
|
+
This is a heredoc
|
189
|
+
|
190
|
+
that has no
|
191
|
+
indent
|
192
|
+
and has some
|
193
|
+
internal indenting
|
194
|
+
| HERE
|
195
|
+
|
196
|
+
$over_indented_interpolated = @("HERE")
|
197
|
+
This is a heredoc
|
198
|
+
with a ${variable}
|
199
|
+
that has been
|
200
|
+
|
201
|
+
indented 4 spaces
|
202
|
+
and has some
|
203
|
+
internal indenting
|
204
|
+
and ${another} variable
|
205
|
+
| HERE
|
206
|
+
|
207
|
+
$under_indented_interpolated = @("HERE")
|
208
|
+
This is a heredoc
|
209
|
+
with a ${variable} with trailing text
|
210
|
+
that has been
|
211
|
+
|
212
|
+
indented 1 space
|
213
|
+
and has some
|
214
|
+
internal indenting
|
215
|
+
and ${another} variable
|
216
|
+
| HERE
|
217
|
+
EOF
|
218
|
+
end
|
219
|
+
|
220
|
+
let(:fixed) do
|
221
|
+
<<~EOF
|
222
|
+
$over_indented = @(HERE)
|
223
|
+
This is a heredoc
|
224
|
+
that has been
|
225
|
+
|
226
|
+
indented 4 spaces
|
227
|
+
and has some
|
228
|
+
internal indenting
|
229
|
+
| HERE
|
230
|
+
|
231
|
+
$under_indented = @(HERE)
|
232
|
+
This is a heredoc
|
233
|
+
|
234
|
+
that has no
|
235
|
+
indent
|
236
|
+
and has some
|
237
|
+
internal indenting
|
238
|
+
| HERE
|
239
|
+
|
240
|
+
$over_indented_interpolated = @("HERE")
|
241
|
+
This is a heredoc
|
242
|
+
with a ${variable}
|
243
|
+
that has been
|
244
|
+
|
245
|
+
indented 4 spaces
|
246
|
+
and has some
|
247
|
+
internal indenting
|
248
|
+
and ${another} variable
|
249
|
+
| HERE
|
250
|
+
|
251
|
+
$under_indented_interpolated = @("HERE")
|
252
|
+
This is a heredoc
|
253
|
+
with a ${variable} with trailing text
|
254
|
+
that has been
|
255
|
+
|
256
|
+
indented 1 space
|
257
|
+
and has some
|
258
|
+
internal indenting
|
259
|
+
and ${another} variable
|
260
|
+
| HERE
|
261
|
+
EOF
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'detects four problems' do
|
265
|
+
expect(problems).to have(4).problem
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'fixes the first problem' do
|
269
|
+
expect(problems).to contain_fixed('indent should be 2 chars and is 4').on_line(2).in_column(1)
|
270
|
+
end
|
271
|
+
|
272
|
+
it 'fixes the second problem' do
|
273
|
+
expect(problems).to contain_fixed('indent should be 2 chars and is 0').on_line(11).in_column(1)
|
274
|
+
end
|
275
|
+
|
276
|
+
it 'fixes the third problem' do
|
277
|
+
expect(problems).to contain_fixed('indent should be 2 chars and is 4').on_line(20).in_column(1)
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'fixes the forth problem' do
|
281
|
+
expect(problems).to contain_fixed('indent should be 2 chars and is 1').on_line(31).in_column(1)
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'moves the heredoc' do
|
285
|
+
expect(manifest).to eq fixed
|
286
|
+
end
|
287
|
+
end
|
93
288
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,29 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
begin
|
4
|
-
require 'simplecov'
|
5
|
-
require 'simplecov-console'
|
6
|
-
require 'codecov'
|
7
|
-
rescue LoadError
|
8
|
-
else
|
9
|
-
SimpleCov.start do
|
10
|
-
track_files 'lib/**/*.rb'
|
11
|
-
|
12
|
-
add_filter '/spec'
|
13
|
-
|
14
|
-
enable_coverage :branch
|
15
|
-
|
16
|
-
# do not track vendored files
|
17
|
-
add_filter '/vendor'
|
18
|
-
add_filter '/.vendor'
|
19
|
-
end
|
20
|
-
|
21
|
-
SimpleCov.formatters = [
|
22
|
-
SimpleCov::Formatter::Console,
|
23
|
-
SimpleCov::Formatter::Codecov,
|
24
|
-
]
|
25
|
-
end
|
26
|
-
|
27
3
|
require 'puppet-lint'
|
4
|
+
require 'rspec/collection_matchers'
|
28
5
|
|
29
6
|
PuppetLint::Plugins.load_spec_helper
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-strict_indent-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vox Pupuli
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -43,16 +43,21 @@ files:
|
|
43
43
|
- lib/puppet-lint/plugins/check_strict_indent.rb
|
44
44
|
- spec/fixtures/fail/1.pp
|
45
45
|
- spec/fixtures/fail/heredoc_extra.pp
|
46
|
+
- spec/fixtures/fail/heredoc_interpolated_extra.pp
|
47
|
+
- spec/fixtures/fail/heredoc_interpolated_insuficient.pp
|
46
48
|
- spec/fixtures/fail/heredoc_unsuficient.pp
|
47
49
|
- spec/fixtures/pass/1.pp
|
50
|
+
- spec/fixtures/pass/doubles.pp
|
48
51
|
- spec/fixtures/pass/heredoc.pp
|
52
|
+
- spec/fixtures/pass/heredocclass.pp
|
53
|
+
- spec/fixtures/pass/semicolon.pp
|
49
54
|
- spec/puppet-lint/plugins/check_strict_indent_spec.rb
|
50
55
|
- spec/spec_helper.rb
|
51
56
|
homepage: https://github.com/voxpupuli/puppet-lint-strict_indent-check
|
52
57
|
licenses:
|
53
58
|
- MPL-2.0
|
54
59
|
metadata: {}
|
55
|
-
post_install_message:
|
60
|
+
post_install_message:
|
56
61
|
rdoc_options: []
|
57
62
|
require_paths:
|
58
63
|
- lib
|
@@ -68,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
73
|
version: '0'
|
69
74
|
requirements: []
|
70
75
|
rubygems_version: 3.2.33
|
71
|
-
signing_key:
|
76
|
+
signing_key:
|
72
77
|
specification_version: 4
|
73
78
|
summary: puppet-lint strict indent check
|
74
79
|
test_files: []
|