archan937/magnum-pi

View on GitHub

Showing 6 of 10 total issues

Method finalize_element has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def finalize_element
    if element = elements.pop
      values = element.delete :values
      index = element.delete :index
      if text = element.delete(:text)
Severity: Minor
Found in lib/magnum-pi/gem_ext/ox/ax.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 process_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def process_value(name, args, block)
        value = args[0]
        if name == :resources
          (_values[name] ||= {}).merge! value
        else
Severity: Minor
Found in lib/magnum-pi/api/scheme.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 request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def request(method, url, params)
        puts "#{method.upcase} #{url} #{"(#{params.inspect[1..-2]})" if params && params.size > 0}" if MagnumPI.debug_output?
        args = [method, url, params]
        args << nil if method.to_s.upcase == "GET"
        args << request_headers(method, url, params)
Severity: Minor
Found in lib/magnum-pi/api/consumer.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 fetch_with_retry has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        uri,
        method    = :get,
        headers   = {},
        params    = [],
        referer   = current_page,
Severity: Minor
Found in lib/magnum-pi/gem_ext/mechanize/http/agent.rb - About 45 mins to fix

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

          def fetch_with_retry(
            uri,
            method    = :get,
            headers   = {},
            params    = [],
    Severity: Minor
    Found in lib/magnum-pi/gem_ext/mechanize/http/agent.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 download has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def download(target, method, *args)
            url, params = parse_args *args
            File.delete target if File.exists? target
            FileUtils.mkdir_p File.dirname(target)
            file = File.open target, "w"
    Severity: Minor
    Found in lib/magnum-pi/api/consumer.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