pencil-js/pencil.js

View on GitHub

Showing 34 of 64 total issues

Function setContext has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    setContext (ctx) {
        super.setContext(ctx);

        if (this.options.shadow.color) {
            const shadowPosition = Position.from(this.options.shadow.position);
Severity: Minor
Found in src/modules/component/component.js - About 1 hr to fix

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

        set (...colorDefinition) {
            const [first] = colorDefinition;
            let input;
            let alpha;
            if (first instanceof Color) {
    Severity: Minor
    Found in src/modules/color/color.js - About 1 hr to fix

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

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

            setContext (ctx) {
                super.setContext(ctx);
        
                if (this.options.shadow.color) {
                    const shadowPosition = Position.from(this.options.shadow.position);
        Severity: Minor
        Found in src/modules/component/component.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 a Cognitive Complexity of 10 (exceeds 5 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

        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 9 (exceeds 5 allowed). Consider refactoring.
        Open

            trace (path) {
                const basePath = new window.Path2D();
                this.base.trace(basePath);
                const matrix = new window.DOMMatrix();
                const { cos, sin } = Math;
        Severity: Minor
        Found in src/modules/particles/particles.js - 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

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

            getTarget (position, ctx) {
                if (!this.options.shown) {
                    return null;
                }
        
        
        Severity: Minor
        Found in src/modules/container/container.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 7 (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 src/modules/rectangle/rectangle.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 source has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            set source (newSource) {
                if (newSource instanceof window.HTMLImageElement ||
                    newSource instanceof window.HTMLCanvasElement ||
                    newSource instanceof OffScreenCanvas) {
                    this[sourceKey] = newSource;
        Severity: Minor
        Found in src/modules/pattern/pattern.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 = OffScreenCanvas.getDrawingContext()) {
                if (!this.options.shown) {
                    return false;
                }
        
        
        Severity: Minor
        Found in src/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

        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 src/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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            get (selector = "*") {
                const filter = ((matcher) => {
                    if (typeof matcher === "function") {
                        return matcher;
                    }
        Severity: Minor
        Found in src/modules/sprite/sprite.js - 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

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

            set (...colorDefinition) {
                const [first] = colorDefinition;
                let input;
                let alpha;
                if (first instanceof Color) {
        Severity: Minor
        Found in src/modules/color/color.js - 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

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

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

        Severity
        Category
        Status
        Source
        Language