Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to rubocop 1.59 [NTC-130] #56

Merged
merged 5 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ workflows:
- "3.0.0"
- "3.1.1"
- "3.2.0"
- "3.3.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could drop Ruby 2.7 support while we're at it as 2.7 is EOL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underlying rubocop version still supports it, so I think we might as well keep it as long as it doesn't hurt the maintenance of this gem.

Dropping support for ruby 2.7 might actually make it harder to move a project from 2.7 to 3+, since instead of bumping rubocop, fixing things and then bumping ruby, you are forced to either bump both of them together or go through 2 rubocop version upgrades.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
/pkg/
/spec/reports/
/tmp/

.idea/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# salsify_rubocop

## 1.59.0
- Upgrade `rubocop` to v1.59.0 to support Ruby 3.3.

## 1.43.1
- Add configuration for `Gemspec/RequiredRubyVersion` cop for configuration manifest embedded gems

Expand Down
2 changes: 1 addition & 1 deletion lib/salsify_rubocop/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SalsifyRubocop
VERSION = '1.43.1'
VERSION = '1.59.0'
end
2 changes: 1 addition & 1 deletion salsify_rubocop.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rspec_junit_formatter'

spec.add_runtime_dependency 'rubocop', '~> 1.43.0'
spec.add_runtime_dependency 'rubocop', '~> 1.59.0'
spec.add_runtime_dependency 'rubocop-performance', '~> 1.15.2'
spec.add_runtime_dependency 'rubocop-rails', '~> 2.17.4'
spec.add_runtime_dependency 'rubocop-rspec', '~> 2.16.0'
Expand Down
16 changes: 9 additions & 7 deletions spec/rubocop/cop/salsify/rails_application_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
describe RuboCop::Cop::Salsify::RailsApplicationMailer do
let(:highlights) { 'ActionMailer::Base' }

let(:message) { "#{cop.cop_name}: #{described_class::MSG}" }

subject(:cop) { described_class.new }

it "allows ApplicationMailer to be defined" do
Expand All @@ -14,55 +16,55 @@
it "corrects mailers that subclass ActionMailer::Base" do
source = "class MyMailer < ActionMailer::Base\nend"
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq("class MyMailer < ApplicationMailer\nend")
end

it "corrects single-line class definitions" do
source = 'class MyMailer < ActionMailer::Base; end'
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq('class MyMailer < ApplicationMailer; end')
end

it "corrects namespaced mailers that subclass ActionMailer::Base" do
source = "module Nested\n class MyMailer < ActionMailer::Base\n end\nend"
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq("module Nested\n class MyMailer < ApplicationMailer\n end\nend")
end

it "corrects mailers defined using nested constants" do
source = "class Nested::MyMailer < ActionMailer::Base\nend"
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq("class Nested::MyMailer < ApplicationMailer\nend")
end

it "corrects mailers defined using Class.new" do
source = 'MyMailer = Class.new(ActionMailer::Base)'
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq('MyMailer = Class.new(ApplicationMailer)')
end

it "corrects nested mailers defined using Class.new" do
source = 'Nested::MyMailer = Class.new(ActionMailer::Base)'
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq('Nested::MyMailer = Class.new(ApplicationMailer)')
end

it "corrects anonymous mailers" do
source = 'Class.new(ActionMailer::Base) {}'
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq('Class.new(ApplicationMailer) {}')
end
Expand Down
16 changes: 9 additions & 7 deletions spec/rubocop/cop/salsify/rails_application_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
describe RuboCop::Cop::Salsify::RailsApplicationSerializer do
let(:highlights) { 'ActiveModel::Serializer' }

let(:message) { "#{cop.cop_name}: #{described_class::MSG}" }

subject(:cop) { described_class.new }

it "allow ApplicationSerializer to be defined" do
Expand All @@ -14,54 +16,54 @@
it "corrects serializers that subclass ActiveModel::Serializer" do
source = "class MySerializer < ActiveModel::Serializer\nend"
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
end

it "corrects single-line class definitions" do
source = 'class MySerializer < ActiveModel::Serializer; end'
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq('class MySerializer < ApplicationSerializer; end')
end

it "corrects namespaced models that subclass ActiveModel::Serializer" do
source = "module Nested\n class MySerializer < ActiveModel::Serializer\n end\nend"
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq("module Nested\n class MySerializer < ApplicationSerializer\n end\nend")
end

it "corrects models defined using nested constants" do
source = "class Nested::MySerializer < ActiveModel::Serializer\nend"
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq("class Nested::MySerializer < ApplicationSerializer\nend")
end

it "corrects models defined using Class.new" do
source = 'MySerializer = Class.new(ActiveModel::Serializer)'
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq('MySerializer = Class.new(ApplicationSerializer)')
end

it "corrects nested models defined using Class.new" do
source = 'Nested::MySerializer = Class.new(ActiveModel::Serializer)'
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq('Nested::MySerializer = Class.new(ApplicationSerializer)')
end

it "correct anonymous models" do
source = 'Class.new(ActiveModel::Serializer) {}'
inspection = inspect_source(source)
expect(inspection[0].message).to eq(described_class::MSG)
expect(inspection[0].message).to eq(message)
expect(inspection[0].location.source).to eq(highlights)
expect(autocorrect_source(source)).to eq('Class.new(ApplicationSerializer) {}')
end
Expand Down