grokify/lita-zendesk

View on GitHub
lib/lita/handlers/zendesk.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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'
Severity: Minor
Found in lib/lita/handlers/zendesk.rb by rubocop

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'
Severity: Minor
Found in lib/lita/handlers/zendesk.rb - About 4 hrs to fix

    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
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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)
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Use casecmp instead of downcase ==.
    Open

              if (comment = audit.events.detect {|e| e.type.downcase == 'comment'})
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    This cop identifies places where a case-insensitive string comparison can better be implemented using casecmp.

    Example:

    # bad
    str.downcase == 'abc'
    str.upcase.eql? 'ABC'
    'abc' == str.downcase
    'ABC'.eql? str.upcase
    str.downcase == str.downcase
    
    # good
    str.casecmp('ABC').zero?
    'abc'.casecmp(str).zero?

    Trailing whitespace detected.
    Open

            message += "\n- Requester: #{user_display(ticket.requester)}"  
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [157/80]
    Open

          route(/^(?:zd|zendesk)\s+(all|total)\s+tickets?\s*$/i, :total_tickets, command: true, help: { 'zd all tickets' => 'returns the count of all tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [96/80]
    Open

            Lita.logger.info "#{logger_prefix}Processing Zendesk ticket comments for [#{ticket.id}]"
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

            if !comments.nil? && comments.length>0
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

            if user.name.to_s.length > 0
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

    Freeze mutable objects assigned to constants.
    Open

          API_VERSION_URL_PATH = 'api/v2'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Freeze mutable objects assigned to constants.
    Open

          QUERY_TICKETS_ALL = 'type:ticket'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Extra empty line detected at class body beginning.
    Open

    
          API_VERSION_URL_PATH = 'api/v2'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    This cops checks if empty lines around the bodies of classes match the configuration.

    Example: EnforcedStyle: empty_lines

    # good
    
    class Foo
    
      def bar
        # ...
      end
    
    end

    Example: EnforcedStyle: emptylinesexcept_namespace

    # good
    
    class Foo
      class Bar
    
        # ...
    
      end
    end

    Example: EnforcedStyle: emptylinesspecial

    # good
    class Foo
    
      def bar; end
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    class Foo
      def bar
        # ...
      end
    end

    Final newline missing.
    Open

    end
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [171/80]
    Open

          route(/^(?:zd|zendesk)\s+list\s+(all|total)\s+tickets?\s*$/i, :total_tickets_list, command: true, help: { 'zd list all tickets' => 'returns a list of all tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Freeze mutable objects assigned to constants.
    Open

          WEB_TICKETS_URL_PATH = 'tickets'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Use empty? instead of length < 1.
    Open

              if parts.length < 1 || user.email != user.name
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

    Example:

    # bad
    [1, 2, 3].length == 0
    0 == "foobar".length
    array.length < 1
    {a: 1, b: 2}.length != 0
    string.length > 0
    hash.size > 0
    
    # good
    [1, 2, 3].empty?
    "foobar".empty?
    array.empty?
    !{a: 1, b: 2}.empty?
    !string.empty?
    !hash.empty?

    Line is too long. [164/80]
    Open

          route(/^(?:zd|zendesk)\s+search\s+tickets?\s+(\S.*?)\s*$/i, :search_tickets, command: true, help: { 'zd search tickets <QUERY>' => 'returns search results' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [164/80]
    Open

          route(/^(?:zd|zendesk)\s+new\s+tickets?\s*$/i, :new_tickets, command: true, help: { 'zd new tickets' => 'returns the count of all new (unassigned) tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Use next to skip iteration.
    Open

              if (comment = audit.events.detect {|e| e.type.downcase == 'comment'})
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Use next to skip iteration instead of a condition at the end.

    Example: EnforcedStyle: skipmodifierifs (default)

    # bad
    [1, 2].each do |a|
      if a == 1
        puts a
      end
    end
    
    # good
    [1, 2].each do |a|
      next unless a == 1
      puts a
    end
    
    # good
    [1, 2].each do |o|
      puts o unless o == 1
    end

    Example: EnforcedStyle: always

    # With `always` all conditions at the end of an iteration needs to be
    # replaced by next - with `skip_modifier_ifs` the modifier if like
    # this one are ignored: `[1, 2].each { |a| return 'yes' if a == 1 }`
    
    # bad
    [1, 2].each do |o|
      puts o unless o == 1
    end
    
    # bad
    [1, 2].each do |a|
      if a == 1
        puts a
      end
    end
    
    # good
    [1, 2].each do |a|
      next unless a == 1
      puts a
    end

    Use !empty? instead of length > 0.
    Open

            if user.email.to_s.length > 0
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

    Example:

    # bad
    [1, 2, 3].length == 0
    0 == "foobar".length
    array.length < 1
    {a: 1, b: 2}.length != 0
    string.length > 0
    hash.size > 0
    
    # good
    [1, 2, 3].empty?
    "foobar".empty?
    array.empty?
    !{a: 1, b: 2}.empty?
    !string.empty?
    !hash.empty?

    Line is too long. [155/80]
    Open

          route(/^(?:zd|zendesk)\s+open\s+tickets?\s*$/i, :open_tickets, command: true, help: { 'zd open tickets' => 'returns the count of all open tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [111/80]
    Open

            response.reply "Listing #{serp_count} of #{tickets.count} #{ticket_desc}#{ticket_word(tickets.count)}."
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [168/80]
    Open

          route(/^(?:zd|zendesk)\s+on\s*hold\s+tickets?\s*$/i, :onhold_tickets, command: true, help: { 'zd on hold tickets' => 'returns the count of all on hold tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Freeze mutable objects assigned to constants.
    Open

          QUERY_TICKETS_UNSOLVED = 'type:ticket status<solved'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Redundant return detected.
    Open

            return comments_text.reverse.join("\n")
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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. [90/80]
    Open

            Lita.logger.info "#{logger_prefix}Connecting Zendesk Client to #{api_version_url}"
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [178/80]
    Open

          route(/^(?:zd|zendesk)\s+ticket\s+(\d+)\s*$/i, :ticket_details_with_comments, command: true, help: { 'zd ticket <ID>' => 'returns information about the specified ticket' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [95/80]
    Open

            Lita.logger.info "#{logger_prefix}Processing Zendesk ticket details for [#{ticket.id}]"
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Redundant return detected.
    Open

            return message
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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.

    Use %r around regular expression.
    Open

            args.join('/').gsub(/\/\s*\//, '/').gsub(/\/+/, '/').gsub(/^(https?:\/)/i, '\1/')
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    This cop enforces using // or %r around regular expressions.

    Example: EnforcedStyle: slashes (default)

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = %r{
      foo
      (bar)
      (baz)
    }x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = /
      foo
      (bar)
      (baz)
    /x

    Example: EnforcedStyle: percent_r

    # bad
    snake_case = /^[\dA-Z_]+$/
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = %r{^[\dA-Z_]+$}
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: EnforcedStyle: mixed

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: AllowInnerSlashes: false (default)

    # If `false`, the cop will always recommend using `%r` if one or more
    # slashes are found in the regexp string.
    
    # bad
    x =~ /home\//
    
    # good
    x =~ %r{home/}

    Example: AllowInnerSlashes: true

    # good
    x =~ /home\//

    Redundant return detected.
    Open

            return serp_count
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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.

    Use %r around regular expression.
    Open

            args.join('/').gsub(/\/\s*\//, '/').gsub(/\/+/, '/').gsub(/^(https?:\/)/i, '\1/')
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    This cop enforces using // or %r around regular expressions.

    Example: EnforcedStyle: slashes (default)

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = %r{
      foo
      (bar)
      (baz)
    }x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = /
      foo
      (bar)
      (baz)
    /x

    Example: EnforcedStyle: percent_r

    # bad
    snake_case = /^[\dA-Z_]+$/
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = %r{^[\dA-Z_]+$}
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: EnforcedStyle: mixed

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: AllowInnerSlashes: false (default)

    # If `false`, the cop will always recommend using `%r` if one or more
    # slashes are found in the regexp string.
    
    # bad
    x =~ /home\//
    
    # good
    x =~ %r{home/}

    Example: AllowInnerSlashes: true

    # good
    x =~ /home\//

    Avoid rescuing without specifying an error class.
    Open

            rescue => e
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Avoid rescuing without specifying an error class.
    Open

            rescue
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Surrounding space missing for operator >.
    Open

            if !comments.nil? && comments.length>0
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Checks that operators have space around them, except for ** which should not have surrounding space.

    Example:

    # bad
    total = 3*4
    "apple"+"juice"
    my_number = 38/4
    a ** b
    
    # good
    total = 3 * 4
    "apple" + "juice"
    my_number = 38 / 4
    a**b

    Missing top-level class documentation comment.
    Open

        class Zendesk < Handler
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Freeze mutable objects assigned to constants.
    Open

          QUERY_TICKETS_HOLD = 'type:ticket status:hold'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Freeze mutable objects assigned to constants.
    Open

          QUERY_TICKETS_PENDING = 'type:ticket status:pending'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Line is too long. [184/80]
    Open

          route(/^(?:zd|zendesk)\s+list\s+escalated\s+tickets?\s*$/i, :escalated_tickets_list, command: true, help: { 'zd list esclated tickets' => 'returns a list of escalated tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Use !empty? instead of length > 0.
    Open

            if !comments.nil? && comments.length>0
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

    Example:

    # bad
    [1, 2, 3].length == 0
    0 == "foobar".length
    array.length < 1
    {a: 1, b: 2}.length != 0
    string.length > 0
    hash.size > 0
    
    # good
    [1, 2, 3].empty?
    "foobar".empty?
    array.empty?
    !{a: 1, b: 2}.empty?
    !string.empty?
    !hash.empty?

    Space missing inside }.
    Open

              if (comment = audit.events.detect {|e| e.type.downcase == 'comment'})
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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. [87/80]
    Open

          QUERY_TICKETS_ESCALATED = 'type:ticket tags:escalated status:open status:pending'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [177/80]
    Open

          route(/^(?:zd|zendesk)\s+list\s+pending\s+tickets?\s*$/i, :pending_tickets_list, command: true, help: { 'zd list pending tickets' => 'returns a list of pending tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Freeze mutable objects assigned to constants.
    Open

          QUERY_TICKETS_OPEN = 'type:ticket status:open'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Use %r around regular expression.
    Open

            args.join('/').gsub(/\/\s*\//, '/').gsub(/\/+/, '/').gsub(/^(https?:\/)/i, '\1/')
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    This cop enforces using // or %r around regular expressions.

    Example: EnforcedStyle: slashes (default)

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = %r{
      foo
      (bar)
      (baz)
    }x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = /
      foo
      (bar)
      (baz)
    /x

    Example: EnforcedStyle: percent_r

    # bad
    snake_case = /^[\dA-Z_]+$/
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = %r{^[\dA-Z_]+$}
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: EnforcedStyle: mixed

    # bad
    snake_case = %r{^[\dA-Z_]+$}
    
    # bad
    regex = /
      foo
      (bar)
      (baz)
    /x
    
    # good
    snake_case = /^[\dA-Z_]+$/
    
    # good
    regex = %r{
      foo
      (bar)
      (baz)
    }x

    Example: AllowInnerSlashes: false (default)

    # If `false`, the cop will always recommend using `%r` if one or more
    # slashes are found in the regexp string.
    
    # bad
    x =~ /home\//
    
    # good
    x =~ %r{home/}

    Example: AllowInnerSlashes: true

    # good
    x =~ /home\//

    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' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [82/80]
    Open

            message += "\n- Description: #{ticket.description}" if include_description
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [89/80]
    Open

            args.join('/').gsub(/\/\s*\//, '/').gsub(/\/+/, '/').gsub(/^(https?:\/)/i, '\1/')
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Freeze mutable objects assigned to constants.
    Open

          QUERY_TICKETS_NEW = 'type:ticket status:new'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

              response.reply "A Zendesk error has been encountered."
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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"

    Useless assignment to variable - user_text.
    Open

            user_text = parts.join(' ')
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Line is too long. [161/80]
    Open

          route(/^(?:zd|zendesk)\s+list\s+new\s+tickets?\s*$/i, :new_tickets_list, command: true, help: { 'zd list new tickets' => 'returns a list of new tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Redundant return detected.
    Open

            return message
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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. [171/80]
    Open

          route(/^(?:zd|zendesk)(\s+unsolved)?\s+tickets?\s*$/i, :unsolved_tickets, command: true, help: { 'zd tickets' => 'returns the total count of all unsolved tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [170/80]
    Open

          route(/^(?:zd|zendesk)\s+pending\s+tickets?\s*$/i, :pending_tickets, command: true, help: { 'zd pending tickets' => 'returns a count of tickets that are pending' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [91/80]
    Open

            Lita.logger.info "#{logger_prefix}Processing Zendesk Ticket Count Query [#{query}]"
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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|
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Line is too long. [203/80]
    Open

          route(/^(?:zd|zendesk)\s+escalated\s+tickets?\s*$/i, :escalated_tickets, command: true, help: { 'zd escalated tickets' => 'returns a count of tickets with escalated tag that are open or pending' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [165/80]
    Open

          route(/^(?:zd|zendesk)\s+list\s+open\s+tickets?\s*$/i, :open_tickets_list, command: true, help: { 'zd list open tickets' => 'returns a list of open tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [119/80]
    Open

            response.reply "Listing #{serp_count} of #{tickets.count} #{ticket_word(tickets.count)} matching #{raw_query}."
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Freeze mutable objects assigned to constants.
    Open

          QUERY_TICKETS_ESCALATED = 'type:ticket tags:escalated status:open status:pending'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Freeze mutable objects assigned to constants.
    Open

          QUERY_USERS = 'users'
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    Space missing after comma.
    Open

            ticket.audits.each_with_index do |audit,i|
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Checks for comma (,) not followed by some kind of space.

    Example:

    # bad
    [1,2]
    { foo:bar,}
    
    # good
    [1, 2]
    { foo:bar, }

    Line is too long. [178/80]
    Open

          route(/^(?:zd|zendesk)\s+list\s+on\s*hold\s+tickets?\s*$/i, :onhold_tickets_list, command: true, help: { 'zd list on hold tickets' => 'returns a list of on hold tickets' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [109/80]
    Open

            Lita.logger.info "#{logger_prefix}Processing Zendesk ticket details for [#{ticket.id}] with comments"
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Line is too long. [116/80]
    Open

              response.reply "Ticket #{ticket.id} is #{ticket.status}: #{ticket_url_web(ticket.id)} - #{ticket.subject}"
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Use !empty? instead of length > 0.
    Open

            if user.name.to_s.length > 0
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

    Example:

    # bad
    [1, 2, 3].length == 0
    0 == "foobar".length
    array.length < 1
    {a: 1, b: 2}.length != 0
    string.length > 0
    hash.size > 0
    
    # good
    [1, 2, 3].empty?
    "foobar".empty?
    array.empty?
    !{a: 1, b: 2}.empty?
    !string.empty?
    !hash.empty?

    Space between { and | missing.
    Open

              if (comment = audit.events.detect {|e| e.type.downcase == 'comment'})
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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' })
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    Missing top-level module documentation comment.
    Open

      module Handlers
    Severity: Minor
    Found in lib/lita/handlers/zendesk.rb by rubocop

    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

    There are no issues that match your filters.

    Category
    Status