puppet-lint-unquoted_string-check 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZmE3YTU1Mjg2ZDAxMzc2ZjllNjM5ODhlNGZmYzA5Mzc1ZjhlMjlkMw==
5
- data.tar.gz: !binary |-
6
- ZDIxYjJlMDRlNGExMDE1YmM5YTI4N2I4ZTMxNTFmYjhlZWQzMDA2NQ==
2
+ SHA256:
3
+ metadata.gz: e98c28603db37044ee14ffae7a038dabe5231eeba2293f192aba89f3d4ec6c9d
4
+ data.tar.gz: 7a1421684d95face81b81bdeb50388cbab28cd1e093414d801b12ce202aa4c5e
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZWE1NzJhYzhlNzE0MjYyZjY4NTgwZjExNmRhMzdiYTEyMTA5ZTY2NTM2NjRk
10
- ZTZkYWE0NmY5ZTZlMGE4ZGNlZTk5ZjQ5ZDZhZDE5MTI4NjE5NzdhZGU1YTkx
11
- NWIxMTc3NGM3MDRjY2I5N2MxZmQxNTA1ZmQ3YmE5Mjk2NTZhMjU=
12
- data.tar.gz: !binary |-
13
- ZDk0MWRjNGIyMjI5MTA1OGE0ZTQyZmMxZDQwNWU0NjUxNWY1Mzk4YTIyZmM2
14
- NDliMzdlMmFjYjIxOTUzMTFlZjJjNjc0NDA1MTE1MDE1ODk1MmY0MjRhMTVj
15
- Yjk0ZjlhMTFiYjBiZmExNTM2OGJhNzM4OTdlMGYyOGE1MDAwNWI=
6
+ metadata.gz: 8aa08133b84dc79ef322ced02da42bde2ca7adddb07f57a7d6b80a9e3278546ff7e38f71b101f110485f9605fcf056be80d4e8cc5986861cde29711aa5fc3f71
7
+ data.tar.gz: 25ce700012433f0b2389ecdd681e1657b5de7bdc9f82b73fad43b7ec9f5dcc1a4355323ce77a9a3ca44ad5b50a48895719710f66fc0d9d4214715da720ea2b7e
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  puppet-lint-unquoted_string-check
2
2
  =================================
3
3
 
4
- [![Build Status](https://img.shields.io/travis/puppet-community/puppet-lint-unquoted_string-check.svg)](https://travis-ci.org/puppet-community/puppet-lint-unquoted_string-check)
4
+ [![Build Status](https://img.shields.io/travis/voxpupuli/puppet-lint-unquoted_string-check.svg)](https://travis-ci.org/voxpupuli/puppet-lint-unquoted_string-check)
5
5
  [![Gem Version](https://img.shields.io/gem/v/puppet-lint-unquoted_string-check.svg)](https://rubygems.org/gems/puppet-lint-unquoted_string-check)
6
6
  [![Gem Downloads](https://img.shields.io/gem/dt/puppet-lint-unquoted_string-check.svg)](https://rubygems.org/gems/puppet-lint-unquoted_string-check)
7
- [![Coverage Status](https://img.shields.io/coveralls/puppet-community/puppet-lint-unquoted_string-check.svg)](https://coveralls.io/r/puppet-community/puppet-lint-unquoted_string-check?branch=master)
8
- [![Gemnasium](https://img.shields.io/gemnasium/puppet-community/puppet-lint-unquoted_string-check.svg)](https://gemnasium.com/puppet-community/puppet-lint-unquoted_string-check)
7
+ [![Coverage Status](https://img.shields.io/coveralls/voxpupuli/puppet-lint-unquoted_string-check.svg)](https://coveralls.io/r/voxpupuli/puppet-lint-unquoted_string-check?branch=master)
9
8
  [![Donated by Camptocamp](https://img.shields.io/badge/donated%20by-camptocamp-fb7047.svg)](#transfer-notice)
10
9
 
11
10
  A puppet-lint plugin to check that selectors and case statements cases are quoted.
@@ -0,0 +1,4 @@
1
+ class PuppetLintUnquotedStringCheck
2
+ VERSION = '1.0.0'.freeze
3
+ end
4
+
@@ -5,14 +5,21 @@ def type_indexes(type)
5
5
  tokens.each_index do |token_idx|
6
6
  if tokens[token_idx].type == type
7
7
  depth = 0
8
+ start = token_idx
8
9
  tokens[(token_idx + 1)..-1].each_index do |case_token_idx|
9
10
  idx = case_token_idx + token_idx + 1
10
11
  if tokens[idx].type == :LBRACE
11
12
  depth += 1
13
+ if depth == 2
14
+ type_indexes << {:start => start, :end => idx}
15
+ end
12
16
  elsif tokens[idx].type == :RBRACE
17
+ if depth == 2
18
+ start = idx
19
+ end
13
20
  depth -= 1
14
21
  if depth == 0
15
- type_indexes << {:start => token_idx, :end => idx}
22
+ type_indexes << {:start => start, :end => idx}
16
23
  break
17
24
  end
18
25
  end
@@ -22,24 +29,20 @@ def type_indexes(type)
22
29
  type_indexes
23
30
  end
24
31
 
25
- def is_puppet_type(token)
26
- token.type == :CLASSREF and [ 'Undef', 'Default', 'Integer', 'Float', 'Boolean', 'Regexp', 'String', 'Array', 'Hash', 'Resource', 'Class', 'Collection', 'Scalar', 'Numeric', 'CatalogEntry', 'Data', 'Tuple', 'Struct', 'Optional', 'NotUndef', 'Variant', 'Enum', 'Pattern', 'Any', 'Callable', 'Type', 'Runtime', ].include? token.value
27
- end
28
-
29
32
  def notify_tokens(type, sep_type, message)
30
33
  type_indexes(type).each do |kase|
31
34
  type_tokens = tokens[kase[:start]..kase[:end]]
32
35
  type_tokens.index do |r|
33
36
  if r.type == sep_type
34
37
  s = r.prev_token
35
- while s.type != :NEWLINE and s.type != :LBRACE
36
- if s.type == :NAME || s.type == :CLASSREF
38
+ while (s.type != :NEWLINE) && (s.type != :LBRACE)
39
+ if (s.type == :NAME || s.type == :CLASSREF) && (s.type != :TYPE)
37
40
  notify :warning, {
38
41
  :message => message,
39
42
  :line => s.line,
40
43
  :column => s.column,
41
44
  :token => s,
42
- } unless is_puppet_type(s)
45
+ }
43
46
  end
44
47
  s = s.prev_token
45
48
  end
@@ -145,5 +145,28 @@ describe 'unquoted_string_in_selector' do
145
145
  )
146
146
  end
147
147
  end
148
+
149
+ context 'hashes in case' do
150
+ let(:code) do
151
+ <<-EOS
152
+ $postfix_configuration = $configuration ? {
153
+ 'relay' => {
154
+ relayhost => '[example.com]:587',
155
+ satellite => true,
156
+ },
157
+ 'smarthost' => {
158
+ smtp_listen => 'all',
159
+ master_submission => 'submission inet n - - - - smtpd -o smtpd_tls_security_level=encrypt',
160
+ mta => true,
161
+ relayhost => 'direct',
162
+ },
163
+ }
164
+ EOS
165
+ end
166
+
167
+ it 'should not detect any problems' do
168
+ expect(problems).to have(0).problems
169
+ end
170
+ end
148
171
  end
149
172
  end
metadata CHANGED
@@ -1,130 +1,143 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-unquoted_string-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Puppet Community
7
+ - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-22 00:00:00.000000000 Z
11
+ date: 2019-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
20
- - - <
19
+ version: '2.1'
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '3.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ! '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '1.0'
30
- - - <
29
+ version: '2.1'
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '3.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
46
  version: '3.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-its
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ~>
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ~>
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec-collection_matchers
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ~>
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '1.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ~>
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '1.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: github_changelog_generator
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: mime-types
77
91
  requirement: !ruby/object:Gem::Requirement
78
92
  requirements:
79
- - - ~>
93
+ - - "~>"
80
94
  - !ruby/object:Gem::Version
81
95
  version: '1.0'
82
96
  type: :development
83
97
  prerelease: false
84
98
  version_requirements: !ruby/object:Gem::Requirement
85
99
  requirements:
86
- - - ~>
100
+ - - "~>"
87
101
  - !ruby/object:Gem::Version
88
102
  version: '1.0'
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: coveralls
91
105
  requirement: !ruby/object:Gem::Requirement
92
106
  requirements:
93
- - - ~>
107
+ - - "~>"
94
108
  - !ruby/object:Gem::Version
95
109
  version: '0.7'
96
110
  type: :development
97
111
  prerelease: false
98
112
  version_requirements: !ruby/object:Gem::Requirement
99
113
  requirements:
100
- - - ~>
114
+ - - "~>"
101
115
  - !ruby/object:Gem::Version
102
116
  version: '0.7'
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: rake
105
119
  requirement: !ruby/object:Gem::Requirement
106
120
  requirements:
107
- - - ! '>='
121
+ - - ">="
108
122
  - !ruby/object:Gem::Version
109
123
  version: '0'
110
124
  type: :development
111
125
  prerelease: false
112
126
  version_requirements: !ruby/object:Gem::Requirement
113
127
  requirements:
114
- - - ! '>='
128
+ - - ">="
115
129
  - !ruby/object:Gem::Version
116
130
  version: '0'
117
- description: ! ' A puppet-lint plugin to check that selectors and case statements
118
- cases are quoted.
119
-
120
- '
121
- email: mickael.canevet@camptocamp.com
131
+ description: " A puppet-lint plugin to check that selectors and case statements
132
+ cases are quoted.\n"
133
+ email: voxpupuli@groups.io
122
134
  executables: []
123
135
  extensions: []
124
136
  extra_rdoc_files: []
125
137
  files:
126
138
  - LICENSE
127
139
  - README.md
140
+ - lib/puppet-lint-unquoted-string-check/version.rb
128
141
  - lib/puppet-lint/plugins/check_unquoted_string_in_case.rb
129
142
  - spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_case_spec.rb
130
143
  - spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_selector_spec.rb
@@ -139,22 +152,22 @@ require_paths:
139
152
  - lib
140
153
  required_ruby_version: !ruby/object:Gem::Requirement
141
154
  requirements:
142
- - - ! '>='
155
+ - - ">="
143
156
  - !ruby/object:Gem::Version
144
157
  version: '0'
145
158
  required_rubygems_version: !ruby/object:Gem::Requirement
146
159
  requirements:
147
- - - ! '>='
160
+ - - ">="
148
161
  - !ruby/object:Gem::Version
149
162
  version: '0'
150
163
  requirements: []
151
164
  rubyforge_project:
152
- rubygems_version: 2.4.5
165
+ rubygems_version: 2.7.7
153
166
  signing_key:
154
167
  specification_version: 4
155
168
  summary: A puppet-lint plugin to check that selectors and case statements cases are
156
169
  quoted.
157
170
  test_files:
171
+ - spec/spec_helper.rb
158
172
  - spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_case_spec.rb
159
173
  - spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_selector_spec.rb
160
- - spec/spec_helper.rb