NLeSC/ahn-pointcloud-viewer

View on GitHub
app/scripts/utils/MeasuringTool.js

Summary

Maintainability
F
1 wk
Test Coverage

Function MeasuringTool has a Cognitive Complexity of 112 (exceeds 5 allowed). Consider refactoring.
Open

Potree.MeasuringTool = function(scene, camera, renderer){

    var scope = this;
    this.enabled = false;

Severity: Minor
Found in app/scripts/utils/MeasuringTool.js - About 2 days 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 MeasuringTool has 313 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Potree.MeasuringTool = function(scene, camera, renderer){

    var scope = this;
    this.enabled = false;

Severity: Major
Found in app/scripts/utils/MeasuringTool.js - About 1 day to fix

    File MeasuringTool.js has 558 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
    'use strict';
    /* global THREE:false, Potree:false  */
    
    Potree.Measure = function(){
    Severity: Major
    Found in app/scripts/utils/MeasuringTool.js - About 1 day to fix

      Function Measure has 211 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Potree.Measure = function(){
          var scope = this;
      
          THREE.Object3D.call( this );
      
      
      Severity: Major
      Found in app/scripts/utils/MeasuringTool.js - About 1 day to fix

        Function Measure has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

        Potree.Measure = function(){
            var scope = this;
        
            THREE.Object3D.call( this );
        
        
        Severity: Minor
        Found in app/scripts/utils/MeasuringTool.js - About 4 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 update has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            this.update = function(){
            var i, point, msg;
        
                if (this.points.length === 0){
                    return;
        Severity: Major
        Found in app/scripts/utils/MeasuringTool.js - About 2 hrs to fix

          Function addMarker has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              this.addMarker = function(point){
                  this.points.push(point);
          
                  // sphere
                  var sphere = new THREE.Mesh(sphereGeometry, createSphereMaterial());
          Severity: Minor
          Found in app/scripts/utils/MeasuringTool.js - About 1 hr to fix

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

                this.update = function(){
                var measurements = [], pr, distance, scale, i, j, label;
            
                    for(i = 0; i < this.measurements.length; i++){
                        measurements.push(this.measurements[i]);
            Severity: Minor
            Found in app/scripts/utils/MeasuringTool.js - About 1 hr to fix

              Function onMouseMove has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function onMouseMove(event){
                  var I;
                      var rect = scope.domElement.getBoundingClientRect();
                      scope.mouse.x = ((event.clientX - rect.left) / scope.domElement.clientWidth) * 2 - 1;
                      scope.mouse.y = -((event.clientY - rect.top) / scope.domElement.clientHeight) * 2 + 1;
              Severity: Minor
              Found in app/scripts/utils/MeasuringTool.js - About 1 hr to fix

                Function projectedRadius has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  function projectedRadius(radius, camera, distance, screenWidth, screenHeight){
                Severity: Minor
                Found in app/scripts/utils/MeasuringTool.js - About 35 mins to fix

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

                              for(j = 0; j < measurement.edgeLabels.length; j++){
                                  label = measurement.angleLabels[j];
                  
                                  distance = scope.camera.position.distanceTo(label.getWorldPosition());
                                  pr = projectedRadius(1, scope.camera.fov * Math.PI / 180, distance, renderer.domElement.clientHeight);
                  Severity: Major
                  Found in app/scripts/utils/MeasuringTool.js and 1 other location - About 5 hrs to fix
                  app/scripts/utils/MeasuringTool.js on lines 695..703

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

                  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

                              for(j = 0; j < measurement.edgeLabels.length; j++){
                                  label = measurement.edgeLabels[j];
                  
                                  distance = scope.camera.position.distanceTo(label.getWorldPosition());
                                  pr = projectedRadius(1, scope.camera.fov * Math.PI / 180, distance, renderer.domElement.clientHeight);
                  Severity: Major
                  Found in app/scripts/utils/MeasuringTool.js and 1 other location - About 5 hrs to fix
                  app/scripts/utils/MeasuringTool.js on lines 706..714

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

                  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

                  Object.defineProperty(Potree.Measure.prototype, 'showDistances', {
                      get: function(){
                          return this._showDistances;
                      },
                      set: function(value){
                  Severity: Major
                  Found in app/scripts/utils/MeasuringTool.js and 2 other locations - About 1 hr to fix
                  app/scripts/utils/MeasuringTool.js on lines 296..304
                  app/scripts/utils/MeasuringTool.js on lines 306..314

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

                  Object.defineProperty(Potree.Measure.prototype, 'showArea', {
                      get: function(){
                          return this._showArea;
                      },
                      set: function(value){
                  Severity: Major
                  Found in app/scripts/utils/MeasuringTool.js and 2 other locations - About 1 hr to fix
                  app/scripts/utils/MeasuringTool.js on lines 306..314
                  app/scripts/utils/MeasuringTool.js on lines 316..324

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

                  Object.defineProperty(Potree.Measure.prototype, 'closed', {
                      get: function(){
                          return this._closed;
                      },
                      set: function(value){
                  Severity: Major
                  Found in app/scripts/utils/MeasuringTool.js and 2 other locations - About 1 hr to fix
                  app/scripts/utils/MeasuringTool.js on lines 296..304
                  app/scripts/utils/MeasuringTool.js on lines 316..324

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

                                  edgeLabel.visible = this.showDistances && (index < lastIndex || this.closed) && this.points.length >= 2 && distance > 0;
                  Severity: Major
                  Found in app/scripts/utils/MeasuringTool.js and 1 other location - About 1 hr to fix
                  app/scripts/utils/MeasuringTool.js on lines 263..263

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

                  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

                                  angleLabel.visible = this.showAngles && (index < lastIndex || this.closed) && this.points.length >= 3 && angle > 0;
                  Severity: Major
                  Found in app/scripts/utils/MeasuringTool.js and 1 other location - About 1 hr to fix
                  app/scripts/utils/MeasuringTool.js on lines 243..243

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

                  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