houston/houston-core

View on GitHub
app/models/action.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method has too many lines. [28/10]
Open

  def run!
    exception = nil

    Houston.reconnect do
      touch :started_at
Severity: Minor
Found in app/models/action.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 run! is too high. [20.32/15]
Open

  def run!
    exception = nil

    Houston.reconnect do
      touch :started_at
Severity: Minor
Found in app/models/action.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 run! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run!
    exception = nil

    Houston.reconnect do
      touch :started_at
Severity: Minor
Found in app/models/action.rb - About 1 hr to fix

    Extra empty line detected before the rescue.
    Open

    
      rescue *::Action.ignored_exceptions
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks if empty lines exist around the bodies of begin sections. This cop doesn't check empty lines at begin body beginning/end and around method definition body. Style/EmptyLinesAroundBeginBody or Style/EmptyLinesAroundMethodBody can be used for this purpose.

    Example:

    # good
    
    begin
      do_something
    rescue
      do_something2
    else
      do_something3
    ensure
      do_something4
    end
    
    # good
    
    def foo
      do_something
    rescue
      do_something2
    end
    
    # bad
    
    begin
      do_something
    
    rescue
    
      do_something2
    
    else
    
      do_something3
    
    ensure
    
      do_something4
    end
    
    # bad
    
    def foo
      do_something
    
    rescue
    
      do_something2
    end

    Line is too long. [100/80]
    Open

        rescue Exception # rescues StandardError by default; but we want to rescue and report all errors
    Severity: Minor
    Found in app/models/action.rb by rubocop

    Extra empty line detected before the ensure.
    Open

    
      ensure
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks if empty lines exist around the bodies of begin sections. This cop doesn't check empty lines at begin body beginning/end and around method definition body. Style/EmptyLinesAroundBeginBody or Style/EmptyLinesAroundMethodBody can be used for this purpose.

    Example:

    # good
    
    begin
      do_something
    rescue
      do_something2
    else
      do_something3
    ensure
      do_something4
    end
    
    # good
    
    def foo
      do_something
    rescue
      do_something2
    end
    
    # bad
    
    begin
      do_something
    
    rescue
    
      do_something2
    
    else
    
      do_something3
    
    ensure
    
      do_something4
    end
    
    # bad
    
    def foo
      do_something
    
    rescue
    
      do_something2
    end

    Extra empty line detected after the rescue.
    Open

    
        # Report all other exceptions
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks if empty lines exist around the bodies of begin sections. This cop doesn't check empty lines at begin body beginning/end and around method definition body. Style/EmptyLinesAroundBeginBody or Style/EmptyLinesAroundMethodBody can be used for this purpose.

    Example:

    # good
    
    begin
      do_something
    rescue
      do_something2
    else
      do_something3
    ensure
      do_something4
    end
    
    # good
    
    def foo
      do_something
    rescue
      do_something2
    end
    
    # bad
    
    begin
      do_something
    
    rescue
    
      do_something2
    
    else
    
      do_something3
    
    ensure
    
      do_something4
    end
    
    # bad
    
    def foo
      do_something
    
    rescue
    
      do_something2
    end

    Indent the right brace the same as the first position after the preceding left parenthesis.
    Open

          })
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the AlignHash cop.

    By default, Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.

    Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.

    This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_braces'. Here are examples:

    Example: EnforcedStyle: specialinsideparentheses (default)

    # The `special_inside_parentheses` style enforces that the first key
    # in a hash literal where the opening brace and the first key are on
    # separate lines is indented one step (two spaces) more than the
    # position inside the opening parentheses.
    
    # bad
    hash = {
      key: :value
    }
    and_in_a_method_call({
      no: :difference
                         })
    
    # good
    special_inside_parentheses
    hash = {
      key: :value
    }
    but_in_a_method_call({
                           its_like: :this
                         })

    Example: EnforcedStyle: consistent

    # The `consistent` style enforces that the first key in a hash
    # literal where the opening brace and the first key are on
    # seprate lines is indented the same as a hash literal which is not
    # defined inside a method call.
    
    # bad
    hash = {
      key: :value
    }
    but_in_a_method_call({
                           its_like: :this
                          })
    
    # good
    hash = {
      key: :value
    }
    and_in_a_method_call({
      no: :difference
    })

    Example: EnforcedStyle: align_braces

    # The `align_brackets` style enforces that the opening and closing
    # braces are indented to the same position.
    
    # bad
    and_now_for_something = {
                              completely: :different
    }
    
    # good
    and_now_for_something = {
                              completely: :different
                            }

    Line is too long. [93/80]
    Open

        update_attributes! started_at: Time.now, finished_at: nil, succeeded: nil, exception: nil
    Severity: Minor
    Found in app/models/action.rb by rubocop

    Extra blank line detected.
    Open

    
    
    
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    Line is too long. [98/80]
    Open

      rescue Exception # rescues StandardError by default; but we want to rescue and report all errors
    Severity: Minor
    Found in app/models/action.rb by rubocop

    Prefer $ERROR_INFO from the stdlib 'English' module (don't forget to require it) over $!.
    Open

        exception = $!
    Severity: Minor
    Found in app/models/action.rb by rubocop

    Extra empty line detected at class body beginning.
    Open

    
      validates :name, presence: true
    Severity: Minor
    Found in app/models/action.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

    Extra empty line detected at class body end.
    Open

    
    end
    Severity: Minor
    Found in app/models/action.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

    Extra blank line detected.
    Open

    
      class << self
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    Extra blank line detected.
    Open

    
    
    
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    Missing top-level class documentation comment.
    Open

    class Action < ActiveRecord::Base
    Severity: Minor
    Found in app/models/action.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

    Prefer $ERROR_INFO from the stdlib 'English' module (don't forget to require it) over $!.
    Open

        exception = $!
    Severity: Minor
    Found in app/models/action.rb by rubocop

    Prefer $ERROR_INFO from the stdlib 'English' module (don't forget to require it) over $!.
    Open

        Houston.report_exception($!, parameters: {
    Severity: Minor
    Found in app/models/action.rb by rubocop

    Extra blank line detected.
    Open

    
      def run!
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
    Open

      rescue Exception # rescues StandardError by default; but we want to rescue and report all errors
    
        # Report all other exceptions
        exception = $!
        Houston.report_exception($!, parameters: {
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cop checks for rescue blocks targeting the Exception class.

    Example:

    # bad
    
    begin
      do_something
    rescue Exception
      handle_exception
    end

    Example:

    # good
    
    begin
      do_something
    rescue ArgumentError
      handle_exception
    end

    Prefer $ERROR_INFO from the stdlib 'English' module (don't forget to require it) over $!.
    Open

          Houston.report_exception($!, parameters: {
    Severity: Minor
    Found in app/models/action.rb by rubocop

    Extra empty line detected after the rescue.
    Open

    
        # Note that the action failed, but do not report _these_ exceptions
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks if empty lines exist around the bodies of begin sections. This cop doesn't check empty lines at begin body beginning/end and around method definition body. Style/EmptyLinesAroundBeginBody or Style/EmptyLinesAroundMethodBody can be used for this purpose.

    Example:

    # good
    
    begin
      do_something
    rescue
      do_something2
    else
      do_something3
    ensure
      do_something4
    end
    
    # good
    
    def foo
      do_something
    rescue
      do_something2
    end
    
    # bad
    
    begin
      do_something
    
    rescue
    
      do_something2
    
    else
    
      do_something3
    
    ensure
    
      do_something4
    end
    
    # bad
    
    def foo
      do_something
    
    rescue
    
      do_something2
    end

    Extra empty line detected before the rescue.
    Open

    
      rescue Exception # rescues StandardError by default; but we want to rescue and report all errors
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks if empty lines exist around the bodies of begin sections. This cop doesn't check empty lines at begin body beginning/end and around method definition body. Style/EmptyLinesAroundBeginBody or Style/EmptyLinesAroundMethodBody can be used for this purpose.

    Example:

    # good
    
    begin
      do_something
    rescue
      do_something2
    else
      do_something3
    ensure
      do_something4
    end
    
    # good
    
    def foo
      do_something
    rescue
      do_something2
    end
    
    # bad
    
    begin
      do_something
    
    rescue
    
      do_something2
    
    else
    
      do_something3
    
    ensure
    
      do_something4
    end
    
    # bad
    
    def foo
      do_something
    
    rescue
    
      do_something2
    end

    Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
    Open

            action_id: id,
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the AlignHash cop.

    By default, Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.

    Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.

    This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_braces'. Here are examples:

    Example: EnforcedStyle: specialinsideparentheses (default)

    # The `special_inside_parentheses` style enforces that the first key
    # in a hash literal where the opening brace and the first key are on
    # separate lines is indented one step (two spaces) more than the
    # position inside the opening parentheses.
    
    # bad
    hash = {
      key: :value
    }
    and_in_a_method_call({
      no: :difference
                         })
    
    # good
    special_inside_parentheses
    hash = {
      key: :value
    }
    but_in_a_method_call({
                           its_like: :this
                         })

    Example: EnforcedStyle: consistent

    # The `consistent` style enforces that the first key in a hash
    # literal where the opening brace and the first key are on
    # seprate lines is indented the same as a hash literal which is not
    # defined inside a method call.
    
    # bad
    hash = {
      key: :value
    }
    but_in_a_method_call({
                           its_like: :this
                          })
    
    # good
    hash = {
      key: :value
    }
    and_in_a_method_call({
      no: :difference
    })

    Example: EnforcedStyle: align_braces

    # The `align_brackets` style enforces that the opening and closing
    # braces are indented to the same position.
    
    # bad
    and_now_for_something = {
                              completely: :different
    }
    
    # good
    and_now_for_something = {
                              completely: :different
                            }

    Line is too long. [93/80]
    Open

        update_attributes! finished_at: Time.now, succeeded: exception.nil?, exception: exception
    Severity: Minor
    Found in app/models/action.rb by rubocop

    Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
    Open

          action_id: id,
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the AlignHash cop.

    By default, Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.

    Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.

    This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_braces'. Here are examples:

    Example: EnforcedStyle: specialinsideparentheses (default)

    # The `special_inside_parentheses` style enforces that the first key
    # in a hash literal where the opening brace and the first key are on
    # separate lines is indented one step (two spaces) more than the
    # position inside the opening parentheses.
    
    # bad
    hash = {
      key: :value
    }
    and_in_a_method_call({
      no: :difference
                         })
    
    # good
    special_inside_parentheses
    hash = {
      key: :value
    }
    but_in_a_method_call({
                           its_like: :this
                         })

    Example: EnforcedStyle: consistent

    # The `consistent` style enforces that the first key in a hash
    # literal where the opening brace and the first key are on
    # seprate lines is indented the same as a hash literal which is not
    # defined inside a method call.
    
    # bad
    hash = {
      key: :value
    }
    but_in_a_method_call({
                           its_like: :this
                          })
    
    # good
    hash = {
      key: :value
    }
    and_in_a_method_call({
      no: :difference
    })

    Example: EnforcedStyle: align_braces

    # The `align_brackets` style enforces that the opening and closing
    # braces are indented to the same position.
    
    # bad
    and_now_for_something = {
                              completely: :different
    }
    
    # good
    and_now_for_something = {
                              completely: :different
                            }

    Indent the right brace the same as the first position after the preceding left parenthesis.
    Open

        })
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cops checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the AlignHash cop.

    By default, Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.

    Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.

    This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_braces'. Here are examples:

    Example: EnforcedStyle: specialinsideparentheses (default)

    # The `special_inside_parentheses` style enforces that the first key
    # in a hash literal where the opening brace and the first key are on
    # separate lines is indented one step (two spaces) more than the
    # position inside the opening parentheses.
    
    # bad
    hash = {
      key: :value
    }
    and_in_a_method_call({
      no: :difference
                         })
    
    # good
    special_inside_parentheses
    hash = {
      key: :value
    }
    but_in_a_method_call({
                           its_like: :this
                         })

    Example: EnforcedStyle: consistent

    # The `consistent` style enforces that the first key in a hash
    # literal where the opening brace and the first key are on
    # seprate lines is indented the same as a hash literal which is not
    # defined inside a method call.
    
    # bad
    hash = {
      key: :value
    }
    but_in_a_method_call({
                           its_like: :this
                          })
    
    # good
    hash = {
      key: :value
    }
    and_in_a_method_call({
      no: :difference
    })

    Example: EnforcedStyle: align_braces

    # The `align_brackets` style enforces that the opening and closing
    # braces are indented to the same position.
    
    # bad
    and_now_for_something = {
                              completely: :different
    }
    
    # good
    and_now_for_something = {
                              completely: :different
                            }

    Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
    Open

        rescue Exception # rescues StandardError by default; but we want to rescue and report all errors
          Houston.report_exception($!, parameters: {
            action_id: id,
            action_name: name,
            trigger: trigger,
    Severity: Minor
    Found in app/models/action.rb by rubocop

    This cop checks for rescue blocks targeting the Exception class.

    Example:

    # bad
    
    begin
      do_something
    rescue Exception
      handle_exception
    end

    Example:

    # good
    
    begin
      do_something
    rescue ArgumentError
      handle_exception
    end

    There are no issues that match your filters.

    Category
    Status