LivePersonInc/cacherjs

View on GitHub

Showing 22 of 22 total issues

Function prototype has 188 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Cacher.prototype = (function () {
        /**
         * Method for initialization
         * @param {Object} [options] - the configuration options for the instance
         * @param {Number} [options.max] - optional max items in cache
Severity: Major
Found in src/cacher.js - About 7 hrs to fix

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

                                } else if (cbRes !== false && timeoutRes !== false) {
                                    remove.call(this, key);
                                    removed++;
                                } else if (!removed && kickoutClosestTTL) {
                                    if (!kickOut) {
    Severity: Major
    Found in src/cacher.js and 1 other location - About 4 hrs to fix
    src/cacher.js on lines 271..315

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

    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

                            if (this.cache[key].timeout <= (new Date()).getTime()) {
                                item = this.cache[key].item;
                                callback = this.cache[key].callback;
    
                                if (callback) {
    Severity: Major
    Found in src/cacher.js and 1 other location - About 4 hrs to fix
    src/cacher.js on lines 288..302

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

    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

    Function prototype has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        TtlCacheFileStore.prototype = (function () {
            /**
             * Method for initialization
             * @param {Object} options - the configuration options for the instance
             * @param {String} options.file - file path
    Severity: Major
    Found in src/stores/ttlCacheFileStore.js - About 3 hrs to fix

      Function _evict has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function _evict(kickoutClosestTTL) {
                  var callback;
                  var item;
                  var cbRes;
                  var timeoutRes;
      Severity: Major
      Found in src/cacher.js - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                    if (!this.initialized) {
                        options = options || {};
        
                        this.cache = {};                                                                                                               // Objects cache
                        this.length = 0;                                                                                                               // Amount of items in cache
        Severity: Critical
        Found in src/cacher.js - About 2 hrs to fix

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

                  function load(options) {
                      var stream;
                      var parser;
                      var data;
                      var attributes;
          Severity: Major
          Found in src/stores/ttlCacheFileStore.js - About 2 hrs to fix

            Function initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function initialize(options) {
                        var that = this;
                        var stop = false;
                        var index = 0;
            
            
            Severity: Minor
            Found in src/cacher.js - About 1 hr to fix

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

                              this.ttl = options.ttl && !isNaN(options.ttl) && 0 < options.ttl ? parseInt(options.ttl, 10) : 0;                              // Time to leave for items (this can be overidden for specific items using the set method - 0 for unlimited
              Severity: Major
              Found in src/cacher.js and 2 other locations - About 1 hr to fix
              src/cacher.js on lines 89..89
              src/cacher.js on lines 91..91

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

                              this.max = options.max && !isNaN(options.max) && 0 < options.max ? parseInt(options.max, 10) : 0;                              // Maximum items in cache - 0 for unlimited
              Severity: Major
              Found in src/cacher.js and 2 other locations - About 1 hr to fix
              src/cacher.js on lines 90..90
              src/cacher.js on lines 91..91

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

                              this.interval = options.interval && !isNaN(options.interval) && 0 < options.interval ? parseInt(options.interval, 10) : 1000;  // Interval for running the eviction loop
              Severity: Major
              Found in src/cacher.js and 2 other locations - About 1 hr to fix
              src/cacher.js on lines 89..89
              src/cacher.js on lines 90..90

              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

              Function save has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      function save(data) {
                          var writable;
                          var json = {};
              
                          if (this.initialized) {
              Severity: Minor
              Found in src/stores/ttlCacheFileStore.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                                if (eviction && (this.cache[key].callback || "function" === typeof this.ontimeout || "function" === typeof this.onkickout) || this.max && this.length > this.max) {
                                    _evict.call(this, this.max && this.length > this.max);
                                }
                Severity: Major
                Found in src/cacher.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if (callback) {
                                                  cbRes = callback(key, item);
                                              }
                  Severity: Major
                  Found in src/cacher.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if (this.ontimeout) {
                                                    timeoutRes = this.ontimeout(key, item);
                                                }
                    Severity: Major
                    Found in src/cacher.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              else if (!removed && kickoutClosestTTL) {
                                                  if (!kickOut) {
                                                      kickOut = {
                                                          key: key,
                                                          timeout: this.cache[key].timeout
                      Severity: Major
                      Found in src/cacher.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (typeof cbRes === 'object') {
                                                        touch.call(this, key, cbRes.ttl || this.cache[key].ttl, cbRes.callback || callback);
                                                    } else if (typeof timeoutRes === 'object') {
                                                        touch.call(this, key, timeoutRes.ttl || this.cache[key].ttl, timeoutRes.callback || callback);
                                                    } else if (cbRes !== false && timeoutRes !== false) {
                        Severity: Major
                        Found in src/cacher.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                          if (options && options.onitem) {
                                                              options.onitem(null, data);
                                                          }
                          Severity: Major
                          Found in src/stores/ttlCacheFileStore.js - About 45 mins to fix

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

                                function TtlCacheFileStore(options) {
                                    // For forcing new keyword
                                    if (false === (this instanceof TtlCacheFileStore)) {
                                        return new TtlCacheFileStore(options);
                                    }
                            Severity: Minor
                            Found in src/stores/ttlCacheFileStore.js and 1 other location - About 35 mins to fix
                            src/cacher.js on lines 45..52

                            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

                                function Cacher(options) {
                                    // For forcing new keyword
                                    if (false === (this instanceof Cacher)) {
                                        return new Cacher(options);
                                    }
                            Severity: Minor
                            Found in src/cacher.js and 1 other location - About 35 mins to fix
                            src/stores/ttlCacheFileStore.js on lines 17..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 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

                            Severity
                            Category
                            Status
                            Source
                            Language