Prefer single-quoted strings when you don't need string interpolation or special symbols. Wontfix
$stderr.puts "Yarn executable was not detected in the system."
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Use warn
instead of $stderr.puts
to allow such output to be disabled. Wontfix
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop identifies places where $stderr.puts
can be replaced by
warn
. The latter has the advantage of easily being disabled by,
the -W0
interpreter flag or setting $VERBOSE
to nil
.
Example:
# bad
$stderr.puts('hello')
# good
warn('hello')
Use warn
instead of $stderr.puts
to allow such output to be disabled. Wontfix
$stderr.puts "Yarn executable was not detected in the system."
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop identifies places where $stderr.puts
can be replaced by
warn
. The latter has the advantage of easily being disabled by,
the -W0
interpreter flag or setting $VERBOSE
to nil
.
Example:
# bad
$stderr.puts('hello')
# good
warn('hello')
Redundant begin
block detected. Wontfix
begin
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant begin
blocks.
Currently it checks for code like this:
Example:
# bad
def redundant
begin
ala
bala
rescue StandardError => e
something
end
end
# good
def preferred
ala
bala
rescue StandardError => e
something
end
# bad
# When using Ruby 2.5 or later.
do_something do
begin
something
rescue => ex
anything
end
end
# good
# In Ruby 2.5 or later, you can omit `begin` in `do-end` block.
do_something do
something
rescue => ex
anything
end
# good
# Stabby lambdas don't support implicit `begin` in `do-end` blocks.
-> do
begin
foo
rescue Bar
baz
end
end
Prefer single-quoted strings when you don't need string interpolation or special symbols. Wontfix
exec "yarnpkg", *ARGV
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Missing magic comment # frozen_string_literal: true
. Wontfix
#!/usr/bin/env ruby
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop is designed to help upgrade to after 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
after 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: always (default)
# 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
Prefer single-quoted strings when you don't need string interpolation or special symbols. Wontfix
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"