WeAreFarmGeek/diplomat

View on GitHub

Showing 45 of 64 total issues

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

    def info(id, options = {}, not_found = :reject, found = :return)
      @id = id
      @options = options
      custom_params = []
      custom_params << use_consistency(options)
Severity: Minor
Found in lib/diplomat/acl.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 fire has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def fire(name, value = nil, service = nil, node = nil, tag = nil, dc = nil, options = {})
Severity: Major
Found in lib/diplomat/event.rb - About 50 mins to fix

    Method read has a Cognitive Complexity of 8 (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/token.rb - About 45 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 transaction_verification has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def transaction_verification(transaction)
          raise Diplomat::InvalidTransaction unless transaction.is_a?(Array)
    
          transaction.each do |req|
            raise Diplomat::InvalidTransaction unless transaction_type_verification(req)
    Severity: Minor
    Found in lib/diplomat/kv.rb - About 45 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 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get(meta = nil, options = {})
          ret = send_get_request(@conn, ['/v1/catalog/datacenters'], options)
    
          if meta && ret.headers
            meta[:index] = ret.headers['x-consul-index'] if ret.headers['x-consul-index']
    Severity: Minor
    Found in lib/diplomat/datacenter.rb - About 45 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def create(value, options = {})
          blacklist = ['ID', 'iD', 'Id', :ID, :iD, :Id] & value.keys
          raise Diplomat::PolicyMalformed, 'ID should not be specified' unless blacklist.empty?
    
          id = value[:Name] || value['Name']
    Severity: Minor
    Found in lib/diplomat/policy.rb - About 45 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 register_script has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def register_script(check_id, name, notes, args, interval, options = {})
    Severity: Minor
    Found in lib/diplomat/check.rb - About 45 mins to fix

      Method send_put_request has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def send_put_request(connection, url, options, data, custom_params = nil, mime = 'application/json')
      Severity: Minor
      Found in lib/diplomat/rest_client.rb - About 45 mins to fix

        Method send_delete_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def send_delete_request(connection, url, options, custom_params = nil)
              rest_options = parse_options(options)
              url += rest_options[:query_params]
              url += custom_params unless custom_params.nil?
              connection.delete do |req|
        Severity: Minor
        Found in lib/diplomat/rest_client.rb - About 45 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def create(value, options = {})
              blacklist = ['ID', 'iD', 'Id', :ID, :iD, :Id] & value.keys
              raise Diplomat::RoleMalformed, 'ID should not be specified' unless blacklist.empty?
        
              id = value[:Name] || value['Name']
        Severity: Minor
        Found in lib/diplomat/role.rb - About 45 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 register_ttl has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def register_ttl(check_id, name, notes, ttl, options = {})
        Severity: Minor
        Found in lib/diplomat/check.rb - About 35 mins to fix

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

              def send_post_request(connection, url, options, data, custom_params = nil)
          Severity: Minor
          Found in lib/diplomat/rest_client.rb - About 35 mins to fix

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

                def wait_to_acquire(key, session, value = nil, check_interval = 10, options = {})
            Severity: Minor
            Found in lib/diplomat/lock.rb - About 35 mins to fix

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

                  def get(name = nil, token = :last, not_found = :wait, found = :return, options = {})
              Severity: Minor
              Found in lib/diplomat/event.rb - About 35 mins to fix

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

                  def self.consul_info(options = {})
                    consul_self = Diplomat::Agent.self(options)
                    puts 'Server: ' + consul_self['Config']['NodeName']
                    puts 'Datacenter: ' + consul_self['Config']['Datacenter']
                    puts 'Consul Version: ' + consul_self['Config']['Version']
                Severity: Minor
                Found in lib/diplomatic_bag/info.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 parse_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def parse_options(options)
                      headers = nil
                      query_params = []
                      url_prefix = nil
                      consistency = []
                Severity: Minor
                Found in lib/diplomat/rest_client.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

                Avoid too many return statements within this method.
                Open

                          return return_value(return_nil_values, transformation)
                Severity: Major
                Found in lib/diplomat/kv.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                            return convert_to_hash(return_value(return_nil_values, transformation, true)) if @options && @options[:convert_to_hash]
                  Severity: Major
                  Found in lib/diplomat/kv.rb - About 30 mins to fix

                    Method create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def create(value = nil, options = {})
                          # TODO: only certain keys are recognised in a session create request,
                          # should raise an error on others.
                          custom_params = []
                          custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]
                    Severity: Minor
                    Found in lib/diplomat/session.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

                    Method update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def update(value, options = {})
                          id = value[:ID] || value['ID']
                          raise Diplomat::IdParameterRequired if id.nil?
                    
                          role_name = value[:Name] || value['Name']
                    Severity: Minor
                    Found in lib/diplomat/role.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