Method has too many lines. [15/10] (https://github.com/voxable-labs/voxable-style-guide#short-methods) Open
def handle(request)
# Don't use the router if a route has already been specified.
unless route = request.route
begin
route = routes.fetch(request.action)
- Read upRead up
- Create a ticketCreate a ticket
- 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.
BUG found Open
# TODO: BUG Thread.current isn't going to work in case of multiple routers
- Create a ticketCreate a ticket
- Exclude checks
TODO found Open
# TODO: BUG Thread.current isn't going to work in case of multiple routers
- Create a ticketCreate a ticket
- Exclude checks
=
is not aligned with the preceding assignment. Open
request.route = route
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for extra/unnecessary whitespace.
Example:
# good if AllowForAlignment is true
name = "RuboCop"
# Some comment and an empty line
website += "/bbatsov/rubocop" unless cond
puts "rubocop" if debug
# bad for any configuration
set_app("RuboCop")
website = "https://github.com/bbatsov/rubocop"
Line is too long. [95/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# @param action_name [String, Symbol] The name of the action to be matched by the router.
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [81/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# @param handler_method_name [Symbol] The name of the handler method on the
- Create a ticketCreate a ticket
- Exclude checks
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 controller(controller_class, &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
Line is too long. [81/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# Note that it's probably a good idea to store your action names as constants.
- Create a ticketCreate a ticket
- Exclude checks
Freeze mutable objects assigned to constants. Open
INTERNAL_ROUTES = {
Hg::InternalActions::DISPLAY_CHUNK => {
controller: Hg::Controllers::ChunksController,
handler: :display_chunk
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Add a line break before the first argument of a multi-line method argument list. Open
action(action_name,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for a line break before the first argument in a multi-line method call.
Example:
# bad
method(foo, bar,
baz)
# good
method(
foo, bar,
baz)
# ignored
method foo, bar,
baz
Line is too long. [81/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# @param controller [Class] The class of the controller which contains this
- Create a ticketCreate a ticket
- Exclude checks
Missing method documentation comment. Open
def controller(controller_class, &block)
Thread.current[:current_controller] = controller_class
yield
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 initialize(action)
super("No route registered for action #{action}")
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
Line is too long. [84/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# should use the same set of action and parameter names, so that `request` objects
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [81/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# @param handler_method_name [Symbol] The name of the handler method on the
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [95/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# @param action_name [String, Symbol] The name of the action to be matched by the router.
- Create a ticketCreate a ticket
- Exclude checks
=
is not aligned with the following assignment. Open
route = routes.fetch(request.action)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for extra/unnecessary whitespace.
Example:
# good if AllowForAlignment is true
name = "RuboCop"
# Some comment and an empty line
website += "/bbatsov/rubocop" unless cond
puts "rubocop" if debug
# bad for any configuration
set_app("RuboCop")
website = "https://github.com/bbatsov/rubocop"
Line is too long. [82/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# TODO: BUG Thread.current isn't going to work in case of multiple routers
- Create a ticketCreate a ticket
- Exclude checks
Use ==
if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition. (https://github.com/voxable-labs/voxable-style-guide#safe-assignment-in-condition) Open
unless route = request.route
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for assignments in the conditions of if/while/until.
Example:
# bad
if some_var = true
do_something
end
Example:
# good
if some_var == true
do_something
end
Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens) Open
action Hg::InternalActions::DEFAULT,
controller: controller,
with: handler_method_name
- 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
Provide an exception class and message as arguments to raise
. (https://github.com/voxable-labs/voxable-style-guide#exception-class-messages) Open
raise ActionNotRegisteredError.new(request.action)
- 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"
Line is too long. [82/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# `action` and `parameters` keys. Postbacks and raw messages sent through an NLU
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [84/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits) Open
# Since the class itself is the router, make it immutable for thread-safety.
- Create a ticketCreate a ticket
- Exclude checks