Noosfero/noosfero

View on GitHub
plugins/sniffer/public/javascripts/infobox.js

Summary

Maintainability
F
4 days
Test Coverage

File infobox.js has 381 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @name InfoBox
 * @version 1.1.9 [October 2, 2011]
 * @author Gary Little (inspired by proof-of-concept code from Pamela Fox of Google)
 * @copyright Copyright 2010 Gary Little [gary at luxcentral.com]
Severity: Minor
Found in plugins/sniffer/public/javascripts/infobox.js - About 5 hrs to fix

    Function panBox_ has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    InfoBox.prototype.panBox_ = function (disablePan) {
    
      var map;
      var bounds;
      var xOffset = 0, yOffset = 0;
    Severity: Minor
    Found in plugins/sniffer/public/javascripts/infobox.js - About 3 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 createInfoBoxDiv_ has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    InfoBox.prototype.createInfoBoxDiv_ = function () {
    
      var bw;
      var me = this;
    
    
    Severity: Minor
    Found in plugins/sniffer/public/javascripts/infobox.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 createInfoBoxDiv_ has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    InfoBox.prototype.createInfoBoxDiv_ = function () {
    
      var bw;
      var me = this;
    
    
    Severity: Major
    Found in plugins/sniffer/public/javascripts/infobox.js - About 2 hrs to fix

      Function setOptions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      InfoBox.prototype.setOptions = function (opt_opts) {
        if (typeof opt_opts.boxClass !== "undefined") { // Must be first
      
          this.boxClass_ = opt_opts.boxClass;
          this.setBoxStyle_();
      Severity: Minor
      Found in plugins/sniffer/public/javascripts/infobox.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

      Function setOptions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      InfoBox.prototype.setOptions = function (opt_opts) {
        if (typeof opt_opts.boxClass !== "undefined") { // Must be first
      
          this.boxClass_ = opt_opts.boxClass;
          this.setBoxStyle_();
      Severity: Minor
      Found in plugins/sniffer/public/javascripts/infobox.js - About 1 hr to fix

        Function panBox_ has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        InfoBox.prototype.panBox_ = function (disablePan) {
        
          var map;
          var bounds;
          var xOffset = 0, yOffset = 0;
        Severity: Minor
        Found in plugins/sniffer/public/javascripts/infobox.js - About 1 hr to fix

          Function setContent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          InfoBox.prototype.setContent = function (content) {
            this.content_ = content;
          
            if (this.div_) {
          
          
          Severity: Minor
          Found in plugins/sniffer/public/javascripts/infobox.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

          Function InfoBox has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function InfoBox(opt_opts) {
          
            opt_opts = opt_opts || {};
          
            google.maps.OverlayView.apply(this, arguments);
          Severity: Minor
          Found in plugins/sniffer/public/javascripts/infobox.js - About 1 hr to fix

            Function setBoxStyle_ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            InfoBox.prototype.setBoxStyle_ = function () {
            
              var i, boxStyle;
            
              if (this.div_) {
            Severity: Minor
            Found in plugins/sniffer/public/javascripts/infobox.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

            Function setContent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            InfoBox.prototype.setContent = function (content) {
              this.content_ = content;
            
              if (this.div_) {
            
            
            Severity: Minor
            Found in plugins/sniffer/public/javascripts/infobox.js - About 1 hr to fix

              Function getBoxWidths_ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              InfoBox.prototype.getBoxWidths_ = function () {
              
                var computedStyle;
                var bw = {top: 0, bottom: 0, left: 0, right: 0};
                var box = this.div_;
              Severity: Minor
              Found in plugins/sniffer/public/javascripts/infobox.js - About 55 mins 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

                    if (pixPosition.x < (-iwOffsetX + padX)) {
                      xOffset = pixPosition.x + iwOffsetX - padX;
                    } else if ((pixPosition.x + iwWidth + iwOffsetX + padX) > mapWidth) {
                      xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;
                    }
              Severity: Major
              Found in plugins/sniffer/public/javascripts/infobox.js and 1 other location - About 3 hrs to fix
              plugins/sniffer/public/javascripts/infobox.js on lines 349..353

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

              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 (pixPosition.y < (-iwOffsetY + padY)) {
                        yOffset = pixPosition.y + iwOffsetY - padY;
                      } else if ((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight) {
                        yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;
                      }
              Severity: Major
              Found in plugins/sniffer/public/javascripts/infobox.js and 1 other location - About 3 hrs to fix
              plugins/sniffer/public/javascripts/infobox.js on lines 337..341

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

              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

              InfoBox.prototype.show = function () {
              
                this.isHidden_ = false;
                if (this.div_) {
                  this.div_.style.visibility = "visible";
              Severity: Major
              Found in plugins/sniffer/public/javascripts/infobox.js and 1 other location - About 1 hr to fix
              plugins/sniffer/public/javascripts/infobox.js on lines 700..706

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

              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

              InfoBox.prototype.hide = function () {
              
                this.isHidden_ = true;
                if (this.div_) {
                  this.div_.style.visibility = "hidden";
              Severity: Major
              Found in plugins/sniffer/public/javascripts/infobox.js and 1 other location - About 1 hr to fix
              plugins/sniffer/public/javascripts/infobox.js on lines 689..695

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

              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

                if (this.moveListener_) {
              
                  google.maps.event.removeListener(this.moveListener_);
                  this.moveListener_ = null;
                }
              Severity: Minor
              Found in plugins/sniffer/public/javascripts/infobox.js and 2 other locations - About 30 mins to fix
              plugins/sniffer/public/javascripts/infobox.js on lines 741..745
              plugins/sniffer/public/javascripts/infobox.js on lines 765..769

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

                if (this.closeListener_) {
              
                  google.maps.event.removeListener(this.closeListener_);
                  this.closeListener_ = null;
                }
              Severity: Minor
              Found in plugins/sniffer/public/javascripts/infobox.js and 2 other locations - About 30 mins to fix
              plugins/sniffer/public/javascripts/infobox.js on lines 759..763
              plugins/sniffer/public/javascripts/infobox.js on lines 765..769

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

                if (this.contextListener_) {
              
                  google.maps.event.removeListener(this.contextListener_);
                  this.contextListener_ = null;
                }
              Severity: Minor
              Found in plugins/sniffer/public/javascripts/infobox.js and 2 other locations - About 30 mins to fix
              plugins/sniffer/public/javascripts/infobox.js on lines 741..745
              plugins/sniffer/public/javascripts/infobox.js on lines 759..763

              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