cloudfoundry/collector

View on GitHub

Showing 9 of 12 total issues

Method fetch has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def fetch(type)
      @components.each do |job, instances|
        instances.each do |index, instance|
          next unless credentials_ok?(job, instance)

Severity: Minor
Found in lib/collector.rb - About 2 hrs 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 fetch has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def fetch(type)
      @components.each do |job, instances|
        instances.each do |index, instance|
          next unless credentials_ok?(job, instance)

Severity: Minor
Found in lib/collector.rb - About 1 hr to fix

    Method process has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def process(context)
            varz = context.varz
    
            send_metric("router.total_requests", varz["requests"], context)
            send_metric("router.total_routes", varz["urls"], context)
    Severity: Minor
    Found in lib/collector/handlers/router.rb - About 1 hr to fix

      Method configure has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def configure(config)
              @index = config["index"].to_i
              setup_logging(config["logging"])
      
              @deployment_name = config["deployment_name"] || "untitled_dev"
      Severity: Minor
      Found in lib/collector/config.rb - About 1 hr to fix

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

            def unbind
              if @port && @ip
                Config.logger.warn("#{@logger_name}-connection-lost")
                EM.add_timer(1.0) do
                  begin
        Severity: Minor
        Found in lib/collector/tcp_connection.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

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

            def do_process(context)
              varz = context.varz
        
              MEM_AND_CPU_STATS.each { |stat| send_metric(stat, varz[stat], context) if varz[stat] }
        
        
        Severity: Minor
        Found in lib/collector/handler.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

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

            def process_plan_score_metric(context)
              varz = context.varz
        
              return unless varz.include?("plans")
              if varz["plans"]
        Severity: Minor
        Found in lib/collector/service_gateway_handler.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

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

              def get_metrics_name(properties)
                # Given a properties hash like so
                # {:key=>"cpu_load_avg", :timestamp=>1394801347, :value=>0.25, :tags=>{:ip=>"172.30.5.74", :role=>"core", :job=>"CloudController", :index=>0, :name=>"CloudController/0", :deployment=>"CF"}}
                # One will get a metrics key like so
                # CF.CloudController.0.172-30-5-74.cpu_load_avg
        Severity: Minor
        Found in lib/collector/historian/graphite.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

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

              def process(context)
                varz = context.varz
        
                send_metric("router.total_requests", varz["requests"], context)
                send_metric("router.total_routes", varz["urls"], context)
        Severity: Minor
        Found in lib/collector/handlers/router.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

        Severity
        Category
        Status
        Source
        Language