WeAreFarmGeek/diplomat

View on GitHub

Showing 45 of 64 total issues

Method get has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def get(key, options = {}, not_found = :reject, found = :return)
      @options = options
      return_nil_values = @options && @options[:nil_values]
      transformation = @options && @options[:transformation] && @options[:transformation].methods.find_index(:call) ? @options[:transformation] : nil
      raw = get_raw(key, options)
Severity: Minor
Found in lib/diplomat/kv.rb - About 3 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

Class RestClient has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

  class RestClient
    @access_methods = []
    @configuration = nil

    # Initialize the fadaray connection
Severity: Minor
Found in lib/diplomat/rest_client.rb - About 2 hrs to fix

    Method send_get_request has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def send_get_request(connection, url, options, custom_params = nil)
          rest_options = parse_options(options)
          url += rest_options[:query_params]
          url += custom_params unless custom_params.nil?
          begin
    Severity: Minor
    Found in lib/diplomat/rest_client.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 send_put_request has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def send_put_request(connection, url, options, data, custom_params = nil, mime = 'application/json')
          rest_options = parse_options(options)
          url += rest_options[:query_params]
          url += custom_params unless custom_params.nil?
          connection.put do |req|
    Severity: Minor
    Found in lib/diplomat/rest_client.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 get_all has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_all(key, options = {}, not_found = :reject, found = :return)
          @options = options
          @options[:recurse] = true
          return_nil_values = @options && @options[:nil_values]
          transformation = @options && @options[:transformation] && @options[:transformation].methods.find_index(:call) ? @options[:transformation] : nil
    Severity: Minor
    Found in lib/diplomat/kv.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 get has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def get(key, scope = :first, options = {}, meta = nil)
          custom_params = []
          custom_params << use_named_parameter('wait', options[:wait]) if options[:wait]
          custom_params << use_named_parameter('index', options[:index]) if options[:index]
          custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]
    Severity: Minor
    Found in lib/diplomat/service.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 service has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def service(s, options = {}, meta = nil)
          custom_params = []
          custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]
          custom_params << ['passing'] if options[:passing]
          custom_params += [*options[:tag]].map { |value| use_named_parameter('tag', value) } if options[:tag]
    Severity: Minor
    Found in lib/diplomat/health.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 return_value has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def return_value(nil_values = false, transformation = nil, return_hash = false)
          @value = decode_values
          return @value if @value.first.is_a? String
    
          if @value.count == 1 && !return_hash
    Severity: Minor
    Found in lib/diplomat/rest_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 get has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def get(name = nil, token = :last, not_found = :wait, found = :return, options = {})
          @raw = send_get_request(@conn, ['/v1/event/list'], options, use_named_parameter('name', name))
          body = JSON.parse(@raw.body)
          # TODO: deal with unknown symbols, invalid indices (find_index will return nil)
          idx = case token
    Severity: Minor
    Found in lib/diplomat/event.rb - About 1 hr to fix

      Method get has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def get(name = nil, token = :last, not_found = :wait, found = :return, options = {})
            @raw = send_get_request(@conn, ['/v1/event/list'], options, use_named_parameter('name', name))
            body = JSON.parse(@raw.body)
            # TODO: deal with unknown symbols, invalid indices (find_index will return nil)
            idx = case token
      Severity: Minor
      Found in lib/diplomat/event.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 get has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def get(key, options = {}, not_found = :reject, found = :return)
            @options = options
            return_nil_values = @options && @options[:nil_values]
            transformation = @options && @options[:transformation] && @options[:transformation].methods.find_index(:call) ? @options[:transformation] : nil
            raw = get_raw(key, options)
      Severity: Minor
      Found in lib/diplomat/kv.rb - About 1 hr to fix

        Method get_all has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def get_all(key, options = {}, not_found = :reject, found = :return)
              @options = options
              @options[:recurse] = true
              return_nil_values = @options && @options[:nil_values]
              transformation = @options && @options[:transformation] && @options[:transformation].methods.find_index(:call) ? @options[:transformation] : nil
        Severity: Minor
        Found in lib/diplomat/kv.rb - About 1 hr to fix

          Method read_name has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def read_name(name, options = {}, not_found = :reject, found = :return)
                @options = options
                custom_params = []
                custom_params << use_consistency(options)
          
          
          Severity: Minor
          Found in lib/diplomat/role.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 read has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def read(id, options = {}, not_found = :reject, found = :return)
                @options = options
                custom_params = []
                custom_params << use_consistency(options)
          
          
          Severity: Minor
          Found in lib/diplomat/policy.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 send_post_request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def send_post_request(connection, url, options, data, custom_params = nil)
                rest_options = parse_options(options)
                url += rest_options[:query_params]
                url += custom_params unless custom_params.nil?
                connection.post do |req|
          Severity: Minor
          Found in lib/diplomat/rest_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 read has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def read(id, options = {}, not_found = :reject, found = :return)
                @options = options
                custom_params = []
                custom_params << use_consistency(options)
          
          
          Severity: Minor
          Found in lib/diplomat/role.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 read has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def read(id, options = {}, not_found = :reject, found = :return)
                @options = options
                custom_params = []
                custom_params << use_consistency(options)
          
          
          Severity: Minor
          Found in lib/diplomat/role.rb - About 1 hr to fix

            Method read has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def read(id, options = {}, not_found = :reject, found = :return)
                  @options = options
                  custom_params = []
                  custom_params << use_consistency(options)
            
            
            Severity: Minor
            Found in lib/diplomat/policy.rb - About 1 hr to fix

              Method read_name has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def read_name(name, options = {}, not_found = :reject, found = :return)
                    @options = options
                    custom_params = []
                    custom_params << use_consistency(options)
              
              
              Severity: Minor
              Found in lib/diplomat/role.rb - About 1 hr to fix

                Method decode_transaction has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def decode_transaction(transaction)
                      return transaction if transaction['Results'].nil? || transaction['Results'].empty?
                
                      transaction.tap do |txn|
                        txn['Results'].each do |resp|
                Severity: Minor
                Found in lib/diplomat/kv.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

                Severity
                Category
                Status
                Source
                Language