GMartigny/pencilJS

View on GitHub

Showing 101 of 101 total issues

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

test("get and set width", (t) => {
    t.is(t.context.width, 300);

    t.context.width = 666;
    t.is(t.context.width, 666);
Severity: Major
Found in modules/slider/slider.test.js and 1 other location - About 3 hrs to fix
modules/progress-bar/progress-bar.test.js on lines 21..28

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

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

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 modules/container/container.js - About 2 hrs to fix

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

    test("hex string constructor", (t) => {
        const fromHex = new Color("#3300FF");
        t.is(fromHex.red, 0.2);
        t.is(fromHex.green, 0);
        t.is(fromHex.blue, 1);
    Severity: Major
    Found in modules/color/color.test.js and 1 other location - About 2 hrs to fix
    modules/color/color.test.js on lines 51..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 89.

    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("hex short string constructor", (t) => {
        const fromHex = new Color("#30f");
        t.is(fromHex.red, 0.2);
        t.is(fromHex.green, 0);
        t.is(fromHex.blue, 1);
    Severity: Major
    Found in modules/color/color.test.js and 1 other location - About 2 hrs to fix
    modules/color/color.test.js on lines 43..49

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

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

        makePath (ctx) {
            const { options } = this;
            if (this.text.length && (options.fill || (options.stroke && options.strokeWidth > 0))) {
                ctx.save();
    
    
    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 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 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

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

    test("get and set value", (t) => {
        t.context.value = 0.5;
        t.is(t.context.value, 0.5);
    
        t.context.value = 2;
    Severity: Major
    Found in modules/progress-bar/progress-bar.test.js and 1 other location - About 2 hrs to fix
    modules/progress-pie/progress-pie.test.js on lines 40..46

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

    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

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

    test("get and set value", (t) => {
        t.context.value = 0.5;
        t.is(t.context.value, 0.5);
    
        t.context.value = 2;
    Severity: Major
    Found in modules/progress-pie/progress-pie.test.js and 1 other location - About 2 hrs to fix
    modules/progress-bar/progress-bar.test.js on lines 30..36

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

    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("from", (t) => {
        const definition = {
            nbBranches: 7,
            bevelRatio: 0.3,
        };
    Severity: Major
    Found in modules/star/star.test.js and 1 other location - About 2 hrs to fix
    modules/regular-polygon/regular-polygon.test.js on lines 36..45

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

    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 = {
            save: () => t.pass(),
            translate: () => t.pass(),
            fill: () => t.pass(),
            stroke: () => t.pass(),
    Severity: Major
    Found in modules/component/component.test.js and 1 other location - About 2 hrs to fix
    modules/component/component.test.js on lines 50..56

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

    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 = {
            save: () => t.pass(),
            translate: () => t.pass(),
            fill: () => t.fail(),
            stroke: () => t.fail(),
    Severity: Major
    Found in modules/component/component.test.js and 1 other location - About 2 hrs to fix
    modules/component/component.test.js on lines 35..41

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

    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("from", (t) => {
        const definition = {
            nbSides: 7,
            radius: 20,
        };
    Severity: Major
    Found in modules/regular-polygon/regular-polygon.test.js and 1 other location - About 2 hrs to fix
    modules/star/star.test.js on lines 26..35

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

    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 draggable has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Position has 22 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 modules/position/position.js - About 2 hrs to fix

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

        test("from", (t) => {
            const definition = {
                width: 42,
                height: 666,
            };
        Severity: Major
        Found in modules/rectangle/rectangle.test.js and 1 other location - About 2 hrs to fix
        modules/ellipse/ellipse.test.js on lines 25..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 79.

        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("from", (t) => {
            const definition = {
                width: 10,
                height: 20,
            };
        Severity: Major
        Found in modules/ellipse/ellipse.test.js and 1 other location - About 2 hrs to fix
        modules/rectangle/rectangle.test.js on lines 51..60

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

        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

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

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

          Function constructor has 51 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: Major
          Found in modules/select/select.js - About 2 hrs to fix

            File container.js has 251 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 modules/container/container.js - About 2 hrs to fix

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

              Severity
              Category
              Status
              Source
              Language