Showing 436 of 436 total issues
Redundant return
detected. (https://github.com/voxable-labs/voxable-style-guide#no-explicit-return) Open
return message
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Missing method documentation comment. Open
def initialize(user_id: nil, namespace: nil)
key = message_key(
user_id: user_id,
namespace: namespace,
key_portion: MESSAGES_QUEUE_KEY_PORTION
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for missing documentation comment for public methods. It can optionally be configured to also require documentation for non-public methods.
Example:
# bad
class Foo
def bar
puts baz
end
end
module Foo
def bar
puts baz
end
end
def foo.bar
puts baz
end
# good
class Foo
# Documentation
def bar
puts baz
end
end
module Foo
# Documentation
def bar
puts baz
end
end
# Documentation
def foo.bar
puts baz
end
Missing method documentation comment. Open
def initialize
super('There was a problem with the API.ai query.')
end
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for missing documentation comment for public methods. It can optionally be configured to also require documentation for non-public methods.
Example:
# bad
class Foo
def bar
puts baz
end
end
module Foo
def bar
puts baz
end
end
def foo.bar
puts baz
end
# good
class Foo
# Documentation
def bar
puts baz
end
end
module Foo
# Documentation
def bar
puts baz
end
end
# Documentation
def foo.bar
puts baz
end
Missing method documentation comment. Open
def display_chunk
# TODO: Shouldn't be constantizing user input. Need a way to sanitize this.
# Although - payloads shouldn't be something the client is allowed to set, in Messenger.
chunk_class = Kernel.const_get(params[:chunk])
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for missing documentation comment for public methods. It can optionally be configured to also require documentation for non-public methods.
Example:
# bad
class Foo
def bar
puts baz
end
end
module Foo
def bar
puts baz
end
end
def foo.bar
puts baz
end
# good
class Foo
# Documentation
def bar
puts baz
end
end
module Foo
# Documentation
def bar
puts baz
end
end
# Documentation
def foo.bar
puts baz
end
Line is too long. [85/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
payload['payload']['params'][Hg::Messenger::Bot::ONBOARDING_PARAM] = true
- Create a ticketCreate a ticket
- Exclude checks
Missing top-level module documentation comment. Open
module Bot
- 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
Provide an exception class and message as arguments to raise
. (https://github.com/voxable-labs/voxable-style-guide#exception-class-messages) Open
raise NoUserClassExistsError.new
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks the args passed to fail
and raise
. For exploded
style (default), it recommends passing the exception class and message
to raise
, rather than construct an instance of the error. It will
still allow passing just a message, or the construction of an error
with more than one argument.
The exploded style works identically, but with the addition that it will also suggest constructing error objects when the exception is passed multiple arguments.
Example: EnforcedStyle: exploded (default)
# bad
raise StandardError.new("message")
# good
raise StandardError, "message"
fail "message"
raise MyCustomError.new(arg1, arg2, arg3)
raise MyKwArgError.new(key1: val1, key2: val2)
Example: EnforcedStyle: compact
# bad
raise StandardError, "message"
raise RuntimeError, arg1, arg2, arg3
# good
raise StandardError.new("message")
raise MyCustomError.new(arg1, arg2, arg3)
fail "message"
Indent the right brace the same as the first position after the preceding left parenthesis. Open
}, access_token: ENV['FB_ACCESS_TOKEN'])
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cops checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the AlignHash cop.
By default, Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.
Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.
This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_braces'. Here are examples:
Example: EnforcedStyle: specialinsideparentheses (default)
# The `special_inside_parentheses` style enforces that the first key
# in a hash literal where the opening brace and the first key are on
# separate lines is indented one step (two spaces) more than the
# position inside the opening parentheses.
# bad
hash = {
key: :value
}
and_in_a_method_call({
no: :difference
})
# good
special_inside_parentheses
hash = {
key: :value
}
but_in_a_method_call({
its_like: :this
})
Example: EnforcedStyle: consistent
# The `consistent` style enforces that the first key in a hash
# literal where the opening brace and the first key are on
# seprate lines is indented the same as a hash literal which is not
# defined inside a method call.
# bad
hash = {
key: :value
}
but_in_a_method_call({
its_like: :this
})
# good
hash = {
key: :value
}
and_in_a_method_call({
no: :difference
})
Example: EnforcedStyle: align_braces
# The `align_brackets` style enforces that the opening and closing
# braces are indented to the same position.
# bad
and_now_for_something = {
completely: :different
}
# good
and_now_for_something = {
completely: :different
}
Use alias
instead of alias_method
in a class body. (https://github.com/voxable-labs/voxable-style-guide#alias-method) Open
alias_method :parameters, :params
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop enforces the use of either #alias
or #alias_method
depending on configuration.
It also flags uses of alias :symbol
rather than alias bareword
.
Example: EnforcedStyle: prefer_alias (default)
# bad
alias_method :bar, :foo
alias :bar :foo
# good
alias bar foo
Example: EnforcedStyle: preferaliasmethod
# bad
alias :bar :foo
alias bar foo
# good
alias_method :bar, :foo
Trailing whitespace detected. (https://github.com/voxable-labs/voxable-style-guide#no-trailing-whitespace) Open
- Create a ticketCreate a ticket
- Exclude checks
Useless assignment to variable - message_received
. (https://github.com/voxable-labs/voxable-style-guide#underscore-unused-vars) Open
message_received = {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
Missing top-level class documentation comment. Open
class MessageQueue < Hg::Queues::Queue
- 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
Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens) Open
Sidekiq::Logging.logger.error e
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks presence of parentheses in method calls containing
parameters. By default, macro methods are ignored. Additional methods
can be added to the IgnoredMethods
list.
Example:
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `IgnoredMethods`
puts 'test'
# IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
# IgnoreMacros: false
# bad
class Foo
bar :baz
end
Unused method argument - block
. If it's necessary, use _
or _block
as an argument name to indicate that it won't be used. (https://github.com/voxable-labs/voxable-style-guide#underscore-unused-vars) Open
def nested_menu(title, &block)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for unused method arguments.
Example:
# bad
def some_method(used, unused, _unused_but_allowed)
puts used
end
Example:
# good
def some_method(used, _unused, _unused_but_allowed)
puts used
end
Missing method documentation comment. Open
def initialize
super('No User class exists for this bot. Define a global class User, or set with user_class=')
end
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for missing documentation comment for public methods. It can optionally be configured to also require documentation for non-public methods.
Example:
# bad
class Foo
def bar
puts baz
end
end
module Foo
def bar
puts baz
end
end
def foo.bar
puts baz
end
# good
class Foo
# Documentation
def bar
puts baz
end
end
module Foo
# Documentation
def bar
puts baz
end
end
# Documentation
def foo.bar
puts baz
end
Missing method documentation comment. Open
def greeting_text(text)
@greeting_text = text
end
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for missing documentation comment for public methods. It can optionally be configured to also require documentation for non-public methods.
Example:
# bad
class Foo
def bar
puts baz
end
end
module Foo
def bar
puts baz
end
end
def foo.bar
puts baz
end
# good
class Foo
# Documentation
def bar
puts baz
end
end
module Foo
# Documentation
def bar
puts baz
end
end
# Documentation
def foo.bar
puts baz
end
Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens) Open
::Facebook::Messenger::Bot.on :postback do |postback|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks presence of parentheses in method calls containing
parameters. By default, macro methods are ignored. Additional methods
can be added to the IgnoredMethods
list.
Example:
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `IgnoredMethods`
puts 'test'
# IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
# IgnoreMacros: false
# bad
class Foo
bar :baz
end
Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens) Open
Rails.logger.error e.backtrace
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks presence of parentheses in method calls containing
parameters. By default, macro methods are ignored. Additional methods
can be added to the IgnoredMethods
list.
Example:
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `IgnoredMethods`
puts 'test'
# IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
# IgnoreMacros: false
# bad
class Foo
bar :baz
end
Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens) Open
::Facebook::Messenger::Bot.on :message do |message|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks presence of parentheses in method calls containing
parameters. By default, macro methods are ignored. Additional methods
can be added to the IgnoredMethods
list.
Example:
# bad
array.delete e
# good
array.delete(e)
# good
# Operators don't need parens
foo == bar
# good
# Setter methods don't need parens
foo.bar = baz
# okay with `puts` listed in `IgnoredMethods`
puts 'test'
# IgnoreMacros: true (default)
# good
class Foo
bar :baz
end
# IgnoreMacros: false
# bad
class Foo
bar :baz
end
Avoid trailing inline comments. Open
spec.add_runtime_dependency 'api-ai-ruby'#, '~> 1.2.3'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for trailing inline comments.
Example:
# good
foo.each do |f|
# Standalone comment
f.bar
end
# bad
foo.each do |f|
f.bar # Trailing inline comment
end