Skip to content

Commit 1afe627

Browse files
Merge pull request #7 from puppetlabs/CAT-1688-Upgrade_rubocop
(CAT-1688) Upgrade rubocop to `~> 1.50.0`
2 parents 409c5c9 + 6cb1792 commit 1afe627

File tree

18 files changed

+47
-89
lines changed

18 files changed

+47
-89
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
inherit_from: .rubocop_todo.yml
22

33
AllCops:
4+
NewCops: enable
45
Include:
56
- 'lib/**/*.rb'
67
- 'puppetfile-cli.rb'

.rubocop_todo.yml

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-10-27 07:36:27 UTC using RuboCop version 1.48.1.
3+
# on 2024-01-22 11:46:15 UTC using RuboCop version 1.50.2.
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
77
# versions of RuboCop, may require this file to be generated again.
88

99
# Offense count: 1
10+
Lint/MissingSuper:
11+
Exclude:
12+
- 'lib/puppetfile-resolver/puppetfile/parser/errors.rb'
13+
14+
# Offense count: 2
1015
# This cop supports unsafe autocorrection (--autocorrect-all).
11-
Lint/DuplicateRequire:
16+
Lint/NonAtomicFileOperation:
1217
Exclude:
13-
- 'lib/puppetfile-resolver/spec_searchers/git/gclone.rb'
18+
- 'lib/puppetfile-resolver/cache/persistent.rb'
1419

15-
# Offense count: 1
16-
Lint/MissingSuper:
20+
# Offense count: 3
21+
# This cop supports unsafe autocorrection (--autocorrect-all).
22+
Lint/OrAssignmentToConstant:
1723
Exclude:
18-
- 'lib/puppetfile-resolver/puppetfile/parser/errors.rb'
24+
- 'lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb'
25+
- 'lib/puppetfile-resolver/spec_searchers/forge_configuration.rb'
26+
- 'lib/puppetfile-resolver/version.rb'
1927

2028
# Offense count: 2
2129
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
@@ -26,33 +34,17 @@ Naming/FileName:
2634
- 'lib/puppetfile-resolver.rb'
2735
- 'puppetfile-cli.rb'
2836

29-
# Offense count: 27
30-
# This cop supports safe autocorrection (--autocorrect).
31-
# Configuration parameters: EnforcedStyle.
32-
# SupportedStyles: separated, grouped
33-
Style/AccessorGrouping:
37+
# Offense count: 1
38+
Style/CombinableLoops:
3439
Exclude:
35-
- 'lib/puppetfile-resolver/models/module_dependency.rb'
36-
- 'lib/puppetfile-resolver/models/module_specification.rb'
3740
- 'lib/puppetfile-resolver/puppetfile/document.rb'
38-
- 'lib/puppetfile-resolver/puppetfile/git_module.rb'
39-
- 'lib/puppetfile-resolver/puppetfile/validation_errors.rb'
40-
- 'lib/puppetfile-resolver/resolver.rb'
41-
- 'lib/puppetfile-resolver/spec_searchers/configuration.rb'
4241

4342
# Offense count: 1
44-
# This cop supports safe autocorrection (--autocorrect).
45-
# Configuration parameters: AllowedMethods, AllowedPatterns.
46-
# AllowedMethods: ==, equal?, eql?
47-
Style/ClassEqualityComparison:
43+
# This cop supports unsafe autocorrection (--autocorrect-all).
44+
Style/ConcatArrayLiterals:
4845
Exclude:
4946
- 'lib/puppetfile-resolver/util.rb'
5047

51-
# Offense count: 1
52-
Style/CombinableLoops:
53-
Exclude:
54-
- 'lib/puppetfile-resolver/puppetfile/document.rb'
55-
5648
# Offense count: 1
5749
# Configuration parameters: AllowedMethods.
5850
# AllowedMethods: respond_to_missing?
@@ -62,21 +54,6 @@ Style/OptionalBooleanParameter:
6254

6355
# Offense count: 1
6456
# This cop supports safe autocorrection (--autocorrect).
65-
Style/RedundantAssignment:
57+
Style/RedundantFreeze:
6658
Exclude:
67-
- 'lib/puppetfile-resolver/puppetfile/parser/r10k_eval/module/local.rb'
68-
69-
# Offense count: 3
70-
# This cop supports safe autocorrection (--autocorrect).
71-
Style/RedundantRegexpEscape:
72-
Exclude:
73-
- 'lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb'
74-
75-
# Offense count: 7
76-
# This cop supports unsafe autocorrection (--autocorrect-all).
77-
# Configuration parameters: Mode.
78-
Style/StringConcatenation:
79-
Exclude:
80-
- 'lib/puppetfile-resolver/cache/persistent.rb'
81-
- 'lib/puppetfile-resolver/spec_searchers/git/github.rb'
82-
- 'lib/puppetfile-resolver/spec_searchers/git/gitlab.rb'
59+
- 'lib/puppetfile-resolver/puppetfile/parser/r10k_eval/module/forge.rb'

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ group :test do
88
gem 'rspec-collection_matchers', '~> 1.0'
99
gem 'rspec-its', '~> 1.0'
1010

11-
gem 'rubocop', '~> 1.48.1'
11+
gem 'rubocop', '~> 1.50.0'
1212
gem 'rubocop-rspec', '~> 2.19'
1313
gem 'rubocop-performance', '~> 1.16'
1414

lib/puppetfile-resolver/cache/persistent.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def persist(name, content_string)
4343
private
4444

4545
def to_cache_name(name)
46-
::Digest::SHA256.hexdigest(name) + '.txt'
46+
"#{::Digest::SHA256.hexdigest(name)}.txt"
4747
end
4848
end
4949
end

lib/puppetfile-resolver/models/module_dependency.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
module PuppetfileResolver
44
module Models
55
class ModuleDependency
6-
attr_accessor :name
7-
attr_accessor :owner
8-
attr_accessor :version_requirement
6+
attr_accessor :name, :owner, :version_requirement
97

108
def initialize(options = {})
119
# Munge the name

lib/puppetfile-resolver/models/module_specification.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
module PuppetfileResolver
88
module Models
99
class ModuleSpecification
10-
attr_accessor :name
11-
attr_accessor :owner
12-
attr_accessor :version
13-
attr_accessor :origin # Same as R10K module :type
14-
attr_accessor :resolver_flags
10+
attr_accessor :name, :owner, :version, :origin, :resolver_flags # origin attr same as R10K module :type
1511

1612
def initialize(options = {})
1713
require 'semantic_puppet'

lib/puppetfile-resolver/puppetfile/document.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
module PuppetfileResolver
66
module Puppetfile
77
class DocumentLocation
8-
attr_accessor :start_line # Base 0
9-
attr_accessor :start_char # Base 0
10-
attr_accessor :end_line # Base 0
11-
attr_accessor :end_char # Base 0
8+
attr_accessor :start_line, :start_char, :end_line, :end_char # Base 0 # Base 0 # Base 0 # Base 0
129
end
1310

1411
class Document
15-
attr_accessor :forge_uri
12+
attr_accessor :forge_uri, :content
1613
attr_reader :modules
17-
attr_accessor :content
1814

1915
def initialize(puppetfile_content)
2016
@content = puppetfile_content

lib/puppetfile-resolver/puppetfile/git_module.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
module PuppetfileResolver
66
module Puppetfile
77
class GitModule < BaseModule
8-
attr_accessor :remote
9-
attr_accessor :ref
10-
attr_accessor :commit
11-
attr_accessor :tag
8+
attr_accessor :remote, :ref, :commit, :tag
129

1310
def initialize(title)
1411
super

lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,19 @@ def self.parse(puppetfile_contents)
6565
def self.post_process_flags!(document)
6666
flag_ranges = {}
6767
document.content.lines.each_with_index do |line, index|
68-
if (matches = line.match(%r{^\s*# resolver:disable ([A-Za-z\/,]+)(?:\s|$)}))
68+
if (matches = line.match(%r{^\s*# resolver:disable ([A-Za-z/,]+)(?:\s|$)}))
6969
flags_from_line(matches[1]).each do |flag|
7070
# Start a flag range if there isn't already one going
7171
next unless flag_ranges[flag].nil?
7272
flag_ranges[flag] = index
7373
end
74-
elsif (matches = line.match(%r{# resolver:disable ([A-Za-z\/,]+)(?:\s|$)}))
74+
elsif (matches = line.match(%r{# resolver:disable ([A-Za-z/,]+)(?:\s|$)}))
7575
flags_from_line(matches[1]).each do |flag|
7676
# Assert the flag if we're not already within a range
7777
next unless flag_ranges[flag].nil?
7878
assert_resolver_flag(document, flag, index, index)
7979
end
80-
elsif (matches = line.match(%r{^\s*# resolver:enable ([A-Za-z\/,]+)(?:\s|$)}))
80+
elsif (matches = line.match(%r{^\s*# resolver:enable ([A-Za-z/,]+)(?:\s|$)}))
8181
flags_from_line(matches[1]).each do |flag|
8282
# End a flag range if there isn't already one going
8383
next if flag_ranges[flag].nil?
@@ -122,8 +122,8 @@ def self.assert_resolver_flag(document, flag, from_line, to_line)
122122
next if mod.location.start_line.nil? || mod.location.end_line.nil?
123123

124124
# If the module doesn't span the range we're looking for (from_line --> to_line) ignore it
125-
next unless mod.location.start_line >= from_line && mod.location.start_line <= to_line ||
126-
mod.location.end_line >= from_line && mod.location.end_line <= to_line
125+
next unless (mod.location.start_line >= from_line && mod.location.start_line <= to_line) ||
126+
(mod.location.end_line >= from_line && mod.location.end_line <= to_line)
127127
mod.resolver_flags << flag unless mod.resolver_flags.include?(flag)
128128
end
129129
nil

lib/puppetfile-resolver/puppetfile/parser/r10k_eval/module/local.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def self.implements?(_name, args)
1515
end
1616

1717
def self.to_document_module(title, _args)
18-
mod = ::PuppetfileResolver::Puppetfile::LocalModule.new(title)
19-
mod
18+
::PuppetfileResolver::Puppetfile::LocalModule.new(title)
2019
end
2120
end
2221
end

0 commit comments

Comments
 (0)