puppet-lint-global_definition-check 0.4.1 → 0.4.2
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: 2896bfc30e8ea8bb554cf3bb9d287ccd67f77365fb3cc35d505206d34508cc24
|
4
|
+
data.tar.gz: cff254e83cf89d4d6e6bf11bfbb0052d41b85918a7a7760342daa0c5b96ddf76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0294aea977236fe3bfb2f6e34e423f1cc097e51e774691971ffc0db022709d896be7f112b55193d627dea3ef5c9a6ff4fb0ea7e024ce48a515a7b90a1d5bb48e'
|
7
|
+
data.tar.gz: 9b8945fb065a3ab9261155a9fd4aceb184f82f6b97f93af4a3fc62de5fca0a12f0d18d9de47b1e32712c29cc21649be8a741aa8d9baef5e10626974ff706bfc1
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module PuppetLintGlobalDefinionCheck
|
2
2
|
private
|
3
3
|
|
4
|
-
def check_for_global_token(type
|
5
|
-
global_tokens.
|
4
|
+
def check_for_global_token(type)
|
5
|
+
global_tokens.each do |token|
|
6
6
|
next unless token.type == type
|
7
|
-
next unless value.nil? || token.value == value
|
8
7
|
|
9
|
-
message =
|
8
|
+
message = yield(token)
|
9
|
+
next unless message
|
10
10
|
|
11
11
|
notify :error,
|
12
12
|
message: "definition #{message} in global space",
|
@@ -37,7 +37,9 @@ PuppetLint.new_check(:global_resource) do
|
|
37
37
|
|
38
38
|
def check
|
39
39
|
check_for_global_resources
|
40
|
-
check_for_global_token(:NAME
|
40
|
+
check_for_global_token(:NAME) do |token|
|
41
|
+
"#{token.value} #{token.next_code_token.value}" if token.value == "include"
|
42
|
+
end
|
41
43
|
end
|
42
44
|
|
43
45
|
def check_for_global_resources
|
@@ -56,6 +58,8 @@ PuppetLint.new_check(:global_function) do
|
|
56
58
|
include PuppetLintGlobalDefinionCheck
|
57
59
|
|
58
60
|
def check
|
59
|
-
check_for_global_token(:FUNCTION_NAME)
|
61
|
+
check_for_global_token(:FUNCTION_NAME) do |token|
|
62
|
+
"#{token.value} #{token.next_code_token.value}" unless !token.prev_code_token.nil? && token.prev_code_token.type == :FUNCTION
|
63
|
+
end
|
60
64
|
end
|
61
65
|
end
|
@@ -30,4 +30,26 @@ describe "global_function" do
|
|
30
30
|
expect(problems).to have(1).problems
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
context "module function definition" do
|
35
|
+
let(:code) do
|
36
|
+
<<-EOS
|
37
|
+
# @summary function to clean hash of undef and empty values
|
38
|
+
function nine_networkinterfaces::delete_empty_values(
|
39
|
+
Hash $hash,
|
40
|
+
) >> Hash {
|
41
|
+
$hash.filter |$key, $value| {
|
42
|
+
case $value {
|
43
|
+
Collection: { $value =~ NotUndef and !$value.empty }
|
44
|
+
default: { $value =~ NotUndef }
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
EOS
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should not detect any problems" do
|
52
|
+
expect(problems).to have(0).problems
|
53
|
+
end
|
54
|
+
end
|
33
55
|
end
|