werein/prestashop

View on GitHub
lib/prestashop/api/connection.rb

Summary

Maintainability
C
1 day
Test Coverage

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

      def get resource, id = nil, opts = {}
        id.to_i unless id.kind_of?(Array)
        raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
        raise ArgumentError, "id: #{id} must be integer, array or nil" unless id.kind_of?(Integer) or id.kind_of?(Array) or id == nil

Severity: Minor
Found in lib/prestashop/api/connection.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 upload has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def upload type, resource, id, payload, file
        raise ArgumentError, "type: #{type} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
        raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
        raise ArgumentError, "id: #{id} must be integer" unless id.to_i.kind_of?(Integer)

Severity: Minor
Found in lib/prestashop/api/connection.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 head has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def head resource, id = nil
        raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
        raise ArgumentError, "id: #{id} must be integer or nil" unless id.to_i.kind_of?(Integer) or id == nil

        request_path = path(resource, id)
Severity: Minor
Found in lib/prestashop/api/connection.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 delete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def delete resource, id
        raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
        raise ArgumentError, "id: #{id} must be integer" unless id.to_i.kind_of?(Integer)

        request_path = path(resource, id)
Severity: Minor
Found in lib/prestashop/api/connection.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 put has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def put resource, id, payload
        raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
        raise ArgumentError, "id: #{id} must be integer" unless id.to_i.kind_of?(Integer)

        request_path = path(resource, id)
Severity: Minor
Found in lib/prestashop/api/connection.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 post has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def post resource, payload
        raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)

        request_path = path(resource)
        response = connection.post request_path, payload
Severity: Minor
Found in lib/prestashop/api/connection.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 upload has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def upload type, resource, id, payload, file
Severity: Minor
Found in lib/prestashop/api/connection.rb - About 35 mins to fix

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

          def api_url= origin_url
            url = origin_url.match(/^(http|https):\/\/.*/)
            url = url.nil? ? 'http://' + origin_url : url.to_s
            url << '/' unless url.end_with? '/'
            url << 'api/' unless url.end_with? 'api/'
    Severity: Minor
    Found in lib/prestashop/api/connection.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

    There are no issues that match your filters.

    Category
    Status