CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/cartodb/old_common/header.js

Summary

Maintainability
F
3 days
Test Coverage

File header.js has 404 lines of code (exceeds 250 allowed). Consider refactoring.
Open


/**
 *  Common header for vis view ( table | derived )
 *
 *  - It needs a visualization model, config and user data.
Severity: Minor
Found in lib/assets/javascripts/cartodb/old_common/header.js - About 5 hrs to fix

    Function _changeTitle has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      _changeTitle: function(e) {
        this.killEvent(e);
    
        var self = this;
        var isOwner = this.model.permission.isOwner(this.options.user);
    Severity: Minor
    Found in lib/assets/javascripts/cartodb/old_common/header.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 _changeTitle has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _changeTitle: function(e) {
        this.killEvent(e);
    
        var self = this;
        var isOwner = this.model.permission.isOwner(this.options.user);
    Severity: Major
    Found in lib/assets/javascripts/cartodb/old_common/header.js - About 2 hrs to fix

      Header has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      cdb.admin.Header = cdb.core.View.extend({
      
        _TEXTS: {
          saving:         _t('Saving...'),
          saved:          _t('Saved'),
      Severity: Minor
      Found in lib/assets/javascripts/cartodb/old_common/header.js - About 2 hrs to fix

        Function _setPrivacy has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _setPrivacy: function() {
        
            var $share  = this.$('a.privacy');
        
            // Update shared count if it is neccessary
        Severity: Minor
        Found in lib/assets/javascripts/cartodb/old_common/header.js - About 1 hr to fix

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

            _setSharedCount: function() {
              var isOwner = this.model.permission.isOwner(this.options.user);
              var $share  = this.$('a.privacy i');
          
              $share.empty();
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/old_common/header.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 _generateTableUrl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            _generateTableUrl: function(e) {
              // Let's create the url ourselves //
              var url = '';
          
              // Check visualization type and get table or viz id
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/old_common/header.js - About 45 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

          Function isVisEditable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            isVisEditable: function() {
              if (this.model.isVisualization()) {
                return true;
              } else {
                var table = this.dataLayer && this.dataLayer.table;
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/old_common/header.js - About 35 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

          Function _setPrivacy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _setPrivacy: function() {
          
              var $share  = this.$('a.privacy');
          
              // Update shared count if it is neccessary
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/old_common/header.js - About 25 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

            _initBinds: function() {
              this.model.bind('change:name',        this._setName,            this);
              this.model.bind('change:type',        this.setInfo,             this);
              this.model.bind('change:privacy',     this._setPrivacy,      this);
              this.model.bind('change:permission',  this._setSharedCount,  this);
          Severity: Major
          Found in lib/assets/javascripts/cartodb/old_common/header.js and 1 other location - About 2 hrs to fix
          lib/assets/javascripts/builder/components/modals/add-layer/content/imports/import-database/import-database-view.js on lines 63..69

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

          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 (is_visualization) {
                $share.find("span").text(this._TEXTS.share.publish);
                this._setPrivacy();
                var route = cdb.config.prefixUrl() + "/dashboard/maps";
                $back.attr("href", route );
          Severity: Major
          Found in lib/assets/javascripts/cartodb/old_common/header.js and 1 other location - About 2 hrs to fix
          lib/assets/javascripts/cartodb/old_common/header.js on lines 349..354

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

          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

              } else {
                $share.find("span").text(this._TEXTS.share.visualize);
                this._setPrivacy();
                var route = cdb.config.prefixUrl() + "/dashboard/datasets";
                $back.attr("href", route );
          Severity: Major
          Found in lib/assets/javascripts/cartodb/old_common/header.js and 1 other location - About 2 hrs to fix
          lib/assets/javascripts/cartodb/old_common/header.js on lines 344..349

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

          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

                var dialog = new cdb.editor.ChangePrivacyView({
                  vis: this.model, //vis
                  user: this.options.user,
                  enter_to_confirm: true,
                  clean_on_hide: true
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/old_common/header.js and 1 other location - About 55 mins to fix
          lib/assets/javascripts/cartodb/table/header/options_menu.js on lines 182..187

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

          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

              } else if (privacy == "password"){
          
                $share
                .removeClass("private")
                .removeClass("link_protected")
          Severity: Major
          Found in lib/assets/javascripts/cartodb/old_common/header.js and 4 other locations - About 35 mins to fix
          lib/assets/javascripts/cartodb/old_common/header.js on lines 199..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 208..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 217..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 235..244

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

          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 (privacy == "public") {
          
                $share
                .removeClass("private")
                .removeClass("link_protected")
          Severity: Major
          Found in lib/assets/javascripts/cartodb/old_common/header.js and 4 other locations - About 35 mins to fix
          lib/assets/javascripts/cartodb/old_common/header.js on lines 208..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 217..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 226..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 235..244

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

          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

              } else if (privacy == "private"){
          
                $share
                .removeClass("public")
                .removeClass("link_protected")
          Severity: Major
          Found in lib/assets/javascripts/cartodb/old_common/header.js and 4 other locations - About 35 mins to fix
          lib/assets/javascripts/cartodb/old_common/header.js on lines 199..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 208..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 226..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 235..244

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

          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

              } else if (privacy == "organization"){
          
                $share
                .removeClass("private")
                .removeClass("link_protected")
          Severity: Major
          Found in lib/assets/javascripts/cartodb/old_common/header.js and 4 other locations - About 35 mins to fix
          lib/assets/javascripts/cartodb/old_common/header.js on lines 199..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 208..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 217..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 226..244

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

          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

              } else if (privacy == "link"){
          
                $share
                .removeClass("public")
                .removeClass("private")
          Severity: Major
          Found in lib/assets/javascripts/cartodb/old_common/header.js and 4 other locations - About 35 mins to fix
          lib/assets/javascripts/cartodb/old_common/header.js on lines 199..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 217..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 226..244
          lib/assets/javascripts/cartodb/old_common/header.js on lines 235..244

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

          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