opal/opal-browser

View on GitHub
opal/browser/http/request.rb

Summary

Maintainability
D
1 day
Test Coverage

Method send has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

  def send(parameters = @parameters)
    raise 'the request has not been opened' unless opened?

    raise 'the request has already been sent' if sent?

Severity: Minor
Found in opal/browser/http/request.rb - About 4 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 Request has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

class Request
  include Native::Wrapper
  include Event::Target

  # Default headers.
Severity: Minor
Found in opal/browser/http/request.rb - About 3 hrs to fix

    Method open has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def open(method = nil, url = nil, asynchronous = nil, user = nil, password = nil)
        raise 'the request has already been opened' if opened?
    
        @method       = method       unless method.nil?
        @url          = url          unless url.nil?
    Severity: Minor
    Found in opal/browser/http/request.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 has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def send(parameters = @parameters)
        raise 'the request has not been opened' unless opened?
    
        raise 'the request has already been sent' if sent?
    
    
    Severity: Minor
    Found in opal/browser/http/request.rb - About 1 hr to fix

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

        def open(method = nil, url = nil, asynchronous = nil, user = nil, password = nil)
      Severity: Minor
      Found in opal/browser/http/request.rb - About 35 mins to fix

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

          def callback
            -> event {
              state = STATES[`#@native.readyState`]
              res   = response
        
        
        Severity: Minor
        Found in opal/browser/http/request.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