CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/builder/dataset/dataset-header/dataset-header-view.js

Summary

Maintainability
D
2 days
Test Coverage

File dataset-header-view.js has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var CoreView = require('backbone/core-view');
var template = require('./dataset-header.tpl');
var moment = require('moment');
var InlineEditorView = require('builder/components/inline-editor/inline-editor-view');
var TipsyTooltipView = require('builder/components/tipsy-tooltip-view');

    exports has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    module.exports = CoreView.extend({
    
      className: 'Editor-HeaderInfoEditor',
    
      events: {

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

        _initViews: function () {
          var isDatasetOwner = this._isDatasetOwner();
      
          var toggleMenuTooltip = new TipsyTooltipView({
            el: this.$('.js-toggle'),

        Function _duplicateDataset has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _duplicateDataset: function () {
            var self = this;
            var tableName = this._tableModel.getUnquotedName();
            var name = this._isCustomQueryApplied() ? _t('dataset.duplicate.query') : tableName;
        
        

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

            _showContextMenu: function (ev) {
              var isSync = this._tableModel.isSync();
              var triggerElementID = 'context-menu-trigger-' + this._tableModel.cid;
              this.$('.js-options').attr('id', triggerElementID);
          
          

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

              _initViews: function () {
                var isDatasetOwner = this._isDatasetOwner();
            
                var toggleMenuTooltip = new TipsyTooltipView({
                  el: this.$('.js-toggle'),

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

              _initBinds: function () {
                this.listenTo(this._syncModel, 'change:state change:interval destroy', this.render);
                this.listenTo(this._visModel, 'change:name', this._onChangeName);
                this.listenTo(this._visModel, 'change:privacy change:name', this.render);
                this.listenTo(this._querySchemaModel, 'change:query', this.render);
            lib/assets/javascripts/builder/components/input-color/input-qualitative-ramps/categories-list/list-view/input-categories-list-view.js on lines 88..93
            lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analyses-content-view.js on lines 123..128
            lib/assets/javascripts/deep-insights/widgets/category/paginator/paginator-view.js on lines 52..59

            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

                var toggleMenuTooltip = new TipsyTooltipView({
                  el: this.$('.js-toggle'),
                  gravity: 'w',
                  title: function () {
                    return this._isHidden() ? _t('editor.layers.options.show') : _t('editor.layers.options.hide');
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 223..229

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

            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._inlineEditor = new InlineEditorView({
                      template: templateInlineEditor,
                      renderOptions: {
                        name: this._tableModel.getUnqualifiedName()
                      },
            lib/assets/javascripts/builder/editor/layers/layer-header-view.js on lines 116..122

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

            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 shareWith = new ShareWith({
                      visDefinitionModel: this._visModel,
                      userModel: this._userModel,
                      separationClass: 'u-rSpace--m',
                      clickPrivacyAction: this._clickPrivacy.bind(this)
            lib/assets/javascripts/builder/editor/editor-header.js on lines 81..86

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 52.

            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

              _isSample: function () {
                var sample = this._visModel.get('sample');
                return sample && !!sample.entity_id || false;
              },
            lib/assets/javascripts/builder/dataset/dataset-header/dataset-header-view.js on lines 388..391

            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

              _isSubscription: function () {
                var subscription = this._visModel.get('subscription');
                return subscription && !!subscription.entity_id || false;
              }
            lib/assets/javascripts/builder/dataset/dataset-header/dataset-header-view.js on lines 383..386

            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

            There are no issues that match your filters.

            Category
            Status