opal/opal-browser

View on GitHub

Showing 71 of 87 total issues

Class Element has 60 methods (exceeds 20 allowed). Consider refactoring.
Open

class Element < Node
  def self.create(*args, &block)
    if Document === args.first
      document = args.shift
    else
Severity: Major
Found in opal/browser/dom/element.rb - About 1 day to fix

    Class Node has 56 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Node
      include Browser::NativeCachedWrapper
    
      ELEMENT_NODE                = 1
      ATTRIBUTE_NODE              = 2
    Severity: Major
    Found in opal/browser/dom/node.rb - About 1 day to fix

      Method supports? has 190 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.supports?(feature)
          if defined?(`#@support[#{feature}]`)
            return `#@support[#{feature}]`
          end
      
      
      Severity: Major
      Found in opal/browser/support.rb - About 7 hrs to fix

        Class Canvas has 38 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Canvas
          include Native::Wrapper
        
          attr_reader :element, :style, :text
        
        
        Severity: Minor
        Found in opal/browser/canvas.rb - About 5 hrs to fix

          File element.rb has 363 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Browser; module DOM
          
          class Element < Node
            def self.create(*args, &block)
              if Document === args.first
          Severity: Minor
          Found in opal/browser/dom/element.rb - About 4 hrs to fix

            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

            File node.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Browser; module DOM
            
            # Abstract class for all DOM node types.
            #
            # @see https://developer.mozilla.org/en-US/docs/Web/API/Node
            Severity: Minor
            Found in opal/browser/dom/node.rb - About 3 hrs to fix

              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

                File base.rb has 286 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module Browser
                
                class Event
                  include Native::Wrapper
                
                
                Severity: Minor
                Found in opal/browser/event/base.rb - About 2 hrs to fix

                  Class Event has 25 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Event
                    include Native::Wrapper
                  
                    # @see https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events
                    class Definition
                  Severity: Minor
                  Found in opal/browser/event/base.rb - About 2 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

                    Class Mouse has 24 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Mouse < UI
                      handles 'click', 'contextmenu', 'dblclick', 'mousedown', 'mouseenter',
                              'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup',
                              'show'
                    
                    
                    Severity: Minor
                    Found in opal/browser/event/mouse.rb - About 2 hrs to fix

                      Class Event has 24 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Event
                        def self.aliases
                          @aliases ||= {
                            'dom:load' => 'DOMContentLoaded',
                            'hover'    => 'mouse:over'
                      Severity: Minor
                      Found in opal/browser/event.rb - About 2 hrs to fix

                        Class Document has 23 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class Document < Element
                          include DocumentOrShadowRoot
                        
                          # Get the first element matching the given ID, CSS selector or XPath.
                          #
                        Severity: Minor
                        Found in opal/browser/dom/document.rb - About 2 hrs to fix

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

                          class Storage
                            def self.json_create(data)
                              data.delete(JSON.create_id)
                          
                              Hash[data.map {|key, value|
                          Severity: Minor
                          Found in opal/browser/storage.rb - About 2 hrs to fix

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

                              def DOM(*args, &block)
                                if block
                                  document = args.shift || $document
                                  roots    = Browser::DOM::Builder.new(document, &block).to_a
                            
                            
                            Severity: Minor
                            Found in opal/browser/dom.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 create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def self.create(*args, &block)
                                if Document === args.first
                                  document = args.shift
                                else
                                  document = $document
                            Severity: Minor
                            Found in opal/browser/dom/element.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 create_element has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def create_element(name, builder=nil, **options, &block)
                                  opts = {}
                              
                                  if options[:is] ||= (options.dig(:attrs, :is))
                                    opts[:is] = options[:is]
                              Severity: Minor
                              Found in opal/browser/dom/document.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 off has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def off(what = nil)
                                    case what
                                    when Callback
                                      callbacks.delete(what)
                                      detach(what)
                              Severity: Minor
                              Found in opal/browser/event/base.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