src/widgets/widgets.annotation.js

Summary

Maintainability
F
6 days
Test Coverage

Function widgetsAnnotation has 312 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const widgetsAnnotation = (three = window.THREE) => {
  if (three === undefined || three.Object3D === undefined) {
    return null;
  }

Severity: Major
Found in src/widgets/widgets.annotation.js - About 1 day to fix

    Function widgetsAnnotation has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    const widgetsAnnotation = (three = window.THREE) => {
      if (three === undefined || three.Object3D === undefined) {
        return null;
      }
    
    
    Severity: Minor
    Found in src/widgets/widgets.annotation.js - About 5 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

    File widgets.annotation.js has 318 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { widgetsBase } from './widgets.base';
    import { widgetsHandle as widgetsHandleFactory } from './widgets.handle';
    
    /**
     * @module widgets/annotation
    Severity: Minor
    Found in src/widgets/widgets.annotation.js - About 3 hrs to fix

      Function updateDOM has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          updateDOM() {
            this.updateDOMColor();
      
            // update line
            const lineData = this.getLineData(
      Severity: Minor
      Found in src/widgets/widgets.annotation.js - About 1 hr to fix

        Function constructor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            constructor(targetMesh, controls, params = {}) {
              super(targetMesh, controls, params);
        
              this._widgetType = 'Annotation';
        
        
        Severity: Minor
        Found in src/widgets/widgets.annotation.js - About 1 hr to fix

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

              free() {
                this.removeEventListeners();
          
                this._handles.forEach(h => {
                  this.remove(h);
          Severity: Minor
          Found in src/widgets/widgets.annotation.js - About 1 hr to fix

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

                removeEventListeners() {
                  window.removeEventListener('resize', this.onResize);
            
                  this._label.removeEventListener('mouseenter', this.onHoverlabel);
                  this._label.removeEventListener('mouseleave', this.notonHoverlabel);
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 1 other location - About 3 hrs to fix
            src/widgets/widgets.annotation.js on lines 68..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 104.

            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

                addEventListeners() {
                  window.addEventListener('resize', this.onResize);
            
                  this._label.addEventListener('mouseenter', this.onHoverlabel);
                  this._label.addEventListener('mouseleave', this.notonHoverlabel);
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 1 other location - About 3 hrs to fix
            src/widgets/widgets.annotation.js on lines 78..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 104.

            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

                showDOM() {
                  this._line.style.display = '';
                  this._dashline.style.display = '';
                  this._label.style.display = '';
                  this._handles.forEach(elem => elem.showDOM());
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 2 other locations - About 2 hrs to fix
            src/widgets/widgets.angle.js on lines 240..246
            src/widgets/widgets.annotation.js on lines 351..356

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

            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

                hideDOM() {
                  this._line.style.display = 'none';
                  this._dashline.style.display = 'none';
                  this._label.style.display = 'none';
                  this._handles.forEach(elem => elem.hideDOM());
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 2 other locations - About 2 hrs to fix
            src/widgets/widgets.angle.js on lines 240..246
            src/widgets/widgets.annotation.js on lines 358..363

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

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

                update() {
                  this.updateColor();
            
                  this._handles[0].update();
                  this._handles[1].update();
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 2 other locations - About 2 hrs to fix
            src/widgets/widgets.ellipse.js on lines 244..254
            src/widgets/widgets.rectangle.js on lines 242..252

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

                set worldPosition(worldPosition) {
                  this._handles[0].worldPosition.copy(worldPosition);
                  this._handles[1].worldPosition.copy(worldPosition);
                  this._worldPosition.copy(worldPosition);
                  this.update();
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 4 other locations - About 2 hrs to fix
            src/widgets/widgets.ellipse.js on lines 468..473
            src/widgets/widgets.pressureHalfTime.js on lines 440..445
            src/widgets/widgets.rectangle.js on lines 431..436
            src/widgets/widgets.ruler.js on lines 353..358

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

            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

                  if (!this._dragged && this._active && this._initialized) {
                    this._selected = !this._selected; // change state if there was no dragging
                    this._handles[0].selected = this._selected;
                    this._handles[1].selected = this._selected;
                  }
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 1 other location - About 1 hr to fix
            src/widgets/widgets.biruler.js on lines 108..112

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

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

                  for (let i = 0; i < 2; i++) {
                    handle = new WidgetsHandle(targetMesh, controls, params);
                    this.add(handle);
                    this._handles.push(handle);
                  }
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 7 other locations - About 1 hr to fix
            src/widgets/widgets.angle.js on lines 43..47
            src/widgets/widgets.biruler.js on lines 44..48
            src/widgets/widgets.crossRuler.js on lines 50..54
            src/widgets/widgets.ellipse.js on lines 49..53
            src/widgets/widgets.pressureHalfTime.js on lines 58..62
            src/widgets/widgets.rectangle.js on lines 48..52
            src/widgets/widgets.ruler.js on lines 43..47

            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

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

                set targetMesh(targetMesh) {
                  this._targetMesh = targetMesh;
                  this._handles.forEach(elem => (elem.targetMesh = targetMesh));
                  this.update();
                }
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 7 other locations - About 1 hr to fix
            src/widgets/widgets.angle.js on lines 391..395
            src/widgets/widgets.biruler.js on lines 419..423
            src/widgets/widgets.crossRuler.js on lines 603..607
            src/widgets/widgets.ellipse.js on lines 458..462
            src/widgets/widgets.pressureHalfTime.js on lines 430..434
            src/widgets/widgets.rectangle.js on lines 421..425
            src/widgets/widgets.ruler.js on lines 343..347

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

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

                  this._dashline.style.transform = `translate3D(${minLine.transformX}px, ${
                    minLine.transformY
                  }px, 0)
                    rotate(${minLine.transformAngle}rad)`;
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 10 other locations - About 40 mins to fix
            src/widgets/widgets.angle.js on lines 302..305
            src/widgets/widgets.angle.js on lines 314..317
            src/widgets/widgets.annotation.js on lines 304..307
            src/widgets/widgets.biruler.js on lines 245..248
            src/widgets/widgets.biruler.js on lines 257..260
            src/widgets/widgets.biruler.js on lines 277..280
            src/widgets/widgets.crossRuler.js on lines 299..302
            src/widgets/widgets.crossRuler.js on lines 311..314
            src/widgets/widgets.pressureHalfTime.js on lines 346..349
            src/widgets/widgets.ruler.js on lines 262..265

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

                  this._line.style.transform = `translate3D(${lineData.transformX}px, ${
                    lineData.transformY
                  }px, 0)
                    rotate(${lineData.transformAngle}rad)`;
            Severity: Major
            Found in src/widgets/widgets.annotation.js and 10 other locations - About 40 mins to fix
            src/widgets/widgets.angle.js on lines 302..305
            src/widgets/widgets.angle.js on lines 314..317
            src/widgets/widgets.annotation.js on lines 338..341
            src/widgets/widgets.biruler.js on lines 245..248
            src/widgets/widgets.biruler.js on lines 257..260
            src/widgets/widgets.biruler.js on lines 277..280
            src/widgets/widgets.crossRuler.js on lines 299..302
            src/widgets/widgets.crossRuler.js on lines 311..314
            src/widgets/widgets.pressureHalfTime.js on lines 346..349
            src/widgets/widgets.ruler.js on lines 262..265

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

                    ${this._handles[1].screenPosition.x - this._labelOffset.x - this._label.offsetWidth / 2}px,
            Severity: Minor
            Found in src/widgets/widgets.annotation.js and 1 other location - About 30 mins to fix
            src/widgets/widgets.annotation.js on lines 208..210

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

            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

                    ${this._handles[1].screenPosition.y -
                      this._labelOffset.y -
                      this._label.offsetHeight / 2 -
            Severity: Minor
            Found in src/widgets/widgets.annotation.js and 1 other location - About 30 mins to fix
            src/widgets/widgets.annotation.js on lines 207..207

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

            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