CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/group-points-form-model.js

Summary

Maintainability
F
3 days
Test Coverage

Function _setSchema has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _setSchema: function () {
    BaseAnalysisFormModel.prototype._setSchema.call(this, this._filterSchemaFieldsByType({
      source: this._primarySourceSchemaItem(),
      type: {
        type: 'Select',

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

      _getColumnOptions: function (attr, attrType) {
        var opts = this._columnOptions.filterByType(attrType);
    
        if (this._columnOptions.get('columnsFetched') && this.get(attr)) {
          var attrExists = false;

    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

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

      _getColumnOptions: function (attr, attrType) {
        var opts = this._columnOptions.filterByType(attrType);
    
        if (this._columnOptions.get('columnsFetched') && this.get(attr)) {
          var attrExists = false;
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/connect-with-lines-form-model.js on lines 246..273
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/georeference-form-model.js on lines 331..357

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

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

      _updateAggregation: function () {
        var aggregate = this.get('aggregate');
    
        if (aggregate === '') {
          this.set({aggregation: 'count', aggregation_column: ''});
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/centroid-form-model.js on lines 162..177

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

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

      _replaceAttrs: function () {
        var attrs = this.parse(this.attributes);
        this.clear({ silent: true });
        this.set('type', attrs.type, { silent: true }); // re-set type to avoid change:type event to trigger again
        this.set(_.extend(attrs, this.defaults));
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/connect-with-lines-form-model.js on lines 72..77

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

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

          category_column: {
            type: 'EnablerEditor',
            title: '',
            label: _t('editor.layers.analysis-form.group-by'),
            editor: {
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/connect-with-lines-form-model.js on lines 190..202

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

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

      updateNodeDefinition: function (nodeDefModel) {
        var attrs = this._formatAttrs(this.attributes);
        nodeDefModel.clear({ silent: true });
        nodeDefModel.set(attrs);
      },
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/centroid-form-model.js on lines 52..56
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/connect-with-lines-form-model.js on lines 79..83
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/georeference-form-model.js on lines 41..45

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

    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

      _formatAttrs: function (formAttrs) {
        var customFormattedFormAttrs = this._typeDef().formatAttrs(formAttrs, this._columnOptions);
        return BaseAnalysisFormModel.prototype._formatAttrs.call(this, customFormattedFormAttrs);
      },
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/connect-with-lines-form-model.js on lines 85..88
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/georeference-form-model.js on lines 47..50

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

    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

      parse: function (attrs) {
        return _.defaults(
          _.pick(attrs, 'id', 'source'), // maintain default attrs
          this._typeDef(attrs.type).parse(attrs)
        );
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/area-of-influence-form-model.js on lines 15..20
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/connect-with-lines-form-model.js on lines 23..28

    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

          target_percentage: {
            type: 'Number',
            title: _t('editor.layers.analysis-form.target-percent'),
            help: _t('editor.layers.analysis-form.target-percent-help'),
            validators: ['required', {
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/area-of-influence-form-model.js on lines 107..116

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

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

        this._columnOptions = new ColumnOptions({}, {
          configModel: this._configModel,
          nodeDefModel: this._layerDefinitionModel.findAnalysisDefinitionNodeModel(this.get('source'))
        });
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/centroid-form-model.js on lines 35..38
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/connect-with-lines-form-model.js on lines 45..48
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/connect-with-lines-form-model.js on lines 50..53
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/georeference-form-model.js on lines 30..33
    lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analysis-form-models/moran-form-model.js on lines 21..24

    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

    There are no issues that match your filters.

    Category
    Status