CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/builder/data/user-model.js

Summary

Maintainability
D
2 days
Test Coverage

UserModel has 43 functions (exceeds 20 allowed). Consider refactoring.
Open

var UserModel = Backbone.Model.extend({
  urlRoot: function () {
    var baseUrl = this._configModel.get('base_url');
    return baseUrl + '/api/v1/users';
  },
Severity: Minor
Found in lib/assets/javascripts/builder/data/user-model.js - About 5 hrs to fix

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

      fullName: function () {
        var name = this.get('name') || '';
        var lastName = this.get('last_name') || '';
        if (name || lastName) {
          return name + (name && lastName ? ' ' : '') + lastName;
    Severity: Major
    Found in lib/assets/javascripts/builder/data/user-model.js and 2 other locations - About 2 hrs to fix
    lib/assets/javascripts/cartodb/models/user.js on lines 98..105
    lib/assets/javascripts/dashboard/data/user-model.js on lines 108..115

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

    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

      renderData: function (currentUser) {
        var name = this.get('username');
        if (currentUser && currentUser.id === this.id) {
          name = _t('user.you');
        }
    Severity: Major
    Found in lib/assets/javascripts/builder/data/user-model.js and 2 other locations - About 2 hrs to fix
    lib/assets/javascripts/cartodb/models/user.js on lines 107..118
    lib/assets/javascripts/dashboard/data/user-model.js on lines 117..128

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

    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

      getTotalPublicMapsCount: function () {
        var totalPublicPrivacyMapsCount = this.get('public_privacy_map_count') || 0;
        var totalPasswordPrivacyMapsCount = this.get('password_privacy_map_count') || 0;
        var totalLinkPrivacyMapsCount = this.get('link_privacy_map_count') || 0;
    
    
    Severity: Major
    Found in lib/assets/javascripts/builder/data/user-model.js and 1 other location - About 2 hrs to fix
    lib/assets/javascripts/dashboard/data/user-model.js on lines 174..180

    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

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

      featureEnabled: function (name) {
        var featureFlags = this.get('feature_flags');
        if (!featureFlags || featureFlags.length === 0 || !name) {
          return false;
        }
    Severity: Major
    Found in lib/assets/javascripts/builder/data/user-model.js and 2 other locations - About 1 hr to fix
    lib/assets/javascripts/cartodb/models/user.js on lines 178..186
    lib/assets/javascripts/dashboard/data/user-model.js on lines 206..214

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

    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

      clone: function () {
        var attrs = _.clone(this.attributes);
        delete attrs.id;
        return new UserModel(attrs, {
          configModel: this._configModel
    Severity: Major
    Found in lib/assets/javascripts/builder/data/user-model.js and 2 other locations - About 1 hr to fix
    lib/assets/javascripts/builder/data/permission-model.js on lines 167..173
    lib/assets/javascripts/dashboard/data/permission-model.js on lines 181..185

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

    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

      canStartTrial: function () {
        return !this.isInsideOrg() && this.get('account_type') === 'FREE' && this.get('table_count') > 0;
      },
    Severity: Major
    Found in lib/assets/javascripts/builder/data/user-model.js and 2 other locations - About 55 mins to fix
    lib/assets/javascripts/cartodb/models/user.js on lines 203..205
    lib/assets/javascripts/dashboard/data/user-model.js on lines 235..237

    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

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

      hasPublicMapsLimits: function () {
        const userWithLimits = this.isIndividualUser() || this.isFree2020User();
        return userWithLimits && !this.hasUnlimitedPublicMaps();
      },
    Severity: Minor
    Found in lib/assets/javascripts/builder/data/user-model.js and 1 other location - About 50 mins to fix
    lib/assets/javascripts/dashboard/data/user-model.js on lines 158..161

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

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

      hasRemainingPrivateMaps: function () {
        if (this.hasPrivateMapsLimits()) {
          return this.get('private_map_quota') > this.getTotalPrivateMapsCount();
        }
        return true;
    Severity: Major
    Found in lib/assets/javascripts/builder/data/user-model.js and 3 other locations - About 40 mins to fix
    lib/assets/javascripts/builder/data/user-model.js on lines 139..144
    lib/assets/javascripts/dashboard/data/user-model.js on lines 163..168
    lib/assets/javascripts/dashboard/data/user-model.js on lines 187..192

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

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

      hasRemainingPublicMaps: function () {
        if (this.hasPublicMapsLimits()) {
          return this.get('public_map_quota') > this.getTotalPublicMapsCount();
        }
        return true;
    Severity: Major
    Found in lib/assets/javascripts/builder/data/user-model.js and 3 other locations - About 40 mins to fix
    lib/assets/javascripts/builder/data/user-model.js on lines 163..168
    lib/assets/javascripts/dashboard/data/user-model.js on lines 163..168
    lib/assets/javascripts/dashboard/data/user-model.js on lines 187..192

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

    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 (this.get('layers')) {
          this.layers = new CustomBaselayersCollection(this.get('layers'), {
            configModel: this._configModel,
            currentUserId: this.id
          });
    Severity: Minor
    Found in lib/assets/javascripts/builder/data/user-model.js and 1 other location - About 35 mins to fix
    lib/assets/javascripts/builder/data/user-model.js on lines 28..36

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

        if (!_.isEmpty(this.get('organization'))) {
          this._organizationModel = new OrganizationModel(
            this.get('organization'),
            {
              configModel: this._configModel,
    Severity: Minor
    Found in lib/assets/javascripts/builder/data/user-model.js and 1 other location - About 35 mins to fix
    lib/assets/javascripts/builder/data/user-model.js on lines 38..43

    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

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

      isIndividualUser: function () {
        const proUsers = ['Individual', 'Annual Individual'];
        return proUsers.indexOf(this.get('account_type')) > -1;
      },
    Severity: Minor
    Found in lib/assets/javascripts/builder/data/user-model.js and 1 other location - About 30 mins to fix
    lib/assets/javascripts/dashboard/data/user-model.js on lines 95..98

    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