puppet-lint-manifest_whitespace-check 0.1.7 → 0.1.8
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 282678f99caeebc548db24014520b89900f3d22430a4c906403958da93701a48
|
4
|
+
data.tar.gz: d37219ad94c7775cdff3eb830c984e71393d0a65369a1262ddf1a284755906d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e563b17a5038ec4e352a504c63ef36674c15cb686a889674ab2b988aeade047ad400bf5e769dd280ab757d3bf1dfa85b07cb46f2323b306fc9ad63755507ae9
|
7
|
+
data.tar.gz: e9ebb4a5ebacb1a69fdff632dde3cf6d91a9abd8d38bdc667aa41c3e2c47dda181de02385d03dc408a56bcec9f6f5a60743541aec37eecf1061bbe695d5cc591
|
@@ -36,13 +36,13 @@ PuppetLint.new_check(:manifest_whitespace_class_name_single_space_after) do
|
|
36
36
|
next unless name_token
|
37
37
|
|
38
38
|
next_token = name_token.next_token
|
39
|
-
|
40
|
-
next unless tokens.index(name_token) != tokens.index(
|
39
|
+
next_code_token = next_non_space_token(name_token)
|
40
|
+
next unless tokens.index(name_token) != tokens.index(next_code_token) - 2 ||
|
41
41
|
!is_single_space(next_token)
|
42
42
|
|
43
43
|
notify(
|
44
44
|
:error,
|
45
|
-
message: 'there should be a single space between the class or resource name and the
|
45
|
+
message: 'there should be a single space between the class or resource name and the next item',
|
46
46
|
line: next_token.line,
|
47
47
|
column: next_token.column,
|
48
48
|
token: next_token,
|
@@ -52,22 +52,13 @@ PuppetLint.new_check(:manifest_whitespace_class_name_single_space_after) do
|
|
52
52
|
|
53
53
|
def fix(problem)
|
54
54
|
token = problem[:token]
|
55
|
-
|
56
|
-
|
57
|
-
if token == brace_token
|
58
|
-
add_token(tokens.index(brace_token), new_single_space)
|
59
|
-
return
|
60
|
-
end
|
61
|
-
|
62
|
-
while token != brace_token
|
63
|
-
unless %i[WHITESPACE INDENT NEWLINE].include?(token.type)
|
64
|
-
raise PuppetLint::NoFix
|
65
|
-
end
|
55
|
+
next_code_token = next_non_space_token(token.prev_token)
|
66
56
|
|
57
|
+
while token != next_code_token
|
67
58
|
remove_token(token)
|
68
59
|
token = token.next_token
|
69
60
|
end
|
70
61
|
|
71
|
-
add_token(tokens.index(
|
62
|
+
add_token(tokens.index(next_code_token), new_single_space)
|
72
63
|
end
|
73
64
|
end
|
@@ -66,10 +66,34 @@ describe 'manifest_whitespace_class_name_single_space_before' do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
+
|
70
|
+
context 'with inherits' do
|
71
|
+
let(:code) do
|
72
|
+
'class example inherits otherexample {'
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should detect no problems' do
|
76
|
+
expect(problems).to have(0).problem
|
77
|
+
end
|
78
|
+
end
|
69
79
|
end
|
70
80
|
|
71
81
|
describe 'manifest_whitespace_class_name_single_space_after' do
|
72
|
-
let(:single_space_msg) { 'there should be a single space between the class or resource name and the
|
82
|
+
let(:single_space_msg) { 'there should be a single space between the class or resource name and the next item' }
|
83
|
+
|
84
|
+
context 'with inherits' do
|
85
|
+
let(:code) do
|
86
|
+
<<~EOF
|
87
|
+
class example inherits otherexample {
|
88
|
+
assert_private()
|
89
|
+
}
|
90
|
+
EOF
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should detect no problems' do
|
94
|
+
expect(problems).to have(0).problem
|
95
|
+
end
|
96
|
+
end
|
73
97
|
|
74
98
|
context 'with parameters and no spaces' do
|
75
99
|
let(:code) do
|
@@ -405,32 +429,8 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
405
429
|
EOF
|
406
430
|
end
|
407
431
|
|
408
|
-
|
409
|
-
|
410
|
-
expect(problems).to have(1).problem
|
411
|
-
end
|
412
|
-
|
413
|
-
it 'should create a error' do
|
414
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(14)
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
context 'with fix enabled' do
|
419
|
-
before do
|
420
|
-
PuppetLint.configuration.fix = true
|
421
|
-
end
|
422
|
-
|
423
|
-
after do
|
424
|
-
PuppetLint.configuration.fix = false
|
425
|
-
end
|
426
|
-
|
427
|
-
it 'should detect a single problem' do
|
428
|
-
expect(problems).to have(1).problem
|
429
|
-
end
|
430
|
-
|
431
|
-
it 'should not fix the manifest' do
|
432
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(14)
|
433
|
-
end
|
432
|
+
it 'should detect no problem' do
|
433
|
+
expect(problems).to have(0).problems
|
434
434
|
end
|
435
435
|
end
|
436
436
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-manifest_whitespace-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Vandeginste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|