Missing magic comment # frozen_string_literal: true
. Open
source "https://rubygems.org"
- Read upRead up
- Exclude checks
This cop is designed to help upgrade to Ruby 3.0. It will add the
comment # frozen_string_literal: true
to the top of files to
enable frozen string literals. Frozen string literals may be default
in Ruby 3.0. The comment will be added below a shebang and encoding
comment. The frozen string literal comment is only valid in Ruby 2.3+.
Example: EnforcedStyle: when_needed (default)
# The `when_needed` style will add the frozen string literal comment
# to files only when the `TargetRubyVersion` is set to 2.3+.
# bad
module Foo
# ...
end
# good
# frozen_string_literal: true
module Foo
# ...
end
Example: EnforcedStyle: always
# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
# ...
end
# good
# frozen_string_literal: true
module Bar
# ...
end
Example: EnforcedStyle: never
# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true
module Baz
# ...
end
# good
module Baz
# ...
end
Gem turbo-rails
requirements already given on line 35 of the Gemfile. Open
gem 'turbo-rails'
- Read upRead up
- Exclude checks
A Gem's requirements should be listed only once in a Gemfile.
Example:
# bad
gem 'rubocop'
gem 'rubocop'
# bad
group :development do
gem 'rubocop'
end
group :test do
gem 'rubocop'
end
# good
group :development, :test do
gem 'rubocop'
end
# good
gem 'rubocop', groups: [:development, :test]
Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem loofah
should appear before simplecov
. Open
gem "loofah", "< 2.21.0" # Workaround for `uninitialized constant Nokogiri::HTML4`
- Read upRead up
- Exclude checks
Gems should be alphabetically sorted within groups.
Example:
# bad
gem 'rubocop'
gem 'rspec'
# good
gem 'rspec'
gem 'rubocop'
# good
gem 'rubocop'
gem 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'
Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem activerecord-jdbcsqlite3-adapter
should appear before minitest
. Open
gem "activerecord-jdbcsqlite3-adapter"
- Read upRead up
- Exclude checks
Gems should be alphabetically sorted within groups.
Example:
# bad
gem 'rubocop'
gem 'rspec'
# good
gem 'rspec'
gem 'rubocop'
# good
gem 'rubocop'
gem 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'
Gem redis
requirements already given on line 36 of the Gemfile. Open
gem 'redis', '~> 4.0'
- Read upRead up
- Exclude checks
A Gem's requirements should be listed only once in a Gemfile.
Example:
# bad
gem 'rubocop'
gem 'rubocop'
# bad
group :development do
gem 'rubocop'
end
group :test do
gem 'rubocop'
end
# good
group :development, :test do
gem 'rubocop'
end
# good
gem 'rubocop', groups: [:development, :test]
Gem sqlite3
requirements already given on line 9 of the Gemfile. Open
gem 'sqlite3', '~> 1.3.6'
- Read upRead up
- Exclude checks
A Gem's requirements should be listed only once in a Gemfile.
Example:
# bad
gem 'rubocop'
gem 'rubocop'
# bad
group :development do
gem 'rubocop'
end
group :test do
gem 'rubocop'
end
# good
group :development, :test do
gem 'rubocop'
end
# good
gem 'rubocop', groups: [:development, :test]
Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem redis
should appear before turbo-rails
. Open
gem "redis", "~> 4.0"
- Read upRead up
- Exclude checks
Gems should be alphabetically sorted within groups.
Example:
# bad
gem 'rubocop'
gem 'rspec'
# good
gem 'rspec'
gem 'rubocop'
# good
gem 'rubocop'
gem 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'
Gem rails
requirements already given on line 22 of the Gemfile. Open
gem 'rails', github: 'rails/rails'
- Read upRead up
- Exclude checks
A Gem's requirements should be listed only once in a Gemfile.
Example:
# bad
gem 'rubocop'
gem 'rubocop'
# bad
group :development do
gem 'rubocop'
end
group :test do
gem 'rubocop'
end
# good
group :development, :test do
gem 'rubocop'
end
# good
gem 'rubocop', groups: [:development, :test]
Gem rails
requirements already given on line 22 of the Gemfile. Open
gem 'rails', "~> #{rails_version}.0"
- Read upRead up
- Exclude checks
A Gem's requirements should be listed only once in a Gemfile.
Example:
# bad
gem 'rubocop'
gem 'rubocop'
# bad
group :development do
gem 'rubocop'
end
group :test do
gem 'rubocop'
end
# good
group :development, :test do
gem 'rubocop'
end
# good
gem 'rubocop', groups: [:development, :test]
Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem redis
should appear before turbo-rails
. Open
gem 'redis', '~> 4.0'
- Read upRead up
- Exclude checks
Gems should be alphabetically sorted within groups.
Example:
# bad
gem 'rubocop'
gem 'rspec'
# good
gem 'rspec'
gem 'rubocop'
# good
gem 'rubocop'
gem 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'