puppet-lint-unquoted_string-check 0.2.2 → 0.2.3

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: 1234067b3fd6b2651cc7a2be8c632b70c0a2094d
4
- data.tar.gz: 840a3bd085a8ed87c71fc537980e0201a135daab
3
+ metadata.gz: d0da62169a6718196034aff4f7ab841c9220fb93
4
+ data.tar.gz: 3c32f8a9a476915f75eba6df3b042d20cbc68891
5
5
  SHA512:
6
- metadata.gz: 1b7e03d5414177c65f9751085e901274ef2c64286515e52cc0abf9b845d034302bae035981f2103b5b3a5f4099a3ad287b718ee7f55e43cf552d7d8d89942182
7
- data.tar.gz: 597c0695a7f642d647f5766a4003f12618f3cc1b8ac6c1fbaff1deb6d2ec7bf32e6947a5c31a59eb60a05bb929394da8fa46ee263b689a444d6bca8c6adf8197
6
+ metadata.gz: 53561bea1d4e76646a010c4d2a1318f87b243658aa029b4bbd86e4dfca4477862560f3f6c6d980167516913d6c35d00c4b355332e2931380bec0dec49a8eb2f6
7
+ data.tar.gz: ccd89bbf93c121df5ac76816a8f45192ac38c6bfaa5b0dd69840fcea34c4dc76353b344c43098acb518d9b1b3eb6db919d5fba100976424fa594675ca41fbc7d
@@ -22,66 +22,44 @@ def type_indexes(type)
22
22
  type_indexes
23
23
  end
24
24
 
25
- def tokens_to_fix(type_tokens, sep_type)
26
- tokens_to_fix = []
27
- type_tokens.index do |r|
28
- if r.type == sep_type
29
- s = r.prev_token
30
- while s.type != :NEWLINE and s.type != :LBRACE
31
- if s.type == :NAME || s.type == :CLASSREF
32
- tokens_to_fix << s
25
+ def notify_tokens(type, sep_type, message)
26
+ type_indexes(type).each do |kase|
27
+ type_tokens = tokens[kase[:start]..kase[:end]]
28
+ type_tokens.index do |r|
29
+ if r.type == sep_type
30
+ s = r.prev_token
31
+ while s.type != :NEWLINE and s.type != :LBRACE
32
+ if s.type == :NAME || s.type == :CLASSREF
33
+ notify :warning, {
34
+ :message => message,
35
+ :line => s.line,
36
+ :column => s.column,
37
+ :token => s,
38
+ }
39
+ end
40
+ s = s.prev_token
33
41
  end
34
- s = s.prev_token
35
42
  end
36
43
  end
37
44
  end
38
- tokens_to_fix
39
- end
40
-
41
- def act_on_tokens(type, sep_type, &block)
42
- type_indexes(type).each do |kase|
43
- case_tokens = tokens[kase[:start]..kase[:end]]
44
-
45
- tokens_to_fix(case_tokens, sep_type).each do |r|
46
- block.call(r)
47
- end
48
- end
49
45
  end
50
46
 
51
47
  PuppetLint.new_check(:unquoted_string_in_case) do
52
-
53
48
  def check
54
- act_on_tokens(:CASE, :COLON) do |r|
55
- notify :warning, {
56
- :message => 'unquoted string in case',
57
- :line => r.line,
58
- :column => r.column,
59
- }
60
- end
49
+ notify_tokens(:CASE, :COLON, 'unquoted string in case')
61
50
  end
62
51
 
63
52
  def fix(problem)
64
- act_on_tokens(:CASE, :COLON) do |r|
65
- r.type = :SSTRING
66
- end
53
+ problem[:token].type = :SSTRING
67
54
  end
68
55
  end
69
56
 
70
57
  PuppetLint.new_check(:unquoted_string_in_selector) do
71
-
72
58
  def check
73
- act_on_tokens(:QMARK, :FARROW) do |r|
74
- notify :warning, {
75
- :message => 'unquoted string in selector',
76
- :line => r.line,
77
- :column => r.column,
78
- }
79
- end
59
+ notify_tokens(:QMARK, :FARROW, 'unquoted string in selector')
80
60
  end
81
61
 
82
62
  def fix(problem)
83
- act_on_tokens(:QMARK, :FARROW) do |r|
84
- r.type = :SSTRING
85
- end
63
+ problem[:token].type = :SSTRING
86
64
  end
87
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-unquoted_string-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camptocamp
@@ -120,5 +120,5 @@ summary: A puppet-lint plugin to check that selectors and case statements cases
120
120
  quoted.
121
121
  test_files:
122
122
  - spec/spec_helper.rb
123
- - spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_case_spec.rb
124
123
  - spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_selector_spec.rb
124
+ - spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_case_spec.rb