18F/dolores-landingham-slack-bot

View on GitHub
app/services/message_sender.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    slack_user_id = EmployeeFinder.new(employee.slack_username).slack_user_id

    if employee.slack_user_id.nil? && slack_user_id.present?
      employee.slack_user_id = slack_user_id
Severity: Minor
Found in app/services/message_sender.rb - About 1 hr to fix

    Method run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        slack_user_id = EmployeeFinder.new(employee.slack_username).slack_user_id
    
        if employee.slack_user_id.nil? && slack_user_id.present?
          employee.slack_user_id = slack_user_id
    Severity: Minor
    Found in app/services/message_sender.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

    Line is too long. [161/80]
    Open

            error: StandardError.new("Was unable to find a slack channel for user with name #{employee.slack_username} and slack user id #{employee.slack_user_id}"),
    Severity: Minor
    Found in app/services/message_sender.rb by rubocop

    Extra empty line detected at method body end.
    Open

    
      end
    Severity: Minor
    Found in app/services/message_sender.rb by rubocop

    This cops checks if empty lines exist around the bodies of methods.

    Example:

    # good
    
    def foo
      # ...
    end
    
    # bad
    
    def bar
    
      # ...
    
    end

    There are no issues that match your filters.

    Category
    Status