GMartigny/pencilJS

View on GitHub

Showing 96 of 96 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

test("defaultOptions", (t) => {
    const options = Slider.defaultOptions;
    t.is(options.min, 0);
    t.is(options.max, 1);
    t.is(options.width, 200);
Severity: Major
Found in modules/slider/slider.test.js and 2 other locations - About 1 hr to fix
modules/progress-bar/progress-bar.test.js on lines 40..45
modules/progress-pie/progress-pie.test.js on lines 48..53

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 73.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 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 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 modules/component/component.js - About 1 hr to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            toJSON () {
                const { size } = this;
                const json = {
                    ...super.toJSON(),
                    size,
        Severity: Major
        Found in modules/square/square.js and 1 other location - About 1 hr to fix
        modules/circle/circle.js on lines 49..58

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 69.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            toJSON () {
                const { radius } = this;
                const json = {
                    ...super.toJSON(),
                    radius,
        Severity: Major
        Found in modules/circle/circle.js and 1 other location - About 1 hr to fix
        modules/square/square.js on lines 74..83

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 69.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function rotatable has 37 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: Minor
        Found in modules/rotatable/rotatable.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 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 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            test("get size", (t) => {
                const { size } = t.context;
                t.is(size.x, 100);
                t.is(size.y, 200);
            });
            Severity: Major
            Found in modules/offscreen-canvas/offscreen-canvas.test.js and 1 other location - About 1 hr to fix
            modules/offscreen-canvas/offscreen-canvas.test.js on lines 53..57

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 63.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            test("get center", (t) => {
                const { center } = t.context;
                t.is(center.x, 50);
                t.is(center.y, 100);
            });
            Severity: Major
            Found in modules/offscreen-canvas/offscreen-canvas.test.js and 1 other location - About 1 hr to fix
            modules/offscreen-canvas/offscreen-canvas.test.js on lines 47..51

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 63.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                const ctx = {
                    moveTo: (...params) => t.deepEqual(params, [200, 200]),
                    lineTo: () => t.pass(),
                    bezierCurveTo: () => t.pass(),
                };
            Severity: Major
            Found in modules/path/path.test.js and 1 other location - About 1 hr to fix
            modules/path/path.test.js on lines 30..34

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                const ctx = {
                    moveTo: (...params) => t.deepEqual(params, [0, 0]),
                    lineTo: () => t.pass(),
                    bezierCurveTo: () => t.pass(),
                };
            Severity: Major
            Found in modules/path/path.test.js and 1 other location - About 1 hr to fix
            modules/path/path.test.js on lines 20..24

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            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 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 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 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 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 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                slider.on(P.Input.events.change, () => {
                    progress.value = slider.value;
                    knob.value = slider.value;
                });
            Severity: Major
            Found in drawingTests/allInputs/script.js and 1 other location - About 1 hr to fix
            drawingTests/allInputs/script.js on lines 22..25

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                dotProduct (positionDefinition) {
                    const position = Position.from(positionDefinition);
                    return (this.x * position.x) + (this.y * position.y);
                }
            Severity: Major
            Found in modules/position/position.js and 1 other location - About 1 hr to fix
            modules/position/position.js on lines 209..212

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                knob.on(P.Input.events.change, () => {
                    progress.value = knob.value;
                    slider.value = knob.value;
                });
            Severity: Major
            Found in drawingTests/allInputs/script.js and 1 other location - About 1 hr to fix
            drawingTests/allInputs/script.js on lines 18..21

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                crossProduct (positionDefinition) {
                    const position = Position.from(positionDefinition);
                    return (this.x * position.y) - (this.y * position.x);
                }
            Severity: Major
            Found in modules/position/position.js and 1 other location - About 1 hr to fix
            modules/position/position.js on lines 199..202

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language