opal/opal-browser

View on GitHub
opal/browser/canvas.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    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 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 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 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 arc has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def arc(x, y, radius, angle, clockwise = false)
          Severity: Minor
          Found in opal/browser/canvas.rb - About 35 mins to fix

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

              def draw_image(image, *args)
                if Canvas === image
                  image = image.element
                else
                  image = DOM(image)
            Severity: Minor
            Found in opal/browser/canvas.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