GMartigny/pencilJS

View on GitHub

Showing 108 of 108 total issues

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

test("moveTo", (t) => {
    const ctx = {
        moveTo: (...args) => t.deepEqual(args, [100, 200]),
    };
    const instruction = Path.moveTo([100, 200]);
Severity: Major
Found in src/modules/path/path.test.js and 1 other location - About 1 hr to fix
src/modules/path/path.test.js on lines 70..76

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

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 3 locations. Consider refactoring.
Open

test("caps", (t) => {
    t.is(Arc.caps.butt, "butt");
    t.is(Arc.caps.round, "round");
    t.is(Arc.caps.square, "square");
});
Severity: Major
Found in src/modules/arc/arc.test.js and 2 other locations - About 1 hr to fix
src/modules/component/component.test.js on lines 169..173
src/modules/line/line.test.js on lines 88..92

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

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 3 locations. Consider refactoring.
Open

test("joins", (t) => {
    t.is(Component.joins.miter, "miter");
    t.is(Component.joins.round, "round");
    t.is(Component.joins.bevel, "bevel");
});
Severity: Major
Found in src/modules/component/component.test.js and 2 other locations - About 1 hr to fix
src/modules/arc/arc.test.js on lines 62..66
src/modules/line/line.test.js on lines 88..92

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

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 3 locations. Consider refactoring.
Open

test("caps", (t) => {
    t.is(Line.caps.butt, "butt");
    t.is(Line.caps.round, "round");
    t.is(Line.caps.square, "square");
});
Severity: Major
Found in src/modules/line/line.test.js and 2 other locations - About 1 hr to fix
src/modules/arc/arc.test.js on lines 62..66
src/modules/component/component.test.js on lines 169..173

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

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

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 src/modules/slider/slider.test.js and 2 other locations - About 1 hr to fix
src/modules/progress-bar/progress-bar.test.js on lines 42..47
src/modules/progress-pie/progress-pie.test.js on lines 49..54

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

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

test("defaultOptions", (t) => {
    const options = ProgressPie.defaultOptions;
    t.is(options.value, 0);
    t.is(options.radius, 100);
    t.is(options.speed, 0.3);
Severity: Major
Found in src/modules/progress-pie/progress-pie.test.js and 2 other locations - About 1 hr to fix
src/modules/progress-bar/progress-bar.test.js on lines 42..47
src/modules/slider/slider.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

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

test("defaultOptions", (t) => {
    const options = ProgressBar.defaultOptions;
    t.is(options.value, 0);
    t.is(options.width, 200);
    t.is(options.speed, 0.3);
Severity: Major
Found in src/modules/progress-bar/progress-bar.test.js and 2 other locations - About 1 hr to fix
src/modules/progress-pie/progress-pie.test.js on lines 49..54
src/modules/slider/slider.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 src/modules/color/color.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 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

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

            toJSON () {
                const { radius } = this;
                const json = {
                    ...super.toJSON(),
                    radius,
        Severity: Major
        Found in src/modules/circle/circle.js and 1 other location - About 1 hr to fix
        src/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

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

        test("get and set radius", (t) => {
            t.is(t.context.radius, 100);
        
            t.context.radius = 200;
            t.is(t.context.radius, 200);
        Severity: Major
        Found in src/modules/knob/knob.test.js and 1 other location - About 1 hr to fix
        src/modules/progress-pie/progress-pie.test.js on lines 33..38

        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 { size } = this;
                const json = {
                    ...super.toJSON(),
                    size,
        Severity: Major
        Found in src/modules/square/square.js and 1 other location - About 1 hr to fix
        src/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

        test("get and set radius", (t) => {
            t.is(t.context.radius, 300);
        
            t.context.radius = 666;
            t.is(t.context.radius, 666);
        Severity: Major
        Found in src/modules/progress-pie/progress-pie.test.js and 1 other location - About 1 hr to fix
        src/modules/knob/knob.test.js on lines 16..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 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 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

          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 src/modules/offscreen-canvas/offscreen-canvas.test.js and 1 other location - About 1 hr to fix
          src/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

          test("get size", (t) => {
              const { size } = t.context;
              t.is(size.x, 100);
              t.is(size.y, 200);
          });
          Severity: Major
          Found in src/modules/offscreen-canvas/offscreen-canvas.test.js and 1 other location - About 1 hr to fix
          src/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

              const ctx = {
                  moveTo: (...params) => t.deepEqual(params, [200, 200]),
                  lineTo: () => t.pass(),
                  bezierCurveTo: () => t.pass(),
              };
          Severity: Major
          Found in src/modules/path/path.test.js and 1 other location - About 1 hr to fix
          src/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

          Severity
          Category
          Status
          Source
          Language