WeAreFarmGeek/diplomat

View on GitHub

Showing 64 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

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        def read(id, options = {}, not_found = :reject, found = :return)
          @options = options
          custom_params = []
          custom_params << use_consistency(options)
    
    
    Severity: Major
    Found in lib/diplomat/role.rb and 2 other locations - About 2 hrs to fix
    lib/diplomat/policy.rb on lines 14..44
    lib/diplomat/role.rb on lines 53..83

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 99.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        def read(id, options = {}, not_found = :reject, found = :return)
          @options = options
          custom_params = []
          custom_params << use_consistency(options)
    
    
    Severity: Major
    Found in lib/diplomat/policy.rb and 2 other locations - About 2 hrs to fix
    lib/diplomat/role.rb on lines 14..44
    lib/diplomat/role.rb on lines 53..83

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 99.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        def read_name(name, options = {}, not_found = :reject, found = :return)
          @options = options
          custom_params = []
          custom_params << use_consistency(options)
    
    
    Severity: Major
    Found in lib/diplomat/role.rb and 2 other locations - About 2 hrs to fix
    lib/diplomat/policy.rb on lines 14..44
    lib/diplomat/role.rb on lines 14..44

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 99.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

    Similar blocks of code found in 2 locations. 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: Major
    Found in lib/diplomat/role.rb and 1 other location - About 2 hrs to fix
    lib/diplomat/policy.rb on lines 84..101

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 81.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. 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: Major
    Found in lib/diplomat/policy.rb and 1 other location - About 2 hrs to fix
    lib/diplomat/role.rb on lines 123..140

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 81.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

    Similar blocks of code found in 2 locations. 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: Major
    Found in lib/diplomat/role.rb and 1 other location - About 1 hr to fix
    lib/diplomat/policy.rb on lines 62..77

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 72.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        def update(value, options = {})
          id = value[:ID] || value['ID']
          raise Diplomat::IdParameterRequired if id.nil?
    
          policy_name = value[:Name] || value['Name']
    Severity: Major
    Found in lib/diplomat/policy.rb and 1 other location - About 1 hr to fix
    lib/diplomat/role.rb on lines 101..116

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 72.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

          Severity
          Category
          Status
          Source
          Language