Showing 93 of 93 total issues
Class has too many lines. [210/100] Open
class Zendesk < Handler
API_VERSION_URL_PATH = 'api/v2'
WEB_TICKETS_URL_PATH = 'tickets'
QUERY_TICKETS_ALL = 'type:ticket'
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Class Zendesk
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Zendesk < Handler
API_VERSION_URL_PATH = 'api/v2'
WEB_TICKETS_URL_PATH = 'tickets'
QUERY_TICKETS_ALL = 'type:ticket'
Assignment Branch Condition size for get_text_for_ticket_comments is too high. [21.63/15] Open
def get_text_for_ticket_comments(ticket)
Lita.logger.info "#{logger_prefix}Processing Zendesk ticket comments for [#{ticket.id}]"
unless ticket.is_a? ZendeskAPI::Ticket
raise 'ticket is not a ZendeskAPI::Ticket'
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for get_text_for_ticket is too high. [20.71/15] Open
def get_text_for_ticket(ticket, include_description = true)
Lita.logger.info "#{logger_prefix}Processing Zendesk ticket details for [#{ticket.id}]"
unless ticket.is_a? ZendeskAPI::Ticket
raise 'ticket is not a ZendeskAPI::Ticket'
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [15/10] Open
def get_text_for_ticket_comments(ticket)
Lita.logger.info "#{logger_prefix}Processing Zendesk ticket comments for [#{ticket.id}]"
unless ticket.is_a? ZendeskAPI::Ticket
raise 'ticket is not a ZendeskAPI::Ticket'
end
- 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.
Assignment Branch Condition size for user_display is too high. [18.55/15] Open
def user_display(user)
parts = []
if user.name.to_s.length > 0
parts.push user.name
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [12/10] Open
def get_text_for_ticket(ticket, include_description = true)
Lita.logger.info "#{logger_prefix}Processing Zendesk ticket details for [#{ticket.id}]"
unless ticket.is_a? ZendeskAPI::Ticket
raise 'ticket is not a ZendeskAPI::Ticket'
end
- 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.
Assignment Branch Condition size for ticket_details_with_comments is too high. [16.31/15] Open
def ticket_details_with_comments(response)
Lita.logger.info "#{logger_prefix}Processing Zendesk Ticket Details"
ticket_id = response.matches[0][0].to_i
begin
ticket = client.ticket.find!(id: ticket_id)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for client is too high. [15.94/15] Open
def client
return @_client if @_client
Lita.logger.info "#{logger_prefix}Connecting Zendesk Client to #{api_version_url}"
@_client = ZendeskAPI::Client.new do |client|
client.url = api_version_url.to_s
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
%q
-literals should be delimited by (
and )
. Open
spec.summary = %q{A Zendesk handler for the Lita chatbot.}
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Line is too long. [160/80] Open
route(/^(?:zd|zendesk)\s+connection\s*$/i, :zd_instance_info, command: true, help: { 'zd connection' => 'returns information on the Zendesk connection' })
- Exclude checks
Space between { and | missing. Open
if (comment = audit.events.detect {|e| e.type.downcase == 'comment'})
- Read upRead up
- Exclude checks
Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.
Example: EnforcedStyle: space (default)
# The `space` style enforces that block braces have
# surrounding space.
# bad
some_array.each {puts e}
# good
some_array.each { puts e }
Example: EnforcedStyle: no_space
# The `no_space` style enforces that block braces don't
# have surrounding space.
# bad
some_array.each { puts e }
# good
some_array.each {puts e}
Example: EnforcedStyleForEmptyBraces: no_space (default)
# The `no_space` EnforcedStyleForEmptyBraces style enforces that
# block braces don't have a space in between when empty.
# bad
some_array.each { }
some_array.each { }
some_array.each { }
# good
some_array.each {}
Example: EnforcedStyleForEmptyBraces: space
# The `space` EnforcedStyleForEmptyBraces style enforces that
# block braces have at least a spece in between when empty.
# bad
some_array.each {}
# good
some_array.each { }
some_array.each { }
some_array.each { }
Example: SpaceBeforeBlockParameters: true (default)
# The SpaceBeforeBlockParameters style set to `true` enforces that
# there is a space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.
# bad
[1, 2, 3].each {|n| n * 2 }
# good
[1, 2, 3].each { |n| n * 2 }
Example: SpaceBeforeBlockParameters: true
# The SpaceBeforeBlockParameters style set to `false` enforces that
# there is no space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.
# bad
[1, 2, 3].each { |n| n * 2 }
# good
[1, 2, 3].each {|n| n * 2 }
Missing top-level module documentation comment. Open
module Handlers
- Read upRead up
- 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
Unused block argument - i
. If it's necessary, use _
or _i
as an argument name to indicate that it won't be used. Open
ticket.audits.each_with_index do |audit,i|
- Read upRead up
- Exclude checks
This cop checks for unused block arguments.
Example:
# bad
do_something do |used, unused|
puts used
end
do_something do |bar|
puts :foo
end
define_method(:foo) do |bar|
puts :baz
end
Example:
#good
do_something do |used, _unused|
puts used
end
do_something do
puts :foo
end
define_method(:foo) do |_bar|
puts :baz
end
Space missing inside }. Open
if (comment = audit.events.detect {|e| e.type.downcase == 'comment'})
- Read upRead up
- Exclude checks
Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.
Example: EnforcedStyle: space (default)
# The `space` style enforces that block braces have
# surrounding space.
# bad
some_array.each {puts e}
# good
some_array.each { puts e }
Example: EnforcedStyle: no_space
# The `no_space` style enforces that block braces don't
# have surrounding space.
# bad
some_array.each { puts e }
# good
some_array.each {puts e}
Example: EnforcedStyleForEmptyBraces: no_space (default)
# The `no_space` EnforcedStyleForEmptyBraces style enforces that
# block braces don't have a space in between when empty.
# bad
some_array.each { }
some_array.each { }
some_array.each { }
# good
some_array.each {}
Example: EnforcedStyleForEmptyBraces: space
# The `space` EnforcedStyleForEmptyBraces style enforces that
# block braces have at least a spece in between when empty.
# bad
some_array.each {}
# good
some_array.each { }
some_array.each { }
some_array.each { }
Example: SpaceBeforeBlockParameters: true (default)
# The SpaceBeforeBlockParameters style set to `true` enforces that
# there is a space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.
# bad
[1, 2, 3].each {|n| n * 2 }
# good
[1, 2, 3].each { |n| n * 2 }
Example: SpaceBeforeBlockParameters: true
# The SpaceBeforeBlockParameters style set to `false` enforces that
# there is no space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.
# bad
[1, 2, 3].each { |n| n * 2 }
# good
[1, 2, 3].each {|n| n * 2 }
Line is too long. [175/80] Open
route(/^(?:zd|zendesk)\s+list(\s+unsolved)?\s+tickets?\s*$/i, :unsolved_tickets_list, command: true, help: { 'zd list tickets' => 'returns a list of unsolved tickets' })
- Exclude checks
Redundant return
detected. Open
return comments_text.reverse.join("\n")
- Read upRead up
- 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.
Line is too long. [96/80] Open
Lita.logger.info "#{logger_prefix}Processing Zendesk ticket comments for [#{ticket.id}]"
- Exclude checks
Final newline missing. Open
gemspec
- Exclude checks
Space missing after comma. Open
ticket.audits.each_with_index do |audit,i|
- Read upRead up
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }