opal/opal-browser

View on GitHub

Showing 71 of 87 total issues

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

Method initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(*args)
    if DOM::Element === args.first
      element = args.shift

      if DOM::Element::Image === element
Severity: Minor
Found in opal/browser/canvas.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 on has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def on(name, selector = nil, &block)
      raise ArgumentError, 'no block has been given' unless block

      name = Event.name_for(name)

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

Method shake has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def shake(dir)
    grid = @grid
    conversion = proc {}
    back_conversion = nil

Severity: Minor
Found in examples/2048/app/application.rb - About 1 hr to fix

    Method DOM has 32 lines of code (exceeds 25 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 1 hr to fix

      Method initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(*args)
          if DOM::Element === args.first
            element = args.shift
      
            if DOM::Element::Image === element
      Severity: Minor
      Found in opal/browser/canvas.rb - About 1 hr to fix

        Method create_element has 29 lines of code (exceeds 25 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

          Method off has 29 lines of code (exceeds 25 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

            Method on has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def on(name, selector = nil, &block)
                  raise ArgumentError, 'no block has been given' unless block
            
                  name = Event.name_for(name)
            
            
            Severity: Minor
            Found in opal/browser/event/base.rb - About 1 hr to fix

              Method unflatten has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def unflatten(array)
                    out = {}
                    array.each do |k,v|
                      path = [k.split("[").first] + k.scan(/\[(.*?)\]/).flatten
                      c = out
              Severity: Minor
              Found in opal/browser/form_data.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 convert has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def convert(hash)
                  options = Native(`{}`)
              
                  if hash[:children]
                    options[:childList] = true
              Severity: Minor
              Found in opal/browser/dom/mutation_observer.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 []= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def []=(name, value, options = {})
                    if namespace = options[:namespace] || @namespace
                      if value
                        `#@native.setAttributeNS(#{namespace.to_s}, #{name.to_s}, #{value})`
                      else
              Severity: Minor
              Found in opal/browser/dom/element/attributes.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 transform has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def transform(m11, m12, m21, m22, dx, dy, &block)
              Severity: Major
              Found in opal/browser/canvas.rb - About 50 mins to fix

                Method ready has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def ready(&block)
                      raise ArgumentError, 'no block given' unless block
                
                      return block.call if ready?
                
                
                Severity: Minor
                Found in opal/browser/dom/document.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 new has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.new(*args, &block)
                    if args.length == 1 && !block_given? && Opal.native?(args[0])
                      # Use `.new` as a wrapping method.
                      node = args[0]
                    else
                Severity: Minor
                Found in opal/browser/dom/element.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 [] has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def [](name, options = {})
                      if name == :class && Browser.supports?('Element.className')
                        name = :className
                      elsif name == :for && Browser.supports?('Element.htmlFor')
                        name = :htmlFor
                Severity: Minor
                Found in opal/browser/dom/element/attributes.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 supports? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.supports?(feature)
                    if defined?(`#@support[#{feature}]`)
                      return `#@support[#{feature}]`
                    end
                
                
                Severity: Minor
                Found in opal/browser/support.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 bezier_curve_to has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def bezier_curve_to(cp1x, cp1y, cp2x, cp2y, x, y)
                Severity: Minor
                Found in opal/browser/canvas.rb - About 45 mins to fix

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

                  def draw_line(c, x1, y1, x2, y2)
                  Severity: Minor
                  Found in examples/canvas/app/application.rb - About 35 mins 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
                      Severity
                      Category
                      Status
                      Source
                      Language