Skip to content

Commit 73d75d1

Browse files
authored
Merge pull request #379 from puppetlabs/CAT-2453
(CAT-2453) Update rubocop to remove rexml dependency
2 parents 1ece702 + 2eb46cf commit 73d75d1

File tree

11 files changed

+49
-41
lines changed

11 files changed

+49
-41
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ vendor/
1414
.rspec_status
1515

1616
# puppetlabs_spec_helper automatic fixtures
17-
spec/fixtures/modules/test_module
17+
spec/fixtures/modules/

.rubocop.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
---
22
inherit_from: .rubocop_todo.yml
33

4-
require: rubocop-rspec
4+
plugins:
5+
- rubocop-rspec
6+
- rubocop-rspec_rails
7+
- rubocop-performance
8+
- rubocop-factory_bot
9+
- rubocop-capybara
510
AllCops:
611
NewCops: enable
712
TargetRubyVersion: '3.1'

.rubocop_todo.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-03-10 20:03:26 UTC using RuboCop version 1.70.0.
3+
# on 2025-09-30 14:08:02 UTC using RuboCop version 1.73.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
@@ -24,6 +24,13 @@ Lint/EmptyClass:
2424
- 'spec/puppet/resource_api/transport_spec.rb'
2525
- 'spec/puppet/resource_api_spec.rb'
2626

27+
# Offense count: 5
28+
# Configuration parameters: MinSize.
29+
Performance/CollectionLiteralInLoop:
30+
Exclude:
31+
- 'lib/puppet/resource_api.rb'
32+
- 'spec/puppet/resource_api/data_type_handling_spec.rb'
33+
2734
# Offense count: 25
2835
# Configuration parameters: IgnoredMetadata.
2936
RSpec/DescribeClass:
@@ -70,8 +77,6 @@ RSpec/SubjectStub:
7077

7178
# Offense count: 24
7279
# This cop supports unsafe autocorrection (--autocorrect-all).
73-
# Configuration parameters: EnforcedStyle.
74-
# SupportedStyles: constant, string
7580
RSpec/VerifiedDoubleReference:
7681
Exclude:
7782
- 'spec/integration/resource_api_spec.rb'

Gemfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ group :tests do
1919
# since the Resource API runs inside the puppetserver, test against the JRuby versions we ship
2020
# these require special dependencies to have everything load properly
2121
# rubocop 1.48 supports JRuby 9.3+, which includes coverage for versions we support
22-
gem 'rubocop', '~> 1.70.0', require: false
23-
gem 'rubocop-rspec', '~> 2.20.0', require: false
24-
gem 'rubocop-performance', '~> 1.17.1', require: false
22+
gem 'rubocop', '~> 1.73.0', require: false
23+
gem 'rubocop-rspec', '~> 3.5.0', require: false
24+
gem 'rubocop-performance', '~> 1.24.0', require: false
25+
gem 'rubocop-rspec_rails', '~> 2.31.0', require: false
26+
gem 'rubocop-factory_bot', '~> 2.27.0', require: false
27+
gem 'rubocop-capybara', '~> 2.22.0', require: false
2528
end
2629

2730
group :development do

spec/integration/resource_api_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,7 @@ def get(_context)
239239
end
240240

241241
before do
242-
allow(catalog).to receive(:resource).and_return nil
243-
allow(catalog).to receive(:alias).and_return nil
244-
allow(catalog).to receive(:host_config?).and_return true
242+
allow(catalog).to receive_messages(resource: nil, alias: nil, host_config?: true)
245243
end
246244

247245
it('flushes') { expect { instance.flush }.not_to raise_exception }

spec/puppet/resource_api/glue_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136

137137
it { expect(value <=> 'string').to eq(-1) }
138138
# Avoid this test on jruby 1.7, where it is hitting a implementation inconsistency and `'string' <=> value` returns `nil`
139-
it('compares to a string', j17_exclude: true) { expect('string' <=> value).to eq 1 }
139+
it('compares to a string', :j17_exclude) { expect('string' <=> value).to eq 1 }
140140
it { expect(value <=> described_class[b: 'b', c: 'c']).to eq 0 }
141141
it { expect(value <=> described_class[d: 'd']).to eq(-1) }
142142
it { expect(value <=> described_class[a: 'a']).to eq 1 }

spec/puppet/resource_api/property_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@
203203
allow(resource).to receive(:rsapi_canonicalized_target_state)
204204
allow(resource).to receive(:rsapi_current_state)
205205
allow(resource).to receive(:rsapi_title)
206-
allow(referrable_type_custom_insync).to receive(:context).and_return(context)
207-
allow(referrable_type_custom_insync).to receive(:my_provider).and_return(test_provider_with_insync)
206+
allow(referrable_type_custom_insync).to receive_messages(context: context, my_provider: test_provider_with_insync)
208207
end
209208

210209
context 'when the property is not rsapi_custom_insync_trigger' do

spec/puppet/resource_api/simple_provider_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,7 @@ def delete(context, _name); end
445445
before do
446446
allow(context).to receive(:updating).with('title').and_yield
447447
allow(type_def).to receive(:feature?).with('simple_get_filter')
448-
allow(type_def).to receive(:ensurable?).and_return(false)
449-
allow(type_def).to receive(:namevars).and_return([:name])
448+
allow(type_def).to receive_messages(ensurable?: false, namevars: [:name])
450449
end
451450

452451
it { expect { provider.set(context, changes) }.to raise_error(/SimpleProvider cannot be used with a Type that is not ensurable/) }

spec/puppet/resource_api/transport/wrapper_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
require 'puppet/resource_api/transport/wrapper'
77
require_relative '../../../fixtures/test_module/lib/puppet/transport/test_device'
88

9-
RSpec.describe Puppet::ResourceApi::Transport::Wrapper, agent_test: true do
9+
RSpec.describe Puppet::ResourceApi::Transport::Wrapper, :agent_test do
1010
describe '#initialize(name, url_or_config)' do
1111
before do
1212
module Puppet::Transport
@@ -64,8 +64,7 @@ class SomethingSomethingDarkside; end
6464
let(:transport) { instance_double(Puppet::Transport::TestDevice, 'transport') }
6565

6666
it 'returns the facts provided by the transport' do
67-
allow(Puppet::ResourceApi::Transport).to receive(:connect).and_return(transport)
68-
allow(Puppet::ResourceApi::Transport).to receive(:list).and_return(schema: :dummy)
67+
allow(Puppet::ResourceApi::Transport).to receive_messages(connect: transport, list: { schema: :dummy })
6968
allow(Puppet::ResourceApi::PuppetContext).to receive(:new).and_return(context)
7069
allow(transport).to receive(:facts).with(context).and_return(facts)
7170

spec/puppet/resource_api/transport_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def change_environment(name = nil)
178178
end
179179
end
180180

181-
describe '#connect(name, connection_info)', agent_test: true do
181+
describe '#connect(name, connection_info)', :agent_test do
182182
let(:name) { 'test_target' }
183183
let(:schema) do
184184
{
@@ -274,7 +274,7 @@ class Wibble; end
274274
end
275275
end
276276

277-
describe '#validate(name, connection_info)', agent_test: true do
277+
describe '#validate(name, connection_info)', :agent_test do
278278
context 'when the transport does not exist' do
279279
it { expect { described_class.send(:validate, 'wibble', {}) }.to raise_error LoadError, %r{(no such file to load|cannot load such file) -- puppet/transport/schema/wibble} }
280280
end

0 commit comments

Comments
 (0)