Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Open
require 'pp'
- Read upRead up
- 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"
Final newline missing. Open
end
- Read upRead up
- Exclude checks
This cop looks for trailing blank lines and a final newline in the source code.
Example: EnforcedStyle: finalblankline
# `final_blank_line` looks for one blank line followed by a new line
# at the end of files.
# bad
class Foo; end
# EOF
# bad
class Foo; end # EOF
# good
class Foo; end
# EOF
Example: EnforcedStyle: final_newline (default)
# `final_newline` looks for one newline at the end of files.
# bad
class Foo; end
# EOF
# bad
class Foo; end # EOF
# good
class Foo; end
# EOF
Prefer each
over for
. Open
for stage in config.stages do
- Read upRead up
- Exclude checks
This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.
Example: EnforcedStyle: each (default)
# bad
def foo
for n in [1, 2, 3] do
puts n
end
end
# good
def foo
[1, 2, 3].each do |n|
puts n
end
end
Example: EnforcedStyle: for
# bad
def foo
[1, 2, 3].each do |n|
puts n
end
end
# good
def foo
for n in [1, 2, 3] do
puts n
end
end
Prefer each
over for
. Open
for role in stage_config.roles do
- Read upRead up
- Exclude checks
This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.
Example: EnforcedStyle: each (default)
# bad
def foo
for n in [1, 2, 3] do
puts n
end
end
# good
def foo
[1, 2, 3].each do |n|
puts n
end
end
Example: EnforcedStyle: for
# bad
def foo
[1, 2, 3].each do |n|
puts n
end
end
# good
def foo
for n in [1, 2, 3] do
puts n
end
end
Prefer each
over for
. Open
for server in role[1].servers do
- Read upRead up
- Exclude checks
This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.
Example: EnforcedStyle: each (default)
# bad
def foo
for n in [1, 2, 3] do
puts n
end
end
# good
def foo
[1, 2, 3].each do |n|
puts n
end
end
Example: EnforcedStyle: for
# bad
def foo
[1, 2, 3].each do |n|
puts n
end
end
# good
def foo
for n in [1, 2, 3] do
puts n
end
end
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Open
require 'capistrano/configuration'
- Read upRead up
- 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"
Script file cap_info.rb doesn't have execute permission. Open
#!/usr/bin/env ruby
- Read upRead up
- Exclude checks
This cop checks if a file which has a shebang line as its first line is granted execute permission.
Example:
# bad
# A file which has a shebang line as its first line is not
# granted execute permission.
#!/usr/bin/env ruby
puts 'hello, world'
# good
# A file which has a shebang line as its first line is
# granted execute permission.
#!/usr/bin/env ruby
puts 'hello, world'
# good
# A file which has not a shebang line as its first line is not
# granted execute permission.
puts 'hello, world'
Unnecessary spacing detected. Open
stage_config.logger.level = 1 # -v
- Read upRead up
- Exclude checks
This cop checks for extra/unnecessary whitespace.
Example:
# good if AllowForAlignment is true
name = "RuboCop"
# Some comment and an empty line
website += "/rubocop-hq/rubocop" unless cond
puts "rubocop" if debug
# bad for any configuration
set_app("RuboCop")
website = "https://github.com/rubocop-hq/rubocop"
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Open
require 'rubygems'
- Read upRead up
- 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"
Unnecessary spacing detected. Open
config.logger.level = 1 # -v
- Read upRead up
- Exclude checks
This cop checks for extra/unnecessary whitespace.
Example:
# good if AllowForAlignment is true
name = "RuboCop"
# Some comment and an empty line
website += "/rubocop-hq/rubocop" unless cond
puts "rubocop" if debug
# bad for any configuration
set_app("RuboCop")
website = "https://github.com/rubocop-hq/rubocop"