puppet-lint-global_definition-check 0.4.1 → 0.4.2

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
  SHA256:
3
- metadata.gz: f5908dbc45cdfa0b23c1118581382b3b94b04d8e3698f97dfee048f88cc86afc
4
- data.tar.gz: 126e6ae65e6ece7de91b78f6dcb231ed6d2afaa82ae92be496b58c7cb9e8cf68
3
+ metadata.gz: 2896bfc30e8ea8bb554cf3bb9d287ccd67f77365fb3cc35d505206d34508cc24
4
+ data.tar.gz: cff254e83cf89d4d6e6bf11bfbb0052d41b85918a7a7760342daa0c5b96ddf76
5
5
  SHA512:
6
- metadata.gz: 697fca75eb244e8e6e86d7320538069da3682aa0a5093a4ef39cb16dd7c6c13c410dd595bfb33d76f31f709c61ad69230451aa913ec293b932f7968702da6484
7
- data.tar.gz: 3de93b7fc97a05f656e54388ad7fb13aa377071450ee94f7f5dd46ea7fd06959b4a8bd90ca50530d0a601fd7b9a23764c12836fa217417a824de0c31f49fd33e
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, value = nil)
5
- global_tokens.each_with_index do |token, i|
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 = value.nil? ? token.value : "#{token.value} #{token.next_code_token.value}"
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, "include")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-global_definition-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nine Internet Solutions AG