puppet-lint-class_parameter-check 0.1.0 → 0.1.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d4ff8ab903779758a54fac337183a597a64ecf2
|
4
|
+
data.tar.gz: 13672cb4c1c29d1f461b8c573bff36b172bcbd3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe4e9065152745426c4f8ad70c9c8b0606ed9612313e862e9294eea4a7b7a89ce6ee402d58e23c7829e205d5c22653652be3ad2d54c0475ebb3e572f134aa171
|
7
|
+
data.tar.gz: 52fa35443e2dee2370ec19c32f7121543df9923abc4904cfa321548b468faf4d51e1d427bb021aa942d33f0d28d168bc9c7721c0426ca277e81038ae95a2d15e
|
@@ -45,9 +45,16 @@ class ClassParameterList
|
|
45
45
|
private
|
46
46
|
def parameters
|
47
47
|
parameter = ClassParameter.new
|
48
|
+
stack = []
|
48
49
|
|
49
50
|
@tokens.inject([]) do |memo, token|
|
50
|
-
if
|
51
|
+
if token.type == :LBRACK
|
52
|
+
stack.push(true)
|
53
|
+
elsif token.type == :RBRACK
|
54
|
+
stack.pop
|
55
|
+
end
|
56
|
+
|
57
|
+
if (token.type == :COMMA || token == @tokens.last) && stack.empty? && parameter.tokens.any?
|
51
58
|
# always add a comma and a newline token at the end of each parameter
|
52
59
|
parameter.add(PuppetLint::Lexer::Token.new(:COMMA, ",", 0,0))
|
53
60
|
parameter.add(PuppetLint::Lexer::Token.new(:NEWLINE, "\n", 0,0))
|
@@ -26,31 +26,20 @@ describe 'class_parameter' do
|
|
26
26
|
it 'has no problems' do
|
27
27
|
expect(problems).to have(0).problems
|
28
28
|
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'class with only optional parameters' do
|
32
|
-
let(:code) { <<-EOF
|
33
|
-
class puppet_module(
|
34
|
-
String $alphabetical = default
|
35
|
-
) { }
|
36
|
-
EOF
|
37
|
-
}
|
38
|
-
|
39
|
-
it 'has no problems' do
|
40
|
-
expect(problems).to have(0).problems
|
41
|
-
end
|
42
29
|
|
43
|
-
context '
|
30
|
+
context 'with hash parameters' do
|
44
31
|
let(:code) { <<-EOF
|
45
32
|
class puppet_module(
|
46
|
-
String
|
47
|
-
|
33
|
+
Hash [String, String] $alphabetical,
|
34
|
+
String $non_alphabetical
|
35
|
+
) { }
|
48
36
|
EOF
|
49
37
|
}
|
50
38
|
|
51
39
|
it 'has no problems' do
|
52
40
|
expect(problems).to have(0).problems
|
53
41
|
end
|
42
|
+
|
54
43
|
end
|
55
44
|
end
|
56
45
|
|
@@ -69,6 +58,32 @@ describe 'class_parameter' do
|
|
69
58
|
end
|
70
59
|
end
|
71
60
|
|
61
|
+
context 'class with only optional parameters' do
|
62
|
+
let(:code) { <<-EOF
|
63
|
+
class puppet_module(
|
64
|
+
String $alphabetical = default
|
65
|
+
) { }
|
66
|
+
EOF
|
67
|
+
}
|
68
|
+
|
69
|
+
it 'has no problems' do
|
70
|
+
expect(problems).to have(0).problems
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'optional parameter from inherited class' do
|
74
|
+
let(:code) { <<-EOF
|
75
|
+
class puppet_module(
|
76
|
+
String $alphabetical = $puppet_module::params::alphabetical
|
77
|
+
) inherits puppet_module::params { }
|
78
|
+
EOF
|
79
|
+
}
|
80
|
+
|
81
|
+
it 'has no problems' do
|
82
|
+
expect(problems).to have(0).problems
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
72
87
|
context 'class with required and optional parameters' do
|
73
88
|
context 'sorted alphabetically per group' do
|
74
89
|
let(:code) { <<-EOF
|