exabugs/node-searcher

View on GitHub

Showing 26 of 26 total issues

File frequency.js has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Frequency Collection
 * @author exabugs@gmail.com
 */

Severity: Minor
Found in lib/text/frequency.js - About 3 hrs to fix

    Function cmdscale has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.cmdscale = function (db, target, source, callback) {
    
      var field = target.option.field || ['x', 'y'];
      var target_collection = db.collection(target.collection);
      var score = target.attribute + '.score';
    Severity: Major
    Found in lib/text/frequency.js - About 3 hrs to fix

      Function cosine has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.cosine = function (collection, condition, condition2, option, field, callback) {
      
        // 検索条件
        condition2.forEach(function (item) {
          var words = _.pluck(item.keyword, field[0]);
      Severity: Major
      Found in lib/vector/index.js - About 2 hrs to fix

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

          this.open(function (err, db) {
            if (err) {
              callback(err);
            } else {
              frequency.mutualize(db, source, field, function (err) {
        Severity: Major
        Found in index.js and 1 other location - About 1 hr to fix
        index.js on lines 243..252

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

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          this.open(function (err, db) {
            if (err) {
              callback(err);
            } else {
              frequency.cmdscale(db, target, source, function (err) {
        Severity: Major
        Found in index.js and 1 other location - About 1 hr to fix
        index.js on lines 205..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 73.

        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 mutualize has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.mutualize = function (db, source, field, callback) {
        
          var condition = source.option.condition || {};
          var collection = db.collection(source.collection);
        
        
        Severity: Minor
        Found in lib/text/frequency.js - About 1 hr to fix

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

                text.batch(db, source, field, function (err, count) {
                  if (err) {
                    db.close();
                    callback(err);
                  } else {
          Severity: Major
          Found in index.js and 1 other location - About 1 hr to fix
          index.js on lines 132..142

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

          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

                    frequency.object_frequency(db, target, freq, field, function (err) {
                      if (err) {
                        db.close();
                        callback(err);
                      } else {
          Severity: Major
          Found in index.js and 1 other location - About 1 hr to fix
          index.js on lines 73..83

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

          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 search has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.search = function (db, target, freq, field, callback) {
          
            var tasks = [];
            tasks.push(function (done) {
              var condition2 = [];
          Severity: Minor
          Found in lib/text/index.js - About 1 hr to fix

            Function countup has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.countup = function (db, target, source, field, callback) {
            
              var condition = target.option.condition || {};
              var collection = db.collection(target.collection);
            
            
            Severity: Minor
            Found in lib/text/frequency.js - About 1 hr to fix

              Function object_frequency has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports.object_frequency = function (db, info, freq, field, callback) {
              
                // 検索条件
                var condition = info.option.condition || {};
                var collection = db.collection(info.collection);
              Severity: Minor
              Found in lib/text/frequency.js - About 1 hr to fix

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

                exports.tfiof = function (db, target, freq, field, callback) {
                  // 検索条件
                  var condition = target.option.condition || {};
                  var collection = db.collection(target.collection);
                  condition[target.attribute] = {$exists: 1};
                Severity: Minor
                Found in lib/text/frequency.js - About 1 hr to fix

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

                  Searcher.prototype.indexing = function (target, source, callback) {
                    var freq = this.freq;
                    var field = this.field;
                    this.check(target);
                    this.check(source);
                  Severity: Minor
                  Found in index.js - About 1 hr to fix

                    Function sum has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Util.prototype.sum = function (a, b) {
                      var k = this.prop[0];
                      var c = this.prop[1];
                      var result = [];
                      for (var i = 0, j = 0; i < a.length || j < b.length;) {
                    Severity: Minor
                    Found in lib/vector/util.js - About 55 mins to fix

                    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

                    Function search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Util.prototype.search = function (array, value, head) {
                      head = head || 0;
                      var tail = array.length - 1;
                      while (head <= tail) {
                        var where = head + Math.floor((tail - head) / 2);
                    Severity: Minor
                    Found in lib/vector/util.js - About 55 mins to fix

                    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

                    Function patch has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    exports.patch = function (db, info, item, out, attribute, field, callback) {
                    Severity: Major
                    Found in lib/text/index.js - About 50 mins to fix

                      Function cosine has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      exports.cosine = function (collection, condition, condition2, option, field, callback) {
                      Severity: Minor
                      Found in lib/vector/index.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if (err) {
                                              callback(err);
                                            } else {
                                              fs.unlink(ofile);
                                              var index = 0;
                        Severity: Major
                        Found in lib/text/frequency.js - About 45 mins to fix

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

                          exports.tfiof = function (db, target, freq, field, callback) {
                          Severity: Minor
                          Found in lib/text/frequency.js - About 35 mins to fix

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

                            exports.object_frequency = function (db, info, freq, field, callback) {
                            Severity: Minor
                            Found in lib/text/frequency.js - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language