Showing 1,586 of 1,600 total issues
Use snake_case for variable names. Open
@@PREPROCESSING_TASKS = %i[
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.
Example: EnforcedStyle: snake_case (default)
# bad
fooBar = 1
# good
foo_bar = 1
Example: EnforcedStyle: camelCase
# bad
foo_bar = 1
# good
fooBar = 1
Use snake_case for variable names. Open
@@_ONLY_NONMULTI_TASKS_H = Hash[@@ONLY_NONMULTI_TASKS.map { |i| [i, true] }]
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.
Example: EnforcedStyle: snake_case (default)
# bad
fooBar = 1
# good
foo_bar = 1
Example: EnforcedStyle: camelCase
# bad
foo_bar = 1
# good
fooBar = 1
Use snake_case for method names. Open
def INFO_FIELDS
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop makes sure that all methods use the configured style, snake_case or camelCase, for their names.
Example: EnforcedStyle: snake_case (default)
# bad
def fooBar; end
# good
def foo_bar; end
Example: EnforcedStyle: camelCase
# bad
def foo_bar; end
# good
def fooBar; end
Replace class var @@_EUTILS with a class instance var. Open
@@_EUTILS = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.
Use the new Ruby 1.9 hash syntax. Open
:'type-genomes' => { stage: :metadata, format: :json }
- Read upRead up
- Create a ticketCreate a ticket
- 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 snake_case for variable names. Open
@@_GTDB_API = 'https://gtdb-api.ecogenomic.org/'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.
Example: EnforcedStyle: snake_case (default)
# bad
fooBar = 1
# good
foo_bar = 1
Example: EnforcedStyle: camelCase
# bad
foo_bar = 1
# good
fooBar = 1
$/${} is unnecessary on arithmetic variables. Open
if [[ $C_LEN -gt $(($P_LEN * 11 / 10)) ]] ; then
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
$/${} is unnecessary on arithmetic variables.
Problematic code:
echo $(($n+1))
Correct code:
echo $((n+1))
Rationale:
The $
on regular variables in arithmetic contexts is unnecessary, and can even lead to subtle bugs. This is because the contents of $((..))
is first expanded into a string, and then evaluated as an expression:
$ a='1+1'
$ echo $(($a * 5)) # becomes 1+1*5
6
$ echo $((a * 5)) # evaluates as (1+1)*5
10
The $
is unavoidable for special variables like $1
vs 1
, $#
vs #
. It's also required when adding modifiers to parameters expansions, like ${#var}
or ${var%-}
. ShellCheck does not warn about these cases.
Notice
Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.
Use snake_case for variable names. Open
@@KNOWN_TYPES = {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.
Example: EnforcedStyle: snake_case (default)
# bad
fooBar = 1
# good
foo_bar = 1
Example: EnforcedStyle: camelCase
# bad
foo_bar = 1
# good
fooBar = 1
Missing top-level module documentation comment. Open
module MiGA::RemoteDataset::Download
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end
Replace class var @@_EUTILS_BUILD with a class instance var. Open
@@_EUTILS_BUILD = lambda { |service, q|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.
To read lines rather than words, pipe/redirect to a 'while read' loop. Open
for win in $(cat "$DATASET.wintax.regions") ; do
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
To read lines rather than words, pipe/redirect to a 'while read' loop.
Problematic code:
for line in $(cat file | grep -v '^ *#')
do
echo "Line: $line"
done
Correct code:
grep -v '^ *#' < file | while IFS= read -r line
do
echo "Line: $line"
done
or without a subshell (bash, zsh, ksh):
while IFS= read -r line
do
echo "Line: $line"
done < <(grep -v '^ *#' < file)
or without a subshell, with a pipe (more portable, but write a file on the filesystem):
mkfifo mypipe
grep -v '^ *#' < file > mypipe &
while IFS= read -r line
do
echo "Line: $line"
done < mypipe
rm mypipe
Rationale:
For loops by default (subject to $IFS
) read word by word. Additionally, glob expansion will occur.
Given this text file:
foo *
bar
The for loop will print:
Line: foo
Line: aardwark.jpg
Line: bullfrog.jpg
...
The while loop will print:
Line: foo *
Line: bar
Exceptions
If you want to read word by word, you should still use a while read loop (e.g. with read -a
to read words into an array).
Rare reasons for ignoring this message is if you don't care because your file only contains numbers and you're not interested in good practices, or if you've set $IFS
appropriately and also disabled globbing.
Notice
Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.
Replace class var @@PREPROCESSING_TASKS with a class instance var. Open
@@PREPROCESSING_TASKS = %i[
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.
Replace class var @@_EXCLUDE_NOREF_TASKS_H with a class instance var. Open
@@_EXCLUDE_NOREF_TASKS_H = Hash[@@EXCLUDE_NOREF_TASKS.map { |i| [i, true] }]
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.
Indent the first line of the right-hand-side of a multi-line assignment. Open
{
universe: universe, db: db, ids: ids.is_a?(Array) ? ids : [ids],
format: format, file: file, obj: obj,
extra: (database_hash[:extra] || {}).merge(extra),
_fun: :"#{getter}_#{action}"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks the indentation of the first line of the right-hand-side of a multi-line assignment.
Example:
# bad
value =
if foo
'bar'
end
# good
value =
if foo
'bar'
end
The indentation of the remaining lines can be corrected with
other cops such as IndentationConsistency
and EndAlignment
.
Avoid rescuing without specifying an error class. Open
rescue => e
- Read upRead up
- Create a ticketCreate a ticket
- 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
Align the parameters of a method call if they span more than one line. Open
db: opts[:db], id: opts[:ids], rettype: opts[:format], retmode: :text
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Use snake_case for variable names. Open
@@_NCBI_DATASETS = 'https://api.ncbi.nlm.nih.gov/datasets/v2alpha/'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.
Example: EnforcedStyle: snake_case (default)
# bad
fooBar = 1
# good
foo_bar = 1
Example: EnforcedStyle: camelCase
# bad
foo_bar = 1
# good
fooBar = 1
Do not use ::
for method calls. Open
URI::join(*safe)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
Example:
# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)
# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)
Replace class var @@_ONLY_NONMULTI_TASKS_H with a class instance var. Open
@@_ONLY_NONMULTI_TASKS_H = Hash[@@ONLY_NONMULTI_TASKS.map { |i| [i, true] }]
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.