Skip to content

Commit e99b9b3

Browse files
authored
Merge pull request #55 from bastelfreak/vr
voxpupuli-rubocop: Update 4.2->5.0
2 parents 188eaf6 + dfc4adf commit e99b9b3

File tree

6 files changed

+26
-74
lines changed

6 files changed

+26
-74
lines changed

.rubocop.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ inherit_gem:
99
Naming/FileName:
1010
Exclude:
1111
- "*.gemspec"
12-
13-
AllCops:
14-
TargetRubyVersion: 3.2

.rubocop_todo.yml

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
3-
# using RuboCop version 1.79.2.
3+
# using RuboCop version 1.81.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -38,70 +38,21 @@ RSpec/DescribeClass:
3838
- '**/spec/views/**/*'
3939
- 'spec/puppet-lint/plugins/check_strict_indent_spec.rb'
4040

41-
# Offense count: 17
42-
# This cop supports unsafe autocorrection (--autocorrect-all).
43-
# Configuration parameters: EnforcedStyle.
44-
# SupportedStyles: always, conditionals
45-
Style/AndOr:
46-
Exclude:
47-
- 'lib/puppet-lint/plugins/check_strict_indent.rb'
48-
4941
# Offense count: 1
5042
# This cop supports safe autocorrection (--autocorrect).
51-
# Configuration parameters: AutoCorrect, EnforcedStyle, AllowComments.
43+
# Configuration parameters: EnforcedStyle, AllowComments.
5244
# SupportedStyles: empty, nil, both
5345
Style/EmptyElse:
5446
Exclude:
5547
- 'lib/puppet-lint/plugins/check_strict_indent.rb'
5648

57-
# Offense count: 3
58-
# This cop supports unsafe autocorrection (--autocorrect-all).
59-
# Configuration parameters: EnforcedStyle.
60-
# SupportedStyles: always, always_true, never
61-
Style/FrozenStringLiteralComment:
62-
Exclude:
63-
- '**/*.arb'
64-
- 'lib/puppet-lint/plugins/check_strict_indent.rb'
65-
- 'puppet-lint-strict_indent-check.gemspec'
66-
- 'spec/puppet-lint/plugins/check_strict_indent_spec.rb'
67-
6849
# Offense count: 4
6950
Style/MultilineBlockChain:
7051
Exclude:
7152
- 'lib/puppet-lint/plugins/check_strict_indent.rb'
7253
- 'spec/puppet-lint/plugins/check_strict_indent_spec.rb'
7354

74-
# Offense count: 1
75-
# This cop supports safe autocorrection (--autocorrect).
76-
# Configuration parameters: AllowMethodComparison, ComparisonsThreshold.
77-
Style/MultipleComparison:
78-
Exclude:
79-
- 'lib/puppet-lint/plugins/check_strict_indent.rb'
80-
8155
# Offense count: 3
82-
# This cop supports unsafe autocorrection (--autocorrect-all).
83-
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
84-
# SupportedStyles: predicate, comparison
85-
Style/NumericPredicate:
86-
Exclude:
87-
- 'spec/**/*'
88-
- 'lib/puppet-lint/plugins/check_strict_indent.rb'
89-
90-
# Offense count: 1
91-
# This cop supports unsafe autocorrection (--autocorrect-all).
92-
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
93-
# AllowedMethods: present?, blank?, presence, try, try!
94-
Style/SafeNavigation:
95-
Exclude:
96-
- 'lib/puppet-lint/plugins/check_strict_indent.rb'
97-
98-
# Offense count: 1
99-
# This cop supports safe autocorrection (--autocorrect).
100-
Style/WhileUntilModifier:
101-
Exclude:
102-
- 'lib/puppet-lint/plugins/check_strict_indent.rb'
103-
104-
# Offense count: 2
10556
# This cop supports safe autocorrection (--autocorrect).
10657
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
10758
# URISchemes: http, https

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ group :development do
1414
gem 'rspec', '~> 3.12'
1515
gem 'rspec-collection_matchers', '~> 1.2'
1616
gem 'rspec-its', '>= 1.3', '< 3'
17-
gem 'voxpupuli-rubocop', '~> 4.2.0'
17+
gem 'voxpupuli-rubocop', '~> 5.0.0'
1818
end

lib/puppet-lint/plugins/check_strict_indent.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Public: Check the manifest tokens for correct indent levels and
24
# record a warning for each instance found.
35

@@ -50,12 +52,12 @@ def check
5052
# indent for open groups in the previous line
5153
open_groups = 0
5254
prev_token = token.prev_token
53-
while !prev_token.nil? and prev_token.type != :NEWLINE
55+
while !prev_token.nil? && (prev_token.type != :NEWLINE)
5456
temp_indent += 1 if prev_token.type == :HEREDOC_OPEN
5557
if %i[LBRACE LBRACK LPAREN].include?(prev_token.type)
5658
if matches[prev_token].nil?
5759
open_groups += 1
58-
elsif matches[prev_token].line > prev_token.line and !matched_open_lines.include?(matches[prev_token].line)
60+
elsif (matches[prev_token].line > prev_token.line) && !matched_open_lines.include?(matches[prev_token].line)
5961
# increase indent for left braces not matched in the same line or in a line we have already matched a brace to
6062
open_groups += 1
6163
matched_open_lines << matches[prev_token].line
@@ -67,17 +69,15 @@ def check
6769

6870
# reset prev_token to last non-whitespace token on previous line
6971
prev_token = token.prev_token
70-
while !prev_token.nil? and (prev_token.type == :WHITESPACE or prev_token.type == :COMMENT)
71-
prev_token = prev_token.prev_token
72-
end
72+
prev_token = prev_token.prev_token while !prev_token.nil? && ((prev_token.type == :WHITESPACE) || (prev_token.type == :COMMENT))
7373

7474
# get type if available
75-
prev_type = prev_token.nil? ? nil : prev_token.type
75+
prev_type = prev_token&.type
7676

7777
# handle change in indent based on last token
7878
case prev_type
7979
when :COLON
80-
if open_groups == 0
80+
if open_groups.zero?
8181
if colon_indent.nil?
8282
# only indent for a colon when you haven't indented yet
8383
colon_indent = prev_token.line
@@ -99,23 +99,23 @@ def check
9999
# unindent for closing brackets in the current line
100100
next_token = token.next_token
101101
matched_close_lines = []
102-
while !next_token.nil? and next_token.type != :NEWLINE
102+
while !next_token.nil? && (next_token.type != :NEWLINE)
103103
if %i[RBRACE RBRACK RPAREN].include?(next_token.type)
104-
if !matches[next_token].nil? and
105-
matches[next_token].line < next_token.line and
104+
if !matches[next_token].nil? &&
105+
(matches[next_token].line < next_token.line) &&
106106
!matched_close_lines.include?(matches[next_token].line)
107107
# right braces matched in a previous line decrease indent unless we already matched a brace in the same line
108108
indent -= 1
109109
matched_close_lines << matches[next_token].line
110110
end
111-
if next_token.type == :RBRACE and !colon_indent.nil? && (!matches[next_token].nil? and matches[next_token].line < colon_indent)
111+
if (next_token.type == :RBRACE) && !colon_indent.nil? && !matches[next_token].nil? && (matches[next_token].line < colon_indent)
112112
# unindent at the end of resources if needed
113113
indent -= 1
114114
colon_indent = nil
115115
end
116-
elsif next_token.type == :SEMIC and !colon_indent.nil? and
117-
%i[INDENT NEWLINE].include?(next_token.prev_token.type) and
118-
(next_token.next_token.nil? or next_token.next_token.type == :NEWLINE)
116+
elsif (next_token.type == :SEMIC) && !colon_indent.nil? &&
117+
%i[INDENT NEWLINE].include?(next_token.prev_token.type) &&
118+
(next_token.next_token.nil? || (next_token.next_token.type == :NEWLINE))
119119
# For a lone semicolon within a block decrement immediately. Use temp_indent because
120120
# indent will be decremented in the next line by the prev_token logic above.
121121
temp_indent -= 1
@@ -124,7 +124,7 @@ def check
124124
end
125125

126126
# obviously we have a problem
127-
if indent < 0
127+
if indent.negative?
128128
notify :error, {
129129
message: 'Error calculating indent. Please file an issue at https://github.com/relud/puppet-lint-indent-check/issues',
130130
line: token.next_token.line,
@@ -151,7 +151,7 @@ def check
151151
# For interpolated heredocs the pipe whitespace is in the HEREDOC_POST token so we need scan forward
152152
# to this and get its length.
153153
next_token = token.next_token
154-
while !next_token.nil? and next_token.type != :NEWLINE and next_token.type != :HEREDOC_POST
154+
while !next_token.nil? && (next_token.type != :NEWLINE) && (next_token.type != :HEREDOC_POST)
155155
next_token = next_token.next_token
156156
end
157157
if next_token.type == :HEREDOC_POST
@@ -195,7 +195,7 @@ def fix(problem)
195195
change = problem[:indent] - problem[:actual]
196196
indent_heredoc(problem[:token], change)
197197
next_token = problem[:token].next_token
198-
while !next_token.nil? and next_token.type != :HEREDOC_POST
198+
while !next_token.nil? && (next_token.type != :HEREDOC_POST)
199199
indent_heredoc(next_token, change) if next_token.type == :HEREDOC_MID
200200
next_token = next_token.next_token
201201
end
@@ -211,10 +211,10 @@ def fix(problem)
211211
def map_heredoc_lines(value, change, skip)
212212
char_for_indent = ' '
213213
value.split("\n").map! do |line|
214-
if skip or line.empty?
214+
if skip || line.empty?
215215
skip = false
216216
line
217-
elsif change < 0
217+
elsif change.negative?
218218
line[-change..]
219219
else
220220
(char_for_indent * change) + line

puppet-lint-strict_indent-check.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
Gem::Specification.new do |spec|
24
spec.name = 'puppet-lint-strict_indent-check'
35
spec.version = '5.0.0'

spec/puppet-lint/plugins/check_strict_indent_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper'
24

35
describe 'strict_indent' do

0 commit comments

Comments
 (0)