ivmartel/dwv

View on GitHub
src/tools/roi.js

Summary

Maintainability
D
1 day
Test Coverage

Function create has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  create(points, style, viewController) {
    // physical shape
    const roi = new ROI();
    // add input points to the ROI
    roi.addPoints(points);
Severity: Major
Found in src/tools/roi.js - About 2 hrs to fix

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

      update(anchor, style, _viewController) {
        // parent group
        const group = anchor.getParent();
        // associated shape
        const kroi = group.getChildren(function (node) {
    Severity: Minor
    Found in src/tools/roi.js - About 1 hr to fix

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

        getAnchors(shape, style) {
          const points = shape.points();
      
          const anchors = [];
          for (let i = 0; i < points.length; i = i + 2) {
      Severity: Major
      Found in src/tools/roi.js and 1 other location - About 5 hrs to fix
      src/tools/freeHand.js on lines 132..145

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

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

            if (typeof defaults.labelText.roi[modality] !== 'undefined') {
              textExpr = defaults.labelText.roi[modality];
            } else {
              textExpr = defaults.labelText.roi['*'];
            }
      Severity: Major
      Found in src/tools/roi.js and 4 other locations - About 1 hr to fix
      src/tools/arrow.js on lines 122..126
      src/tools/freeHand.js on lines 89..93
      src/tools/protractor.js on lines 116..120
      src/tools/ruler.js on lines 130..134

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

      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 textPos = {
            x: points[0] + kroi.x(),
            y: points[1] + kroi.y() + style.scale(10)
          };
      Severity: Major
      Found in src/tools/roi.js and 1 other location - About 1 hr to fix
      src/tools/freeHand.js on lines 193..196

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

      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

          const ktext = new Konva.Text({
            fontSize: style.getFontSize(),
            fontFamily: style.getFontFamily(),
            fill: style.getLineColour(),
            name: 'text'
      Severity: Major
      Found in src/tools/roi.js and 1 other location - About 1 hr to fix
      src/tools/freeHand.js on lines 81..86

      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

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

          const point = group.getChildren(function (node) {
            return node.id() === anchor.id();
          })[0];
      Severity: Minor
      Found in src/tools/roi.js and 1 other location - About 40 mins to fix
      src/tools/freeHand.js on lines 173..175

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

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

          klabel.add(new Konva.Tag({
            fill: style.getLineColour(),
            opacity: style.getTagOpacity()
          }));
      Severity: Major
      Found in src/tools/roi.js and 4 other locations - About 35 mins to fix
      src/tools/arrow.js on lines 145..148
      src/tools/freeHand.js on lines 111..114
      src/tools/protractor.js on lines 148..151
      src/tools/ruler.js on lines 155..158

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

      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

      There are no issues that match your filters.

      Category
      Status