Method has too many lines. [20/15] Open
def ask_to_join
asked_to_join = File.join(SequenceServer::DOTDIR, 'asked_to_join')
unless File.exist?(asked_to_join)
puts
puts <<~MSG
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
You can set literals you want to fold with CountAsOne
.
Available are: 'array', 'hash', and 'heredoc'. Each literal
will be counted as one line regardless of its actual size.
NOTE: The ExcludedMethods
configuration is deprecated and only kept
for backwards compatibility. Please use IgnoredMethods
instead.
Example: CountAsOne: ['array', 'heredoc']
def m
array = [ # +1
1,
2
]
hash = { # +3
key: 'value'
}
<<~HEREDOC # +1
Heredoc
content.
HEREDOC
end # 5 points
Favor modifier unless
usage when having a single-line body. Another good alternative is the usage of control flow &&
/||
. Open
unless File.basename(response) == 'bin'
- Read upRead up
- Exclude checks
Checks for if
and unless
statements that would fit on one line if
written as modifier if
/unless
. The cop also checks for modifier
if
/unless
lines that exceed the maximum line length.
The maximum line length is configured in the Layout/LineLength
cop. The tab size is configured in the IndentationWidth
of the
Layout/IndentationStyle
cop.
Example:
# bad
if condition
do_stuff(bar)
end
unless qux.empty?
Foo.do_something
end
do_something_with_a_long_name(arg) if long_condition_that_prevents_code_fit_on_single_line
# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?
if long_condition_that_prevents_code_fit_on_single_line
do_something_with_a_long_name(arg)
end
if short_condition # a long comment that makes it too long if it were just a single line
do_something
end
Redundant single-element character class, [n]
can be replaced with n
. Open
SequenceServer.makeblastdb.run unless response =~ /^[n]$/i
- Read upRead up
- Exclude checks
This cop checks for unnecessary single-element Regexp character classes.
Example:
# bad
r = /[x]/
# good
r = /x/
# bad
r = /[\s]/
# good
r = /\s/
# bad
r = %r{/[b]}
# good
r = %r{/b}
# good
r = /[ab]/
Align the elements of an array literal if they span more than one line. Open
SequenceServer::BLAST_DATABASE_ERROR,
- Read upRead up
- Exclude checks
Here we check if the elements of a multi-line array literal are aligned.
Example: EnforcedStyle: withfirstelement (default)
# good
array = [1, 2, 3,
4, 5, 6]
array = ['run',
'forrest',
'run']
# bad
array = [1, 2, 3,
4, 5, 6]
array = ['run',
'forrest',
'run']
Example: EnforcedStyle: withfixedindentation
# good
array = [1, 2, 3,
4, 5, 6]
# bad
array = [1, 2, 3,
4, 5, 6]
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
"1FAIpQLSe7sOCiKzYbI7LwErid-g3wfIU5Zpi6VTm0ILJyR036RqC8zg/formResponse " \
- 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"
Use $stdin
instead of STDIN
. Open
response = STDIN.gets.to_s.strip
- Read upRead up
- Exclude checks
This cop enforces the use of $stdout/$stderr/$stdin
instead of STDOUT/STDERR/STDIN
.
STDOUT/STDERR/STDIN
are constants, and while you can actually
reassign (possibly to redirect some stream) constants in Ruby, you'll get
an interpreter warning if you do so.
Safety:
Autocorrection is unsafe because STDOUT
and $stdout
may point to different
objects, for example.
Example:
# bad
STDOUT.puts('hello')
hash = { out: STDOUT, key: value }
def m(out = STDOUT)
out.puts('hello')
end
# good
$stdout.puts('hello')
hash = { out: $stdout, key: value }
def m(out = $stdout)
out.puts('hello')
end
Incorrect indentation detected (column 4 instead of 7). Open
# on 'doctor',
- Read upRead up
- Exclude checks
This cop checks the indentation of comments.
Example:
# bad
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
# good
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
Use 2 spaces for indentation in a heredoc. Open
SequenceServer has scanned your databases directory and will now offer
to convert FASTA files into BLAST databases. It will also offer to
reformat any old-format BLAST databases and those created without
the -parse_seqids option of makeblastdb (-parse_seqids option is
required for sequence retrieval to correctly work).
- Read upRead up
- Exclude checks
This cop checks the indentation of the here document bodies. The bodies are indented one step.
Note: When Layout/LineLength
's AllowHeredoc
is false (not default),
this cop does not add any offenses for long here documents to
avoid Layout/LineLength
's offenses.
Example:
# bad
<<-RUBY
something
RUBY
# good
<<~RUBY
something
RUBY
Avoid rescuing without specifying an error class. Open
rescue => e
- Read upRead up
- Exclude checks
This cop checks for rescuing StandardError
. There are two supported
styles implicit
and explicit
. This cop will not register an offense
if any error other than StandardError
is specified.
Example: EnforcedStyle: implicit
# `implicit` will enforce using `rescue` instead of
# `rescue StandardError`.
# bad
begin
foo
rescue StandardError
bar
end
# good
begin
foo
rescue
bar
end
# good
begin
foo
rescue OtherError
bar
end
# good
begin
foo
rescue StandardError, SecurityError
bar
end
Example: EnforcedStyle: explicit (default)
# `explicit` will enforce using `rescue StandardError`
# instead of `rescue`.
# bad
begin
foo
rescue
bar
end
# good
begin
foo
rescue StandardError
bar
end
# good
begin
foo
rescue OtherError
bar
end
# good
begin
foo
rescue StandardError, SecurityError
bar
end
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
post_email_cmd = "curl -m 5 https://docs.google.com/forms/u/0/d/e/" \
- 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"
Align the elements of an array literal if they span more than one line. Open
SequenceServer::CONFIG_FILE_ERROR,
- Read upRead up
- Exclude checks
Here we check if the elements of a multi-line array literal are aligned.
Example: EnforcedStyle: withfirstelement (default)
# good
array = [1, 2, 3,
4, 5, 6]
array = ['run',
'forrest',
'run']
# bad
array = [1, 2, 3,
4, 5, 6]
array = ['run',
'forrest',
'run']
Example: EnforcedStyle: withfixedindentation
# good
array = [1, 2, 3,
4, 5, 6]
# bad
array = [1, 2, 3,
4, 5, 6]
Use the new Ruby 1.9 hash syntax. Open
params = {:xml => xml_file_path}
- Read upRead up
- Exclude checks
This cop checks hash literal syntax.
It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).
A separate offense is registered for each problematic pair.
The supported styles are:
- ruby19 - forces use of the 1.9 syntax (e.g.
{a: 1}
) when hashes have all symbols for keys - hash_rockets - forces use of hash rockets for all hashes
- nomixedkeys - simply checks for hashes with mixed syntaxes
- ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes
Example: EnforcedStyle: ruby19 (default)
# bad
{:a => 2}
{b: 1, :c => 2}
# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden
Example: EnforcedStyle: hash_rockets
# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}
# good
{:a => 1, :b => 2}
Example: EnforcedStyle: nomixedkeys
# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}
# good
{:a => 1, :b => 2}
{c: 1, d: 2}
Example: EnforcedStyle: ruby19nomixed_keys
# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets
# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}
Use 2 spaces for indentation in a heredoc. Open
Do you want to be notified of SequenceServer releases and any
other important announcements (3-12 messages a year)? If yes,
please provide your email address below or press enter to
continue (you won't be prompted again).
MSG
- Read upRead up
- Exclude checks
This cop checks the indentation of the here document bodies. The bodies are indented one step.
Note: When Layout/LineLength
's AllowHeredoc
is false (not default),
this cop does not add any offenses for long here documents to
avoid Layout/LineLength
's offenses.
Example:
# bad
<<-RUBY
something
RUBY
# good
<<~RUBY
something
RUBY
Use a guard clause (return if File.exist?(asked_to_join)
) instead of wrapping the code inside a conditional expression. Open
unless File.exist?(asked_to_join)
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
# bad
if something
foo || raise('exception')
else
ok
end
# good
foo || raise('exception') if something
ok
Incorrect indentation detected (column 7 instead of 4). Open
# 'Run SequenceServer doctor'
- Read upRead up
- Exclude checks
This cop checks the indentation of comments.
Example:
# bad
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
# good
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
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
Use $stdin
instead of STDIN
. Open
response = STDIN.gets.to_s.strip
- Read upRead up
- Exclude checks
This cop enforces the use of $stdout/$stderr/$stdin
instead of STDOUT/STDERR/STDIN
.
STDOUT/STDERR/STDIN
are constants, and while you can actually
reassign (possibly to redirect some stream) constants in Ruby, you'll get
an interpreter warning if you do so.
Safety:
Autocorrection is unsafe because STDOUT
and $stdout
may point to different
objects, for example.
Example:
# bad
STDOUT.puts('hello')
hash = { out: STDOUT, key: value }
def m(out = STDOUT)
out.puts('hello')
end
# good
$stdout.puts('hello')
hash = { out: $stdout, key: value }
def m(out = $stdout)
out.puts('hello')
end
Use $stdin
instead of STDIN
. Open
response = STDIN.gets.to_s.strip
- Read upRead up
- Exclude checks
This cop enforces the use of $stdout/$stderr/$stdin
instead of STDOUT/STDERR/STDIN
.
STDOUT/STDERR/STDIN
are constants, and while you can actually
reassign (possibly to redirect some stream) constants in Ruby, you'll get
an interpreter warning if you do so.
Safety:
Autocorrection is unsafe because STDOUT
and $stdout
may point to different
objects, for example.
Example:
# bad
STDOUT.puts('hello')
hash = { out: STDOUT, key: value }
def m(out = STDOUT)
out.puts('hello')
end
# good
$stdout.puts('hello')
hash = { out: $stdout, key: value }
def m(out = $stdout)
out.puts('hello')
end
Redundant single-element character class, [n]
can be replaced with n
. Open
unless response =~ /^[n]$/i
- Read upRead up
- Exclude checks
This cop checks for unnecessary single-element Regexp character classes.
Example:
# bad
r = /[x]/
# good
r = /x/
# bad
r = /[\s]/
# good
r = /\s/
# bad
r = %r{/[b]}
# good
r = %r{/b}
# good
r = /[ab]/
Align the elements of an array literal if they span more than one line. Open
SequenceServer::NUM_THREADS_INCORRECT => e
- Read upRead up
- Exclude checks
Here we check if the elements of a multi-line array literal are aligned.
Example: EnforcedStyle: withfirstelement (default)
# good
array = [1, 2, 3,
4, 5, 6]
array = ['run',
'forrest',
'run']
# bad
array = [1, 2, 3,
4, 5, 6]
array = ['run',
'forrest',
'run']
Example: EnforcedStyle: withfixedindentation
# good
array = [1, 2, 3,
4, 5, 6]
# bad
array = [1, 2, 3,
4, 5, 6]
Space inside { missing. Open
params = {:xml => xml_file_path}
- Read upRead up
- Exclude checks
Checks that braces used for hash literals have or don't have surrounding space depending on configuration.
Example: EnforcedStyle: space (default)
# The `space` style enforces that hash literals have
# surrounding space.
# bad
h = {a: 1, b: 2}
# good
h = { a: 1, b: 2 }
Example: EnforcedStyle: no_space
# The `no_space` style enforces that hash literals have
# no surrounding space.
# bad
h = { a: 1, b: 2 }
# good
h = {a: 1, b: 2}
Example: EnforcedStyle: compact
# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.
# bad
h = { a: { b: 2 } }
foo = { { a: 1 } => { b: { c: 2 } } }
# good
h = { a: { b: 2 }}
foo = {{ a: 1 } => { b: { c: 2 }}}
Example: EnforcedStyleForEmptyBraces: no_space (default)
# The `no_space` EnforcedStyleForEmptyBraces style enforces that
# empty hash braces do not contain spaces.
# bad
foo = { }
bar = { }
# good
foo = {}
bar = {}
Example: EnforcedStyleForEmptyBraces: space
# The `space` EnforcedStyleForEmptyBraces style enforces that
# empty hash braces contain space.
# bad
foo = {}
# good
foo = { }
foo = { }
foo = { }
Space inside } missing. Open
params = {:xml => xml_file_path}
- Read upRead up
- Exclude checks
Checks that braces used for hash literals have or don't have surrounding space depending on configuration.
Example: EnforcedStyle: space (default)
# The `space` style enforces that hash literals have
# surrounding space.
# bad
h = {a: 1, b: 2}
# good
h = { a: 1, b: 2 }
Example: EnforcedStyle: no_space
# The `no_space` style enforces that hash literals have
# no surrounding space.
# bad
h = { a: 1, b: 2 }
# good
h = {a: 1, b: 2}
Example: EnforcedStyle: compact
# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.
# bad
h = { a: { b: 2 } }
foo = { { a: 1 } => { b: { c: 2 } } }
# good
h = { a: { b: 2 }}
foo = {{ a: 1 } => { b: { c: 2 }}}
Example: EnforcedStyleForEmptyBraces: no_space (default)
# The `no_space` EnforcedStyleForEmptyBraces style enforces that
# empty hash braces do not contain spaces.
# bad
foo = { }
bar = { }
# good
foo = {}
bar = {}
Example: EnforcedStyleForEmptyBraces: space
# The `space` EnforcedStyleForEmptyBraces style enforces that
# empty hash braces contain space.
# bad
foo = {}
# good
foo = { }
foo = { }
foo = { }