betajs/betajs-data

View on GitHub
src/data/stores/partial/cached_store.js

Summary

Maintainability
F
3 days
Test Coverage

File cached_store.js has 510 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Very important to know:
 *  - If both itemCache + remoteStore use the same id_key, the keys actually coincide.
 *  - If they use different keys, the cache stores the remoteStore keys as a foreign key and assigns its own keys to the cached items
 *
Severity: Major
Found in src/data/stores/partial/cached_store.js - About 1 day to fix

    Function cacheQuery has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                cacheQuery: function (query, queryOptions, options, ctx) {
                    var queryString = Constrained.serialize({
                        query: query,
                        options: queryOptions
                    });
    Severity: Major
    Found in src/data/stores/partial/cached_store.js - About 2 hrs to fix

      Function cacheGet has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  cacheGet: function (id, options, ctx) {
                      var foreignKey = options.foreignKey && this._foreignKey;
                      return this.cacheOnlyGet(id, options, ctx).mapSuccess(function (data) {
                          if (!data) {
                              if (!foreignKey && this._foreignKey)
      Severity: Major
      Found in src/data/stores/partial/cached_store.js - About 2 hrs to fix

        Function cacheUpdate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    cacheUpdate: function (id, data, options, ctx, transaction_id) {
                        var foreignKey = options.foreignKey && this._foreignKey;
                        var idKey = foreignKey ? this.remoteStore.id_key() : this.id_key();
                        var itemPromise = foreignKey ?
                                          this.itemCache.getBy(this.remoteStore.id_key(), id, ctx)
        Severity: Minor
        Found in src/data/stores/partial/cached_store.js - About 1 hr to fix

          Function constructor has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      constructor: function (remoteStore, options) {
                          inherited.constructor.call(this);
                          this.remoteStore = remoteStore;
                          this.__remoteQueryAggregate = Promise.aggregateExecution(this.remoteStore.query, this.remoteStore, null, function (data) {
                              return data ? data.asArray() : data;
          Severity: Minor
          Found in src/data/stores/partial/cached_store.js - About 1 hr to fix

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

                                var remotePromise = this.__remoteQueryAggregate(this.removeItemSupp(query), queryOptions, ctx).mapSuccess(function (items) {
                                    this.online();
                                    items = items.asArray ? items.asArray() : items;
                                    var meta = {
                                        refreshMeta: options.queryRefreshMeta ? this.cacheStrategy.queryRefreshMeta() : null,
            Severity: Minor
            Found in src/data/stores/partial/cached_store.js - About 1 hr to fix

              Function cacheUpdate has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                          cacheUpdate: function (id, data, options, ctx, transaction_id) {
              Severity: Minor
              Found in src/data/stores/partial/cached_store.js - About 35 mins to fix

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

                                        if (options.accessMeta) {
                                            meta.accessMeta = this.cacheStrategy.itemAccessMeta(meta.accessMeta);
                                            this.itemCache.update(cached_id, this.addItemMeta({}, meta), ctx);
                                        }
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 1 other location - About 1 hr to fix
                src/data/stores/partial/cached_store.js on lines 349..352

                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

                                            if (options.queryAccessMeta) {
                                                meta.accessMeta = this.cacheStrategy.queryAccessMeta(meta.accessMeta);
                                                this.queryCache.update(query_id, this.addQueryMeta({}, meta), ctx);
                                            }
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 1 other location - About 1 hr to fix
                src/data/stores/partial/cached_store.js on lines 276..279

                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

                            itemRefreshMeta: function (refreshMeta) {
                                if (refreshMeta)
                                    return refreshMeta;
                                if (this._options.itemRefreshTime === null)
                                    return null;
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 1 other location - About 1 hr to fix
                src/data/stores/partial/cached_store.js on lines 583..589

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

                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

                            queryRefreshMeta: function (refreshMeta) {
                                if (refreshMeta)
                                    return refreshMeta;
                                if (this._options.queryRefreshTime === null)
                                    return null;
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 1 other location - About 1 hr to fix
                src/data/stores/partial/cached_store.js on lines 575..581

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

                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

                            itemAccessMeta: function (accessMeta) {
                                if (this._options.itemAccessTime === null)
                                    return null;
                                return this._options.now() + this._options.itemAccessTime;
                            },
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 1 other location - About 1 hr to fix
                src/data/stores/partial/cached_store.js on lines 597..601

                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

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

                            queryAccessMeta: function (accessMeta) {
                                if (this._options.queryAccessTime === null)
                                    return null;
                                return this._options.now() + this._options.queryAccessTime;
                            },
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 1 other location - About 1 hr to fix
                src/data/stores/partial/cached_store.js on lines 591..595

                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

                                var itemPromise = foreignKey ?
                                      this.itemCache.getBy(this.remoteStore.id_key(), id, ctx)
                                    : this.itemCache.get(id, ctx);
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 2 other locations - About 50 mins to fix
                src/data/stores/partial/cached_store.js on lines 147..149
                src/data/stores/partial/cached_store.js on lines 238..240

                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

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

                                var itemPromise = foreignKey ?
                                                  this.itemCache.getBy(this.remoteStore.id_key(), id, ctx)
                                                : this.itemCache.get(id, ctx);
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 2 other locations - About 50 mins to fix
                src/data/stores/partial/cached_store.js on lines 217..219
                src/data/stores/partial/cached_store.js on lines 238..240

                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

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

                                var itemPromise = foreignKey ?
                                      this.itemCache.getBy(this.remoteStore.id_key(), id, ctx)
                                    : this.itemCache.get(id, ctx);
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 2 other locations - About 50 mins to fix
                src/data/stores/partial/cached_store.js on lines 147..149
                src/data/stores/partial/cached_store.js on lines 217..219

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

                            addQueryMeta: function (data, meta) {
                                data = Objs.clone(data, 1);
                                data[this._options.queryMetaKey] = meta;
                                return data;
                            },
                Severity: Minor
                Found in src/data/stores/partial/cached_store.js and 1 other location - About 45 mins to fix
                src/data/stores/partial/cached_store.js on lines 408..412

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

                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

                            addItemMeta: function (data, meta) {
                                data = Objs.clone(data, 1);
                                data[this._options.itemMetaKey] = meta;
                                return data;
                            },
                Severity: Minor
                Found in src/data/stores/partial/cached_store.js and 1 other location - About 45 mins to fix
                src/data/stores/partial/cached_store.js on lines 426..430

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

                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

                            validItemRefreshMeta: function (refreshMeta) {
                                return this._options.itemRefreshTime === null || refreshMeta >= this._options.now();
                            },
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 3 other locations - About 30 mins to fix
                src/data/stores/partial/cached_store.js on lines 607..609
                src/data/stores/partial/cached_store.js on lines 611..613
                src/data/stores/partial/cached_store.js on lines 615..617

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

                            validItemAccessMeta: function (accessMeta) {
                                return this._options.itemAccessTime === null || accessMeta >= this._options.now();
                            },
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 3 other locations - About 30 mins to fix
                src/data/stores/partial/cached_store.js on lines 603..605
                src/data/stores/partial/cached_store.js on lines 607..609
                src/data/stores/partial/cached_store.js on lines 615..617

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

                            validQueryAccessMeta: function (accessMeta) {
                                return this._options.queryAccessTime === null || accessMeta >= this._options.now();
                            }
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 3 other locations - About 30 mins to fix
                src/data/stores/partial/cached_store.js on lines 603..605
                src/data/stores/partial/cached_store.js on lines 607..609
                src/data/stores/partial/cached_store.js on lines 611..613

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

                            validQueryRefreshMeta: function (refreshMeta) {
                                return this._options.queryRefreshTime === null || refreshMeta >= this._options.now();
                            },    
                Severity: Major
                Found in src/data/stores/partial/cached_store.js and 3 other locations - About 30 mins to fix
                src/data/stores/partial/cached_store.js on lines 603..605
                src/data/stores/partial/cached_store.js on lines 611..613
                src/data/stores/partial/cached_store.js on lines 615..617

                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