hawkular/hawkular-client-ruby

View on GitHub

Showing 12 of 23 total issues

File alerts_api.rb has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'hawkular/base_client'
require 'ostruct'

# Alerts module provides access to Hawkular-Alerts.
# There are three main parts here:
Severity: Minor
Found in lib/hawkular/alerts/alerts_api.rb - About 4 hrs to fix

    Class Client has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Client < Hawkular::BaseClient
        def initialize(entrypoint, credentials = {}, options = {})
          entrypoint = normalize_entrypoint_url entrypoint, 'hawkular/alerts'
          @entrypoint = entrypoint
    
    
    Severity: Minor
    Found in lib/hawkular/alerts/alerts_api.rb - About 4 hrs to fix

      Class Client has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Client < Hawkular::BaseClient
          include WebSocket::Client
          include MonitorMixin
      
          attr_accessor :ws, :logger
      Severity: Minor
      Found in lib/hawkular/operations/operations_api.rb - About 2 hrs to fix

        Method invoke_operation_helper has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def invoke_operation_helper(operation_payload, operation_name = nil, binary_content = nil, &callback)
              synchronize { connect }
        
              # fallback to generic 'ExecuteOperation' if nothing is specified
              operation_name ||= 'ExecuteOperation'
        Severity: Minor
        Found in lib/hawkular/operations/operations_api.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 handle_fault has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_fault(f)
              http_code = (f.respond_to?(:http_code) ? f.http_code : 0)
              fail Hawkular::Exception.new('Unauthorized', http_code) if f.instance_of? RestClient::Unauthorized
        
              if f.respond_to?(:http_body) && !f.http_body.nil?
        Severity: Minor
        Found in lib/hawkular/base_client.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 check_pre_conditions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_pre_conditions(hash = {}, params = [], &callback)
              fail Hawkular::ArgumentError, 'Hash cannot be nil.' if hash.nil?
              fail Hawkular::ArgumentError, 'callback must have the perform method defined. include Hawkular::Operations' unless
                  callback.nil? || callback.respond_to?('perform')
        
        
        Severity: Minor
        Found in lib/hawkular/operations/operations_api.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 handle_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_message(operation_name, operation_payload, &callback)
              client = @ws
              # register a callback handler
              @ws.on :message do |msg|
                parsed = msg.data.to_msg_hash
        Severity: Minor
        Found in lib/hawkular/operations/operations_api.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 generate_query_params has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def generate_query_params(params = {})
              params = params.reject { |_k, v| v.nil? || ((v.instance_of? Array) && v.empty?) }
              return '' if params.empty?
        
              params.inject('?') do |ret, (k, v)|
        Severity: Minor
        Found in lib/hawkular/base_client.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 export_jdr has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def export_jdr(resource_id, feed_id, delete_immediately = false, sender_request_id = nil, &callback)
        Severity: Minor
        Found in lib/hawkular/operations/operations_api.rb - About 35 mins to fix

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

                def to_msg_hash
                  operation_name, json = split('=', 2)
          
                  # Check if there is a zip file following JSON.
                  # This check is done only in the first 100KB, hoping it's unlikely to
          Severity: Minor
          Found in lib/hawkular/operations/operations_api.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(args)
                args = {
                  credentials: {},
                  options: {},
                  wait_time: 0.5,
          Severity: Minor
          Found in lib/hawkular/operations/operations_api.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_data_helper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def get_data_helper(id, params)
                  path = "/#{@resource}/#{ERB::Util.url_encode(id)}/"
                  path << if @legacy_api
                            'data/?'
                          elsif params[:bucketDuration].nil? && params[:buckets].nil?
          Severity: Minor
          Found in lib/hawkular/metrics/metric_api.rb - About 25 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