Skip to content

Commit

Permalink
Update to rubocop 1.59 [NTC-130] (#56)
Browse files Browse the repository at this point in the history
* Update to rubocop 1.59

* Add .idea/ to .gitignore

* Update tests

* Update .gitignore

* Add Ruby 3.3 to test matrix
  • Loading branch information
ric2b authored Jan 3, 2024
1 parent 41fab9e commit 4204db5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
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"
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

0 comments on commit 4204db5

Please sign in to comment.