GMartigny/pencilJS

View on GitHub

Showing 21 of 93 total issues

Function set has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    set (...colorDefinition) {
        if (colorDefinition.length > 0 && colorDefinition.length < 3) {
            const param = colorDefinition[0];
            if (param instanceof Color) {
                this.red = param.red;
Severity: Minor
Found in modules/color/color.js - 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

Function listenForEvents has 81 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 modules/scene/scene.js - About 3 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] -
    Severity: Minor
    Found in modules/container/container.js - About 2 hrs to fix

      Function listenForEvents has a Cognitive Complexity of 18 (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 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

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

      import test from "ava";
      import Container from "./container";
      
      test.beforeEach((t) => {
          t.context = new Container([10, 20]);
      Severity: Minor
      Found in modules/container/container.test.js - About 2 hrs to fix

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

            makePath (ctx) {
                const opts = this.options;
                if (this.text.length && (opts.fill || (opts.stroke && opts.strokeWidth > 0))) {
                    ctx.save();
                    const origin = this.getOrigin();
        Severity: Minor
        Found in modules/text/text.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 draggable has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Component.prototype.draggable = function draggable (options) {
            const cursorNotSet = this.options.cursor === Component.cursors.default;
            if (cursorNotSet) {
                this.options.cursor = Component.cursors.grab;
            }
        Severity: Minor
        Found in modules/draggable/draggable.js - About 2 hrs to fix

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

              makePath (ctx) {
                  const opts = this.options;
                  if (this.text.length && (opts.fill || (opts.stroke && opts.strokeWidth > 0))) {
                      ctx.save();
                      const origin = this.getOrigin();
          Severity: Minor
          Found in modules/text/text.js - About 1 hr to fix

            Function set has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                set (...colorDefinition) {
                    if (colorDefinition.length > 0 && colorDefinition.length < 3) {
                        const param = colorDefinition[0];
                        if (param instanceof Color) {
                            this.red = param.red;
            Severity: Minor
            Found in modules/color/color.js - About 1 hr to fix

              Function constructor has 46 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, options);
              Severity: Minor
              Found in modules/select/select.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 modules/component/component.js - About 1 hr to fix

                  Function resizable has 44 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 modules/resizable/resizable.js - About 1 hr to fix

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

                        render (ctx) {
                            if (!this.options.shown) {
                                return this;
                            }
                    
                    
                    Severity: Minor
                    Found in modules/container/container.js - About 1 hr to fix

                      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 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 render has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                          render (ctx) {
                              if (!this.options.shown) {
                                  return this;
                              }
                      
                      
                      Severity: Minor
                      Found in 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

                      Function getTarget has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          getTarget (position, ctx) {
                              if (!this.options.shown) {
                                  return null;
                              }
                      
                      
                      Severity: Minor
                      Found in 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

                      Function from has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          static from (vectorDefinition = new Vector()) {
                              if (vectorDefinition instanceof Vector) {
                                  return vectorDefinition;
                              }
                              if (Array.isArray(vectorDefinition) && vectorDefinition.length === 2) {
                      Severity: Minor
                      Found in modules/vector/vector.js - 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

                      Function getOrigin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          getOrigin () {
                              const { origin } = this.options;
                              if (typeof origin === "string") {
                                  const { origins } = Rectangle;
                                  const position = new Position();
                      Severity: Minor
                      Found in modules/rectangle/rectangle.js - 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

                      Function trace has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          trace (path) {
                              let lastPosition = new Position();
                              const instructions = this.instructions.slice();
                      
                              if (Array.isArray(instructions)) {
                      Severity: Minor
                      Found in modules/path/path.js - About 35 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

                      Function isHover has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          isHover (positionDefinition, ctx = (new OffScreenCanvas()).ctx) {
                              if (!this.options.shown) {
                                  return false;
                              }
                      
                      
                      Severity: Minor
                      Found in modules/component/component.js - About 35 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

                      Severity
                      Category
                      Status
                      Source
                      Language