livingsocial/rearview-engine

View on GitHub
lib/rearview/monitor_runner.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method exec_process has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def exec_process(expr = "", namespace = {}.to_json, immediate=false)
        logger.debug "#{self} exec_process"

        # create script template
        script_text = self.monitor_script % {utilities: self.utilities_script, expression: expr, timeout: Rearview.config.sandbox_timeout, namespace: namespace}
Severity: Minor
Found in lib/rearview/monitor_runner.rb - About 1 hr to fix

    Method normalize_results has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def normalize_results(results)
            normalized = { status: "error", output: nil, graph_data: nil }
            unless results.nil?
              if results[:monitor_output]
                normalized[:status] = results[:monitor_output][:status]
    Severity: Minor
    Found in lib/rearview/monitor_runner.rb - About 1 hr 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

    Method eval has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def eval(data, expr = nil, initial_ns = {}, verbose = false, immediate = false)
            logger.debug "#{self} eval"
            # prepare variable map for the monitor process
            namespace = create_namespace(data, initial_ns)
    
    
    Severity: Minor
    Found in lib/rearview/monitor_runner.rb - About 1 hr to fix

      Method eval has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def eval(data, expr = nil, initial_ns = {}, verbose = false, immediate = false)
              logger.debug "#{self} eval"
              # prepare variable map for the monitor process
              namespace = create_namespace(data, initial_ns)
      
      
      Severity: Minor
      Found in lib/rearview/monitor_runner.rb - About 55 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

      Method run has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def run(metrics,
                    monitor_expr = nil,
                    minutes      = nil,
                    namespace    = {},
                    verbose      = false,
      Severity: Major
      Found in lib/rearview/monitor_runner.rb - About 50 mins to fix

        Method eval has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def eval(data, expr = nil, initial_ns = {}, verbose = false, immediate = false)
        Severity: Minor
        Found in lib/rearview/monitor_runner.rb - About 35 mins to fix

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

                def exec_process(expr = "", namespace = {}.to_json, immediate=false)
                  logger.debug "#{self} exec_process"
          
                  # create script template
                  script_text = self.monitor_script % {utilities: self.utilities_script, expression: expr, timeout: Rearview.config.sandbox_timeout, namespace: namespace}
          Severity: Minor
          Found in lib/rearview/monitor_runner.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

          There are no issues that match your filters.

          Category
          Status