puppet-lint-wmf_styleguide-check 1.1.1 → 1.1.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: 899c8c3526bd03b42700fe80c845fc590fc60876ef10410e1216fcab6e4ac7e5
4
- data.tar.gz: 4ed16c3cff59cfa2c72b6dca1af26210daca111ff92e984c999087acd5c44b62
3
+ metadata.gz: '0996980289ea98e58b4da21e94d46732a5fec1cda561ddcd979ec647c91db633'
4
+ data.tar.gz: d8b5d617cb4ba1f1765670171cf157b723d73428410b8f1e564d8f160f20a046
5
5
  SHA512:
6
- metadata.gz: b550d1bf27ecffec3b069cf131367232a0b65dc8da3c6296054aa6d1c634b655bd291cece4bf6c71fbb4a2e41939f6455c86a8a594e36d1fe486178f24eec3b8
7
- data.tar.gz: d0641b8fd0fe54e5430a1fab4f5e0b40d24d97243ceed0d8195d9faeaa2c57700b91597af050c962b959aed2c0fba6edb4600badc66286d91440df31a57e9110
6
+ metadata.gz: c8056b429179de7156ecdb3ccb09bad40c9c4ae0c487a2177ca8073b204e4de935da30ac993b3c94ebf896f0140f9bee36707cf045cfeb5e3617c34142debeb2
7
+ data.tar.gz: 96531a80875d9aa641a8a34ac3a541ab1ad75c0b4fb37228324c6312e2ba736749e3532de77bb6d8412ea5b3c5d973977f69f09a83d2ec10310d9cd3f028f9b4
@@ -280,7 +280,6 @@ end
280
280
 
281
281
  def lookup_not_in_params(klass)
282
282
  # Checks if a lookup call is not in a parameter declaration. Used to check profiles
283
-
284
283
  # Any lookup call that is not inside a parameter declaration is a violation
285
284
  tokens = klass.lookup_calls.reject do |token|
286
285
  maybe_param = token.prev_code_token.prev_code_token
@@ -498,7 +497,9 @@ PuppetLint.new_check(:wmf_styleguide) do
498
497
  msg = {
499
498
  message: "wmf-style: regex node matching must match the whole string (^...$), got: #{token.value}",
500
499
  line: token.line,
501
- column: token.column
500
+ column: token.column,
501
+ token: token,
502
+ problem: 'node_regex'
502
503
  }
503
504
  notify :error, msg
504
505
  end
@@ -547,4 +548,15 @@ PuppetLint.new_check(:wmf_styleguide) do
547
548
  check_node node
548
549
  end
549
550
  end
551
+
552
+ def fix_node_regex(problem)
553
+ problem[:token].value.insert(0, '^') unless problem[:token].value.start_with?('^')
554
+ problem[:token].value << '$' unless problem[:token].value.end_with?('$')
555
+ end
556
+
557
+ def fix(problem)
558
+ raise PuppetLint::NoFix unless problem[:problem] == 'node_regex'
559
+ method = "fix_#{problem[:problem]}"
560
+ send(method, problem) if respond_to? method
561
+ end
550
562
  end
@@ -124,6 +124,12 @@ node /test1.*\\.example\\.com/ {
124
124
  }
125
125
  EOF
126
126
 
127
+ node_regex_fixed = <<-EOF
128
+ node /^test1.*\\.example\\.com$/ {
129
+ role(spare::system)
130
+ }
131
+ EOF
132
+
127
133
  deprecation_ko = <<-EOF
128
134
  define test() {
129
135
  base::service_unit{ 'test2': }
@@ -283,4 +289,27 @@ describe 'wmf_styleguide' do
283
289
  expect(problems).to contain_error("wmf-style: 'test' should not include the deprecated define 'base::service_unit'")
284
290
  end
285
291
  end
292
+
293
+ context 'with fix enabled' do
294
+ before do
295
+ PuppetLint.configuration.fix = true
296
+ end
297
+
298
+ after do
299
+ PuppetLint.configuration.fix = false
300
+ end
301
+
302
+ context 'node regex with start violation' do
303
+ let(:code) { node_regex_missing_start }
304
+ it { expect(manifest).to eq(node_regex_fixed) }
305
+ end
306
+ context 'node regex with end violation' do
307
+ let(:code) { node_regex_missing_end }
308
+ it { expect(manifest).to eq(node_regex_fixed) }
309
+ end
310
+ context 'node regex with start and end violations' do
311
+ let(:code) { node_regex_missing_both }
312
+ it { expect(manifest).to eq(node_regex_fixed) }
313
+ end
314
+ end
286
315
  end
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.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giuseppe Lavagetto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-13 00:00:00.000000000 Z
11
+ date: 2023-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
@@ -168,5 +168,5 @@ signing_key:
168
168
  specification_version: 4
169
169
  summary: A puppet-lint plugin to check code adheres to the WMF coding guidelines
170
170
  test_files:
171
- - spec/puppet-lint/plugins/check_wmf_styleguide_check_spec.rb
172
171
  - spec/spec_helper.rb
172
+ - spec/puppet-lint/plugins/check_wmf_styleguide_check_spec.rb