Skip to content

Commit

Permalink
Add frozen string literal magic comment
Browse files Browse the repository at this point in the history
This cop was disabled probably by mistake, since it is present in both
Arbre and Active Admin gems

The only production code affected is:
- app/controllers/inherited_resources/base.rb
- lib/inherited_resources/version.rb

Change to `version.rb` is safe.

After inspecting the source code of `InheritedResources` module, the
change seems safe, but it can represent a breaking change in third-party application.

Since we are bumping the major version number, it would be fine to break
if documented.

Fixed with `rubocop -A`

Also adds `Style/Encoding` cop for parity with Arbre
  • Loading branch information
tagliala committed Aug 26, 2024
1 parent fdc9a9c commit 7fccb80
Show file tree
Hide file tree
Showing 36 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,5 +373,13 @@ Performance/UnfreezeString:
Performance/UriDefaultParser:
Enabled: true

Style/Encoding:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true
Exclude:
- bin/console

Style/HashSyntax:
Enabled: true
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## Version 2.0.0

* Test against Rails 7.2 [#921][].
* Add frozen string literal to `InheritedResources` module [#933][].
* Change return codes to new Responders defaults [#918][].

## Version 1.14.0
Expand Down Expand Up @@ -234,3 +235,4 @@ _No changes_.
[#873]: https://github.com/activeadmin/inherited_resources/pull/873
[#918]: https://github.com/activeadmin/inherited_resources/pull/918
[#921]: https://github.com/activeadmin/inherited_resources/pull/921
[#921]: https://github.com/activeadmin/inherited_resources/pull/933
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

gemspec path: '.'
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rdoc/task'
Expand Down
1 change: 1 addition & 0 deletions app/controllers/inherited_resources/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module InheritedResources
# = Base
#
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_61/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

gemspec path: '../..'
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_70/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

gemspec path: '../..'
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_71/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

gemspec path: '../..'
Expand Down
1 change: 1 addition & 0 deletions inherited_resources.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "inherited_resources/version"
Expand Down
1 change: 1 addition & 0 deletions lib/inherited_resources/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module InheritedResources
VERSION = '2.0.0'.freeze
end
1 change: 1 addition & 0 deletions test/aliases_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Student
Expand Down
1 change: 1 addition & 0 deletions test/association_chain_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Pet
Expand Down
1 change: 1 addition & 0 deletions test/autoload/engine.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module MyTestNamespace
class Engine; end
end
1 change: 1 addition & 0 deletions test/base_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class User
Expand Down
1 change: 1 addition & 0 deletions test/belongs_to_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Post
Expand Down
1 change: 1 addition & 0 deletions test/belongs_to_with_shallow_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Post
Expand Down
1 change: 1 addition & 0 deletions test/changelog_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class ChangelogTest < ActiveSupport::TestCase
Expand Down
1 change: 1 addition & 0 deletions test/class_methods_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Book; end
Expand Down
1 change: 1 addition & 0 deletions test/customized_base_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Car
Expand Down
1 change: 1 addition & 0 deletions test/customized_belongs_to_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class GreatSchool
Expand Down
1 change: 1 addition & 0 deletions test/customized_redirect_to_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Post;
Expand Down
1 change: 1 addition & 0 deletions test/defaults_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Malarz
Expand Down
1 change: 1 addition & 0 deletions test/multiple_nested_optional_belongs_to_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Student; end
Expand Down
1 change: 1 addition & 0 deletions test/nested_belongs_to_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Country
Expand Down
1 change: 1 addition & 0 deletions test/nested_belongs_to_with_shallow_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Dresser
Expand Down
1 change: 1 addition & 0 deletions test/nested_model_with_shallow_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Subfaculty
Expand Down
1 change: 1 addition & 0 deletions test/nested_singleton_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

# This test file is instead to test the how controller flow and actions
Expand Down
1 change: 1 addition & 0 deletions test/optional_belongs_to_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Brands; end
Expand Down
1 change: 1 addition & 0 deletions test/polymorphic_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Factory; end
Expand Down
1 change: 1 addition & 0 deletions test/redirect_to_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Machine;
Expand Down
1 change: 1 addition & 0 deletions test/singleton_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

# This test file is instead to test the how controller flow and actions
Expand Down
1 change: 1 addition & 0 deletions test/strong_parameters_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class Widget
Expand Down
1 change: 1 addition & 0 deletions test/tasks/gemfile_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "minitest"

class GemfilesTest < Minitest::Test
Expand Down
1 change: 1 addition & 0 deletions test/tasks/gemspec_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "minitest"
require "open3"
require "inherited_resources/version"
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
if ENV.fetch('COVERAGE', false)
require 'simplecov'
require 'simplecov-cobertura'
Expand Down
1 change: 1 addition & 0 deletions test/url_helpers_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'

class ModelBase
Expand Down

0 comments on commit 7fccb80

Please sign in to comment.