puppet-lint-wmf_styleguide-check 1.1.0 → 1.1.1

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: 7980b85ac1476eb1cfd7107a024a8d01f56d3aaa13bc4adf6542b52edeb862a8
4
- data.tar.gz: f5b71a6c23db3e26deec5d4f2a2d036ad4dbaeb26e0aa80d2049bf6e95e830eb
3
+ metadata.gz: 899c8c3526bd03b42700fe80c845fc590fc60876ef10410e1216fcab6e4ac7e5
4
+ data.tar.gz: 4ed16c3cff59cfa2c72b6dca1af26210daca111ff92e984c999087acd5c44b62
5
5
  SHA512:
6
- metadata.gz: 814e0b269f85a970e883534f42a12f201e0afaf530f47474e7bbfaf685dd0ae549a529de9c639768c6e34f11d53bb66425e7c31a4a25cf0d6bb6d60f9c614238
7
- data.tar.gz: 8b85af51045fc558202c404ce87f20c0ca14dc76538ea30bde1abd68c3eac4ac154e1a77a309ff08b9e96ed93aca6945e870d117553259a68aa09d45d7b68b91
6
+ metadata.gz: b550d1bf27ecffec3b069cf131367232a0b65dc8da3c6296054aa6d1c634b655bd291cece4bf6c71fbb4a2e41939f6455c86a8a594e36d1fe486178f24eec3b8
7
+ data.tar.gz: d0641b8fd0fe54e5430a1fab4f5e0b40d24d97243ceed0d8195d9faeaa2c57700b91597af050c962b959aed2c0fba6edb4600badc66286d91440df31a57e9110
@@ -493,6 +493,15 @@ PuppetLint.new_check(:wmf_styleguide) do
493
493
  # If we're not within a node definition, skip this token
494
494
  next unless in_node_def
495
495
  case token.type
496
+ when :REGEX
497
+ if !token.value.start_with?('^') || !token.value.end_with?('$')
498
+ msg = {
499
+ message: "wmf-style: regex node matching must match the whole string (^...$), got: #{token.value}",
500
+ line: token.line,
501
+ column: token.column
502
+ }
503
+ notify :error, msg
504
+ end
496
505
  when :LBRACE
497
506
  title_tokens = tokens[start + 1..(i - 1)].select(&:node_def?) if braces_level.zero?
498
507
  braces_level += 1
@@ -88,7 +88,7 @@ define foo::fixme ($a=hiera('something')) {
88
88
  EOF
89
89
 
90
90
  node_ok = <<-EOF
91
- node /^test1.*\.example\.com$/ {
91
+ node /^test1.*\\.example\\.com$/ {
92
92
  role(spare::system)
93
93
  }
94
94
  EOF
@@ -106,6 +106,24 @@ node 'fixme' {
106
106
  }
107
107
  EOF
108
108
 
109
+ node_regex_missing_start = <<-EOF
110
+ node /test1.*\\.example\\.com$/ {
111
+ role(spare::system)
112
+ }
113
+ EOF
114
+
115
+ node_regex_missing_end = <<-EOF
116
+ node /^test1.*\\.example\\.com/ {
117
+ role(spare::system)
118
+ }
119
+ EOF
120
+
121
+ node_regex_missing_both = <<-EOF
122
+ node /test1.*\\.example\\.com/ {
123
+ role(spare::system)
124
+ }
125
+ EOF
126
+
109
127
  deprecation_ko = <<-EOF
110
128
  define test() {
111
129
  base::service_unit{ 'test2': }
@@ -240,6 +258,25 @@ describe 'wmf_styleguide' do
240
258
  end
241
259
  end
242
260
 
261
+ context 'node regex with start violation' do
262
+ let(:code) { node_regex_missing_start }
263
+ it 'should start the regex with ^' do
264
+ expect(problems).to contain_error('wmf-style: regex node matching must match the whole string (^...$), got: test1.*\\.example\\.com$')
265
+ end
266
+ end
267
+ context 'node regex with end violation' do
268
+ let(:code) { node_regex_missing_end }
269
+ it 'should end the regex with $' do
270
+ expect(problems).to contain_error('wmf-style: regex node matching must match the whole string (^...$), got: ^test1.*\\.example\\.com')
271
+ end
272
+ end
273
+ context 'node regex with start and end violations' do
274
+ let(:code) { node_regex_missing_both }
275
+ it 'should start the regex with ^ and end it with $' do
276
+ expect(problems).to contain_error('wmf-style: regex node matching must match the whole string (^...$), got: test1.*\\.example\\.com')
277
+ end
278
+ end
279
+
243
280
  context 'defined type with deprecations' do
244
281
  let(:code) { deprecation_ko }
245
282
  it 'should not' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-wmf_styleguide-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giuseppe Lavagetto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-15 00:00:00.000000000 Z
11
+ date: 2023-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
@@ -163,8 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []
166
- rubyforge_project:
167
- rubygems_version: 2.7.6.2
166
+ rubygems_version: 3.2.5
168
167
  signing_key:
169
168
  specification_version: 4
170
169
  summary: A puppet-lint plugin to check code adheres to the WMF coding guidelines