pencil-js/pencil.js

View on GitHub

Showing 34 of 64 total issues

Function listenForEvents has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Scene.prototype[listenForEventsKey] = function listenForEvents (container) {
    if (this.isReady) {
        throw new EvalError("Can't rebind event a second time.");
    }

Severity: Major
Found in src/modules/scene/scene.js - About 3 hrs to fix

    Function draggable has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Component.prototype.draggable = function draggable (options) {
        if (this.isRotatable) {
            throw new Error("Component can't be both rotatable and draggable.");
        }
    
    
    Severity: Major
    Found in src/modules/draggable/draggable.js - About 3 hrs to fix

      Function draggable has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      Component.prototype.draggable = function draggable (options) {
          if (this.isRotatable) {
              throw new Error("Component can't be both rotatable and draggable.");
          }
      
      
      Severity: Minor
      Found in src/modules/draggable/draggable.js - About 3 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

      Color has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class Color {
          /**
           * @typedef {Color|String|Number|Array<Number>} ColorDefinition
           */
          /**
      Severity: Minor
      Found in src/modules/color/color.js - About 2 hrs to fix

        Container has 25 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default class Container extends EventEmitter {
            /**
             * Container constructor
             * @param {PositionDefinition} [positionDefinition] - Position in its container
             * @param {ContainerOptions} [options] - Specific options
        Severity: Minor
        Found in src/modules/container/container.js - About 2 hrs to fix

          Function listenForEvents has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          Scene.prototype[listenForEventsKey] = function listenForEvents (container) {
              if (this.isReady) {
                  throw new EvalError("Can't rebind event a second time.");
              }
          
          
          Severity: Minor
          Found in src/modules/scene/scene.js - 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

          Function rotatable has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Component.prototype.rotatable = function rotatable () {
              if (this.isDraggable) {
                  throw new Error("Component can't be both draggable and rotatable.");
              }
          
          
          Severity: Major
          Found in src/modules/rotatable/rotatable.js - About 2 hrs to fix

            Position has 23 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export default class Position {
                /**
                 * Position constructor
                 * @param {Number} x - Vertical component
                 * @param {Number} y - Horizontal component
            Severity: Minor
            Found in src/modules/position/position.js - About 2 hrs to fix

              Function constructor has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  constructor (positionDefinition, optionsList, options) {
                      if (!optionsList.length) {
                          throw new RangeError("Options list should have at least one item.");
                      }
                      super(positionDefinition, Rectangle, options);
              Severity: Major
              Found in src/modules/select/select.js - About 2 hrs to fix

                File container.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import EventEmitter from "@pencil.js/event-emitter";
                import BaseEvent from "@pencil.js/base-event";
                import Position from "@pencil.js/position";
                import { radianCircle } from "@pencil.js/math";
                
                
                Severity: Minor
                Found in src/modules/container/container.js - About 2 hrs to fix

                  Function rotatable has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Component.prototype.rotatable = function rotatable () {
                      if (this.isDraggable) {
                          throw new Error("Component can't be both draggable and rotatable.");
                      }
                  
                  
                  Severity: Minor
                  Found in src/modules/rotatable/rotatable.js - 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

                  Function resizable has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Rectangle.prototype.resizable = function resizable (options) {
                      if (this.options.rotation % 1 !== 0) {
                          throw new EvalError("Resizable don't support rotation.");
                      }
                  
                  
                  Severity: Minor
                  Found in src/modules/resizable/resizable.js - About 1 hr to fix

                    Function cursors has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        static get cursors () {
                            const cursors = {
                                default: "default",
                                none: "none",
                                contextMenu: "context-menu",
                    Severity: Minor
                    Found in src/modules/component/component.js - About 1 hr to fix

                      Function measureText has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const measureText = (() => {
                          let sandbox;
                          const cache = {};
                          const select = ({
                              lineHeight,
                      Severity: Minor
                      Found in src/modules/text/text.js - About 1 hr to fix

                        Function makePath has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            makePath (ctx) {
                                const { options } = this;
                                if (this.text.length && (this.willFill || this.willStroke)) {
                                    const origin = this.getOrigin();
                                    ctx.translate(origin.x, origin.y);
                        Severity: Minor
                        Found in src/modules/text/text.js - About 1 hr to fix

                          Function makePath has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              makePath (ctx) {
                                  const { options } = this;
                                  if (this.text.length && (this.willFill || this.willStroke)) {
                                      const origin = this.getOrigin();
                                      ctx.translate(origin.x, origin.y);
                          Severity: Minor
                          Found in src/modules/text/text.js - 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

                          Function url has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              set url (source) {
                                  if (this.url === source) {
                                      return;
                                  }
                          
                          
                          Severity: Minor
                          Found in src/modules/image/image.js - About 1 hr to fix

                            Function makePath has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                makePath (ctx) {
                                    const { sourceSize } = this.frames[Math.floor(this.frame)];
                                    this.width = sourceSize.w;
                                    this.height = sourceSize.h;
                            
                            
                            Severity: Minor
                            Found in src/modules/sprite/sprite.js - 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

                            Function getAlignOffset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                getAlignOffset () {
                                    const { align } = this.options;
                            
                                    let offset = 0;
                            
                            
                            Severity: Minor
                            Found in src/modules/text/text.js - 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

                            Function setContext has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                setContext (ctx) {
                                    if (this.options.clip) {
                                        const clipping = new window.Path2D();
                                        const { clip } = this.options;
                                        const { x, y } = clip.position;
                            Severity: Minor
                            Found in src/modules/container/container.js - 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