locomotivecms/coal

View on GitHub

Showing 7 of 7 total issues

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

  class Client

    attr_reader :uri, :credentials, :options

    def initialize(uri, credentials, options = {})
Severity: Minor
Found in lib/locomotive/coal/client.rb - About 2 hrs to fix

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

          def do_request(action, endpoint, parameters = {}, raw = false)
            max_count = 5
            response = begin
              # Just uncomment following line if you want to trace protocol between wagon & engine live
              # puts "#{parameters}"
    Severity: Minor
    Found in lib/locomotive/coal/resources/concerns/request.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 _encode_parameters has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def _encode_parameters(parameters)
            return parameters unless parameters.is_a?(Hash)
            parameters.tap do
              parameters.each do |key, value|
                if value.is_a?(Array)
    Severity: Minor
    Found in lib/locomotive/coal/resources/concerns/request.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 do_request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def do_request(action, endpoint, parameters = {}, raw = false)
            max_count = 5
            response = begin
              # Just uncomment following line if you want to trace protocol between wagon & engine live
              # puts "#{parameters}"
    Severity: Minor
    Found in lib/locomotive/coal/resources/concerns/request.rb - About 1 hr to fix

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

          def prepare_uri(str)
            str = "http://#{str.to_s}" unless str.to_s =~ /^https?:\/\//
      
            URI(str).tap do |uri|
              if ssl?
      Severity: Minor
      Found in lib/locomotive/coal/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 _request_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def _request_headers(parameters)
              { 'Accept' => 'application/json' }.tap do |headers|
                if _token
                  headers['X-Locomotive-Account-Email'] = credentials[:email]
                  headers['X-Locomotive-Account-Token'] = credentials[:token]
      Severity: Minor
      Found in lib/locomotive/coal/resources/concerns/request.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 build_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_message
            attributes = (body['attributes'] || body).map do |name, errors|
              if errors.is_a?(Hash)
                errors.map do |k, _errors|
                  "#{name}.#{k}: #{_errors.join(' + ')}"
      Severity: Minor
      Found in lib/locomotive/coal/error.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