Showing 714 of 714 total issues
Avoid using {...}
for multi-line blocks. Open
wsList.each_with_index {|_item, index|
- Read upRead up
- Exclude checks
Check for uses of braces or do/end around single line or multi-line blocks.
Example: EnforcedStyle: linecountbased (default)
# bad - single line block
items.each do |item| item / 5 end
# good - single line block
items.each { |item| item / 5 }
# bad - multi-line block
things.map { |thing|
something = thing.some_method
process(something)
}
# good - multi-line block
things.map do |thing|
something = thing.some_method
process(something)
end
Example: EnforcedStyle: semantic
# Prefer `do...end` over `{...}` for procedural blocks.
# return value is used/assigned
# bad
foo = map do |x|
x
end
puts (map do |x|
x
end)
# return value is not used out of scope
# good
map do |x|
x
end
# Prefer `{...}` over `do...end` for functional blocks.
# return value is not used out of scope
# bad
each { |x|
x
}
# return value is used/assigned
# good
foo = map { |x|
x
}
map { |x|
x
}.inspect
Example: EnforcedStyle: bracesforchaining
# bad
words.each do |word|
word.flip.flop
end.join("-")
# good
words.each { |word|
word.flip.flop
}.join("-")
Avoid using {...}
for multi-line blocks. Open
wsList.each_with_index {|val, index|
- Read upRead up
- Exclude checks
Check for uses of braces or do/end around single line or multi-line blocks.
Example: EnforcedStyle: linecountbased (default)
# bad - single line block
items.each do |item| item / 5 end
# good - single line block
items.each { |item| item / 5 }
# bad - multi-line block
things.map { |thing|
something = thing.some_method
process(something)
}
# good - multi-line block
things.map do |thing|
something = thing.some_method
process(something)
end
Example: EnforcedStyle: semantic
# Prefer `do...end` over `{...}` for procedural blocks.
# return value is used/assigned
# bad
foo = map do |x|
x
end
puts (map do |x|
x
end)
# return value is not used out of scope
# good
map do |x|
x
end
# Prefer `{...}` over `do...end` for functional blocks.
# return value is not used out of scope
# bad
each { |x|
x
}
# return value is used/assigned
# good
foo = map { |x|
x
}
map { |x|
x
}.inspect
Example: EnforcedStyle: bracesforchaining
# bad
words.each do |word|
word.flip.flop
end.join("-")
# good
words.each { |word|
word.flip.flop
}.join("-")
Omit the parentheses in defs when the method doesn't accept any arguments. Open
def Command.modulesCommand()
- Read upRead up
- Exclude checks
This cop checks for parentheses in the definition of a method, that does not take any arguments. Both instance and class/singleton methods are checked.
Example:
# bad
def foo()
# does a thing
end
# good
def foo
# does a thing
end
# also good
def foo() does_a_thing end
Example:
# bad
def Baz.foo()
# does a thing
end
# good
def Baz.foo
# does a thing
end
Do not use parentheses for method calls with no arguments. Open
while cmdSend = Readline::readline("\ncmd ##{wss.getSelected()} > ".colorize(:magenta))
- Read upRead up
- Exclude checks
This cop checks for unwanted parentheses in parameterless method calls.
Example:
# bad
object.some_method()
# good
object.some_method
Do not use parentheses for method calls with no arguments. Open
if !Bbs::WebSocket.validSession?(wss.getSelected(), wss.getWsList())
- Read upRead up
- Exclude checks
This cop checks for unwanted parentheses in parameterless method calls.
Example:
# bad
object.some_method()
# good
object.some_method
Do not use parentheses for method calls with no arguments. Open
if !Bbs::WebSocket.validSession?(wss.getSelected(), wss.getWsList())
- Read upRead up
- Exclude checks
This cop checks for unwanted parentheses in parameterless method calls.
Example:
# bad
object.some_method()
# good
object.some_method
Favor unless
over if
for negative conditions. Open
if !Bbs::WebSocket.validSession?(wss.getSelected(), wss.getWsList())
break
end
- Read upRead up
- Exclude checks
Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:
- both
- prefix
- postfix
Example: EnforcedStyle: both (default)
# enforces `unless` for `prefix` and `postfix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# bad
bar if !foo
# good
bar unless foo
Example: EnforcedStyle: prefix
# enforces `unless` for just `prefix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# good
bar if !foo
Example: EnforcedStyle: postfix
# enforces `unless` for just `postfix` conditionals
# bad
bar if !foo
# good
bar unless foo
# good
if !foo
bar
end
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
Use self.sessionsCommand
instead of Command.sessionsCommand
. Open
def Command.sessionsCommand(selected, wsList)
- Read upRead up
- Exclude checks
This cop checks for uses of the class/module name instead of self, when defining class/module methods.
Example:
# bad
class SomeClass
def SomeClass.class_method
# ...
end
end
# good
class SomeClass
def self.class_method
# ...
end
end
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
if fileContent.lines.first.chomp == "// INTERACTIVE"
- 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 self.targetCommand
instead of Command.targetCommand
. Open
def Command.targetCommand(wss, cmdIn)
- Read upRead up
- Exclude checks
This cop checks for uses of the class/module name instead of self, when defining class/module methods.
Example:
# bad
class SomeClass
def SomeClass.class_method
# ...
end
end
# good
class SomeClass
def self.class_method
# ...
end
end
Use self.lsCommand
instead of Command.lsCommand
. Open
def Command.lsCommand(cmdIn)
- Read upRead up
- Exclude checks
This cop checks for uses of the class/module name instead of self, when defining class/module methods.
Example:
# bad
class SomeClass
def SomeClass.class_method
# ...
end
end
# good
class SomeClass
def self.class_method
# ...
end
end
Do not use parentheses for method calls with no arguments. Open
if Bbs::WebSocket.validSession?(selectIn, wss.getWsList())
- Read upRead up
- Exclude checks
This cop checks for unwanted parentheses in parameterless method calls.
Example:
# bad
object.some_method()
# good
object.some_method
Redundant begin
block detected. Open
begin
- Read upRead up
- Exclude checks
This cop checks for redundant begin
blocks.
Currently it checks for code like this:
Example:
def redundant
begin
ala
bala
rescue StandardError => e
something
end
end
def preferred
ala
bala
rescue StandardError => e
something
end
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
print " --> "
- 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"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
modules = Dir.glob("modules/*.js").select{ |e| File.file? 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"
Use snake_case for variable names. Open
fileContent = file.read
- Read upRead up
- 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 2 (not 4) spaces for indentation. Open
def PrintColor.print_error(message)
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Use self.catCommand
instead of Command.catCommand
. Open
def Command.catCommand(log, cmdIn)
- Read upRead up
- Exclude checks
This cop checks for uses of the class/module name instead of self, when defining class/module methods.
Example:
# bad
class SomeClass
def SomeClass.class_method
# ...
end
end
# good
class SomeClass
def self.class_method
# ...
end
end