voxable-labs/hg

View on GitHub
app/workers/hg/postback_worker.rb

Summary

Maintainability
A
35 mins
Test Coverage

Method has too many lines. [21/10] (https://github.com/voxable-labs/voxable-style-guide#short-methods)
Open

    def perform(user_id, redis_namespace, bot_class_name)
      # Retrieve the latest postback for this user
      raw_postback = pop_raw_postback(user_id, redis_namespace)

      # Do nothing if no postback available. This could be due to multiple
Severity: Minor
Found in app/workers/hg/postback_worker.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 perform is too high. [18.81/15] (http://c2.com/cgi/wiki?AbcMetric)
Open

    def perform(user_id, redis_namespace, bot_class_name)
      # Retrieve the latest postback for this user
      raw_postback = pop_raw_postback(user_id, redis_namespace)

      # Do nothing if no postback available. This could be due to multiple
Severity: Minor
Found in app/workers/hg/postback_worker.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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def perform(user_id, redis_namespace, bot_class_name)
      # Retrieve the latest postback for this user
      raw_postback = pop_raw_postback(user_id, redis_namespace)

      # Do nothing if no postback available. This could be due to multiple
Severity: Minor
Found in app/workers/hg/postback_worker.rb - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

TODO found
Open

    # TODO: Make number of retries configurable.
Severity: Minor
Found in app/workers/hg/postback_worker.rb by fixme

TODO found
Open

        # TODO: pass in a `user_id_field` to indicate how to find user in order to
Severity: Minor
Found in app/workers/hg/postback_worker.rb by fixme

Line is too long. [81/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits)
Open

            @postback = Facebook::Messenger::Incoming::Postback.new(raw_postback)
Severity: Minor
Found in app/workers/hg/postback_worker.rb by rubocop

Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens)
Open

            build_referral_request @referral, user
Severity: Minor
Found in app/workers/hg/postback_worker.rb by rubocop

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

Line is too long. [82/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits)
Open

        # TODO: pass in a `user_id_field` to indicate how to find user in order to
Severity: Minor
Found in app/workers/hg/postback_worker.rb by rubocop

Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens)
Open

            build_payload_request @postback.payload, user
Severity: Minor
Found in app/workers/hg/postback_worker.rb by rubocop

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

Line is too long. [84/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits)
Open

    # @param user_id [String, Integer] The ID representing the user on this platform
Severity: Minor
Found in app/workers/hg/postback_worker.rb by rubocop

Line is too long. [81/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits)
Open

            @referral = Facebook::Messenger::Incoming::Referral.new(raw_postback)
Severity: Minor
Found in app/workers/hg/postback_worker.rb by rubocop

Line is too long. [82/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits)
Open

    # @param redis_namespace [String] The redis namespace under which the postback
Severity: Minor
Found in app/workers/hg/postback_worker.rb by rubocop

Favor a normal if-statement over a modifier clause in a multiline statement. (https://github.com/voxable-labs/voxable-style-guide#no-multiline-if-modifiers)
Open

        send_user_message(
          intent: request.action,
          text: request.action,
          not_handled: false,
          message: @postback || @referral
Severity: Minor
Found in app/workers/hg/postback_worker.rb by rubocop

Checks for uses of if/unless modifiers with multiple-lines bodies.

Example:

# bad
{
  result: 'this should not happen'
} unless cond

# good
{ result: 'ok' } if cond

There are no issues that match your filters.

Category
Status