Skip to content

Commit 54becf8

Browse files
committed
rubocop: autofix
1 parent db1c0be commit 54becf8

File tree

5 files changed

+81
-32
lines changed

5 files changed

+81
-32
lines changed

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
inherit_from: .rubocop_todo.yml
3+
24
# Managed by modulesync - DO NOT EDIT
35
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
46

.rubocop_todo.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2023-04-21 11:38:16 UTC using RuboCop version 1.50.2.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 6
10+
# Configuration parameters: ForbiddenDelimiters.
11+
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
12+
Naming/HeredocDelimiterNaming:
13+
Exclude:
14+
- 'puppet-lint-leading_zero-check.gemspec'
15+
- 'spec/puppet-lint/plugins/check_leading_zero/check_leading_zero_spec.rb'
16+
17+
# Offense count: 4
18+
# Configuration parameters: Prefixes, AllowedPatterns.
19+
# Prefixes: when, with, without
20+
RSpec/ContextWording:
21+
Exclude:
22+
- 'spec/puppet-lint/plugins/check_leading_zero/check_leading_zero_spec.rb'
23+
24+
# Offense count: 1
25+
# Configuration parameters: IgnoredMetadata.
26+
RSpec/DescribeClass:
27+
Exclude:
28+
- '**/spec/features/**/*'
29+
- '**/spec/requests/**/*'
30+
- '**/spec/routing/**/*'
31+
- '**/spec/system/**/*'
32+
- '**/spec/views/**/*'
33+
- 'spec/puppet-lint/plugins/check_leading_zero/check_leading_zero_spec.rb'
34+
35+
# Offense count: 1
36+
# This cop supports unsafe autocorrection (--autocorrect-all).
37+
# Configuration parameters: EnforcedStyle.
38+
# SupportedStyles: always, conditionals
39+
Style/AndOr:
40+
Exclude:
41+
- 'lib/puppet-lint/plugins/check_leading_zero.rb'
42+
43+
# Offense count: 5
44+
# This cop supports unsafe autocorrection (--autocorrect-all).
45+
# Configuration parameters: EnforcedStyle.
46+
# SupportedStyles: always, always_true, never
47+
Style/FrozenStringLiteralComment:
48+
Exclude:
49+
- 'Gemfile'
50+
- 'Rakefile'
51+
- 'lib/puppet-lint/plugins/check_leading_zero.rb'
52+
- 'puppet-lint-leading_zero-check.gemspec'
53+
- 'spec/puppet-lint/plugins/check_leading_zero/check_leading_zero_spec.rb'

lib/puppet-lint/plugins/check_leading_zero.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
PuppetLint.new_check(:leading_zero) do
22
def check
33
tokens.each do |token|
4-
if token.type == :NUMBER and token.value =~ /^0\d/
5-
notify :warning, {
6-
:message => 'unquoted number with leading zero',
7-
:line => token.line,
8-
:column => token.column,
9-
:token => token,
10-
}
11-
end
4+
next unless token.type == :NUMBER and token.value =~ /^0\d/
5+
6+
notify :warning, {
7+
message: 'unquoted number with leading zero',
8+
line: token.line,
9+
column: token.column,
10+
token: token,
11+
}
1212
end
1313
end
1414

puppet-lint-leading_zero-check.gemspec

-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Gem::Specification.new do |spec|
1111
'lib/**/*',
1212
'spec/**/*',
1313
]
14-
spec.test_files = Dir['spec/**/*']
1514
spec.summary = 'A puppet-lint plugin to check for unquoted numbers with leading zero.'
1615
spec.description = <<-EOF
1716
A puppet-lint plugin to check for unquoted numbers with leading zero.
@@ -20,9 +19,4 @@ Gem::Specification.new do |spec|
2019
spec.required_ruby_version = '>= 2.7.0'
2120

2221
spec.add_dependency 'puppet-lint', '>= 3', '< 5'
23-
spec.add_development_dependency 'rspec', '~> 3.0'
24-
spec.add_development_dependency 'rspec-its', '~> 1.0'
25-
spec.add_development_dependency 'rspec-collection_matchers', '~> 1.0'
26-
spec.add_development_dependency 'simplecov'
27-
spec.add_development_dependency 'rake'
2822
end

spec/puppet-lint/plugins/check_leading_zero/check_leading_zero_spec.rb

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
require 'spec_helper'
22

33
describe 'leading_zero' do
4-
let (:msg) { 'unquoted number with leading zero' }
4+
let(:msg) { 'unquoted number with leading zero' }
55

66
context 'with fix disabled' do
77
context 'no unquoted numbers with leading zero' do
8-
let (:code) {
8+
let(:code) do
99
<<-EOS
1010
$foo = '010'
1111
$bar = 10
1212
$baz = 0
1313
EOS
14-
}
14+
end
1515

16-
it 'should not detect any problems' do
16+
it 'does not detect any problems' do
1717
expect(problems).to have(0).problems
1818
end
1919
end
2020

2121
context 'unquoted numbers with leading zero' do
22-
let (:code) {
22+
let(:code) do
2323
<<-EOS
2424
$foo = 010
2525
EOS
26-
}
26+
end
2727

28-
it 'should detect a single problem' do
28+
it 'detects a single problem' do
2929
expect(problems).to have(1).problem
3030
end
3131

32-
it 'should create a warning' do
32+
it 'creates a warning' do
3333
expect(problems).to contain_warning(msg).on_line(1).in_column(16)
3434
end
3535
end
@@ -45,41 +45,41 @@
4545
end
4646

4747
context 'no unquoted numbers with leading zero' do
48-
let (:code) {
48+
let(:code) do
4949
<<-EOS
5050
$foo = '010'
5151
$bar = 10
5252
$baz = 0
5353
EOS
54-
}
54+
end
5555

56-
it 'should not detect any problems' do
56+
it 'does not detect any problems' do
5757
expect(problems).to have(0).problems
5858
end
5959

60-
it 'should not modify the manifest' do
60+
it 'does not modify the manifest' do
6161
expect(manifest).to eq(code)
6262
end
6363
end
6464

6565
context 'unquoted numbers with leading zero' do
66-
let (:code) {
66+
let(:code) do
6767
<<-EOS
6868
$foo = 010
6969
EOS
70-
}
70+
end
7171

72-
it 'should detect a single problem' do
72+
it 'detects a single problem' do
7373
expect(problems).to have(1).problem
7474
end
7575

76-
it 'should fix the problem' do
76+
it 'fixes the problem' do
7777
expect(problems).to contain_fixed(msg).on_line(1).in_column(16)
7878
end
7979

80-
it 'should should use undef' do
80+
it 'shoulds use undef' do
8181
expect(manifest).to eq(
82-
<<-EOS
82+
<<-EOS,
8383
$foo = '010'
8484
EOS
8585
)

0 commit comments

Comments
 (0)