puppet-lint-roles-profiles 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/puppet-lint/plugins/check_roles_profiles.rb +12 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c617ba6a13ec44e4c41a130c446564a297dd45d3
|
4
|
+
data.tar.gz: 5623bfe60411cecfdb68a469206642daab28f7c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 898397f3e133513d2e184a9cc3ddb0f0e32e6e19f651a45c5d33207ebc2563db6689ef02a81b7d487ad7c4aa37c082f41fd4d5fc8b7c1d3bf0a90a68710c027c
|
7
|
+
data.tar.gz: 89658130c10d3b8b1d8edddbbe0ac88ee237d54122a192211d8ea6352d8984853cc2213e9c35d0a0a02714d03239f52c0b2607e51a49fd0de7a88181365c954d
|
@@ -5,7 +5,7 @@ PuppetLint.new_check(:roles_with_params) do
|
|
5
5
|
# breaks when roles have params that have variables as defaults
|
6
6
|
c[:param_tokens].select { |t| t.type == :VARIABLE }.each do |t|
|
7
7
|
notify :warning, {
|
8
|
-
:message => '
|
8
|
+
:message => 'Roles must not have parameters',
|
9
9
|
:line => t.line,
|
10
10
|
:column => t.column,
|
11
11
|
}
|
@@ -15,33 +15,29 @@ PuppetLint.new_check(:roles_with_params) do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
PuppetLint.new_check(:roles_include_profiles) do
|
18
|
+
def warn(t)
|
19
|
+
notify :warning, {
|
20
|
+
:message => "Roles must only include profiles",
|
21
|
+
:line => t.line,
|
22
|
+
:column => t.column
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
18
26
|
def check
|
19
27
|
class_indexes.select { |c| c[:name_token].value =~ /^roles?(::|$)/ }.each do |c|
|
20
28
|
# As only `include profile` is allowed any resource is bad
|
21
29
|
resource_indexes.select { |r| r[:start] >= c[:start] and r[:end] <= c[:end] }.each do |r|
|
22
|
-
|
23
|
-
:message => "Roles must only `include profiles`",
|
24
|
-
:line => r[:type].line,
|
25
|
-
:column => r[:type].column,
|
26
|
-
}
|
30
|
+
warn(r[:type])
|
27
31
|
end
|
28
32
|
# each include must be followed with a profile
|
29
33
|
tokens[c[:start]..c[:end]].select { |t| t.value == 'include' }.each do |t|
|
30
34
|
unless t.next_code_token.value =~ /^(::)?profiles?(::|$)/
|
31
|
-
|
32
|
-
:message => "Roles must only `include profiles`",
|
33
|
-
:line => t.line,
|
34
|
-
:column => t.column
|
35
|
-
}
|
35
|
+
warn(t)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
# Conditional logic should be avoided
|
39
39
|
tokens[c[:start]..c[:end]].select { |t| [ :IF, :ELSE, :ELSIF, :UNLESS, :CASE].include?(t.type) }.each do |t|
|
40
|
-
|
41
|
-
:message => "Roles must only `include profiles`",
|
42
|
-
:line => t.line,
|
43
|
-
:column => t.column
|
44
|
-
}
|
40
|
+
warn(t)
|
45
41
|
end
|
46
42
|
end
|
47
43
|
end
|