puppet-lint-duplicate_class_parameters-check 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd37576ccadd7950e00643ae5bf071511564842d
|
4
|
+
data.tar.gz: c9faed627d84e90dff0bfa4051e3feacf7528a9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8e4dd1d4aac280c6926d29475e3e6499e4a2b8b18853ffc6fb1595507c04cb86ef59793a9b1b4de8c6699601cdaf85cecc79d87d0d525da81aff92f247819dd
|
7
|
+
data.tar.gz: 2ca2571d1e337510cdecadc4b92b4c40c4b2dcd5a0de6e1f86bbfe33e3412e79504d53b5295ceb843d689d3dc3ee602a7f22d9d2d34c9c9385df9fd923c28ffa
|
@@ -2,6 +2,7 @@ PuppetLint.new_check(:duplicate_class_parameters) do
|
|
2
2
|
def check
|
3
3
|
class_indexes.each do |class_idx|
|
4
4
|
seen = Hash.new(0)
|
5
|
+
inside = nil
|
5
6
|
|
6
7
|
# if there are no params there is nothing to do, return early.
|
7
8
|
return if class_idx[:param_tokens].nil?
|
@@ -10,6 +11,18 @@ PuppetLint.new_check(:duplicate_class_parameters) do
|
|
10
11
|
class_name = class_idx[:name_token].value
|
11
12
|
|
12
13
|
if token.type == :VARIABLE
|
14
|
+
next_type = token.next_code_token.type
|
15
|
+
|
16
|
+
# handling for lines with an equals and a variable on the rhs
|
17
|
+
if next_type == :EQUALS
|
18
|
+
inside = true
|
19
|
+
elsif next_type == :COMMA
|
20
|
+
inside = false
|
21
|
+
end
|
22
|
+
|
23
|
+
# only proceed if we're at the end of a declaration.
|
24
|
+
next if !inside
|
25
|
+
|
13
26
|
param_name = token.value
|
14
27
|
seen[param_name] += 1
|
15
28
|
|
@@ -21,7 +34,6 @@ PuppetLint.new_check(:duplicate_class_parameters) do
|
|
21
34
|
:column => token.column,
|
22
35
|
}
|
23
36
|
end
|
24
|
-
|
25
37
|
end
|
26
38
|
end
|
27
39
|
end
|
@@ -39,6 +39,46 @@ describe 'duplicate_class_parameters' do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
context 'class with duplicate right hand side' do
|
43
|
+
let(:code) do
|
44
|
+
<<-EOS
|
45
|
+
class duplicated_rhs(
|
46
|
+
$nagios_innodb_enable = $sys11mysql,
|
47
|
+
$nagios_myisam_enable = $sys11mysql,
|
48
|
+
) {
|
49
|
+
file { '/tmp/my-file':
|
50
|
+
mode => '0600',
|
51
|
+
}
|
52
|
+
}
|
53
|
+
EOS
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should not detect any problems' do
|
57
|
+
expect(problems).to have(0).problems
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'class with type and duplicate right hand side' do
|
62
|
+
let(:code) do
|
63
|
+
<<-EOS
|
64
|
+
class duplicated_rhs(
|
65
|
+
Boolean $nagios_innodb_enable = $sys11mysql::params::production_environment,
|
66
|
+
Boolean $nagios_myisam_enable = $sys11mysql::params::production_environment,
|
67
|
+
) {
|
68
|
+
file { '/tmp/my-file':
|
69
|
+
mode => '0600',
|
70
|
+
}
|
71
|
+
}
|
72
|
+
EOS
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should not detect any problems' do
|
76
|
+
expect(problems).to have(0).problems
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Examples that should fail specs
|
81
|
+
|
42
82
|
context 'class with duplicate parameters' do
|
43
83
|
let(:msg) { 'found duplicate parameter \'duplicated\' in class \'file_resource\'' }
|
44
84
|
let(:code) do
|
@@ -74,4 +114,32 @@ describe 'duplicate_class_parameters' do
|
|
74
114
|
end
|
75
115
|
|
76
116
|
end
|
117
|
+
|
118
|
+
context 'class with type and duplicate parameters' do
|
119
|
+
let(:msg) { 'found duplicate parameter \'not_unique\' in class \'duplicated_type\'' }
|
120
|
+
let(:code) do
|
121
|
+
<<-EOS
|
122
|
+
class duplicated_type(
|
123
|
+
Boolean $not_unique = true,
|
124
|
+
Boolean $not_unique = false,
|
125
|
+
) {
|
126
|
+
|
127
|
+
file { '/tmp/my-file':
|
128
|
+
mode => '0600',
|
129
|
+
}
|
130
|
+
|
131
|
+
$baz = 'xxzzy'
|
132
|
+
}
|
133
|
+
EOS
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should detect two problems' do
|
137
|
+
expect(problems).to have(1).problems
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should create a warning' do
|
141
|
+
expect(problems).to contain_warning(msg).on_line(3).in_column(19)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
77
145
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-duplicate_class_parameters-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 3.5.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
|
-
version:
|
46
|
+
version: 3.5.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec-its
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,28 +78,56 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.
|
81
|
+
version: 0.47.1
|
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: 0.
|
88
|
+
version: 0.47.1
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: rake
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - "
|
93
|
+
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 11.2.0
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - "
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 11.2.0
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rspec-json_expectations
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.4'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '1.4'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: simplecov
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 0.15.0
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
101
129
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
130
|
+
version: 0.15.0
|
103
131
|
description: |2
|
104
132
|
A puppet-lint extension that ensures class parameter names
|
105
133
|
are unique.
|
@@ -133,11 +161,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
161
|
version: '0'
|
134
162
|
requirements: []
|
135
163
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.5.1
|
137
165
|
signing_key:
|
138
166
|
specification_version: 4
|
139
167
|
summary: puppet-lint duplicate class parameters check
|
140
168
|
test_files:
|
141
169
|
- spec/spec_helper.rb
|
142
170
|
- spec/puppet-lint/plugins/puppet-lint_duplicate_class_parameters_spec.rb
|
143
|
-
has_rdoc:
|