betajs/betajs-data

View on GitHub
src/data/queries/queries.js

Summary

Maintainability
F
4 days
Test Coverage

File queries.js has 546 lines of code (exceeds 250 allowed). Consider refactoring.
Open

Scoped.define("module:Queries", [
    "base:Types",
    "base:Sort",
    "base:Objs",
    "base:Class",
Severity: Major
Found in src/data/queries/queries.js - About 1 day to fix

    Function rangeSuperQueryDiffQuery has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            rangeSuperQueryDiffQuery: function(superCandidate, subCandidate) {
                if (!Objs.keyEquals(superCandidate, subCandidate))
                    return false;
                var rangeKey = Objs.objectify(["$gt", "$lt", "$gte", "$lte"]);
                var ors = [];
    Severity: Major
    Found in src/data/queries/queries.js - About 2 hrs to fix

      Function iterResult has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  var iterResult = Objs.iter(superCandidate, function(superValue, key) {
                      superValue = Objs.clone(superValue, 1);
                      var subValue = Objs.clone(subCandidate[key], 1);
                      Objs.iter(rangeKey, function(dummy, k) {
                          if (superValue[k] && subValue[k] && superValue[k] === subValue[k]) {
      Severity: Major
      Found in src/data/queries/queries.js - About 2 hrs to fix

        Function disjunctiveNormalForm has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                disjunctiveNormalForm: function(query, mergeKeys) {
                    query = Objs.clone(query, 1);
                    var factors = [];
                    if (query.$or) {
                        var factor = [];
        Severity: Minor
        Found in src/data/queries/queries.js - About 1 hr to fix

          Function mergeConditions has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  mergeConditions: function(conditions1, conditions2) {
                      if (!Types.is_object(conditions1))
                          conditions1 = {
                              "$eq": conditions1
                          };
          Severity: Minor
          Found in src/data/queries/queries.js - About 1 hr to fix

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

                    simplifyConditions: function(conditions) {
                        var result = {};
                        Objs.iter(["", "ic"], function(add) {
                            if (conditions["$eq" + add] || conditions["$in" + add]) {
                                var filtered = Objs.filter(conditions["$eq" + add] ? [conditions["$eq" + add]] : conditions["$in" + add], function(inkey) {
            Severity: Minor
            Found in src/data/queries/queries.js - About 1 hr to fix

              Avoid too many return statements within this function.
              Open

                                          return false;
              Severity: Major
              Found in src/data/queries/queries.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return false;
                Severity: Major
                Found in src/data/queries/queries.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return false;
                  Severity: Major
                  Found in src/data/queries/queries.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                            return false;
                    Severity: Major
                    Found in src/data/queries/queries.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                              return true;
                      Severity: Major
                      Found in src/data/queries/queries.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                                        return false;
                        Severity: Major
                        Found in src/data/queries/queries.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                          return this.validate_query(value, capabilities);
                          Severity: Major
                          Found in src/data/queries/queries.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                                        return false;
                            Severity: Major
                            Found in src/data/queries/queries.js - About 30 mins to fix

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

                                              } else if (subValue.$lt || subValue.$lte) {
                                                  if (superValue.$gt || superValue.$gte)
                                                      return false;
                                                  if (superValue.$lt || superValue.$lte) {
                                                      if ((superValue.$lt || superValue.$lte) < (subValue.$lt || subValue.$lte))
                              Severity: Major
                              Found in src/data/queries/queries.js and 1 other location - About 3 hrs to fix
                              src/data/queries/queries.js on lines 335..343

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

                              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

                                                  } else {
                                                      if (superValue.$lt || superValue.$lte)
                                                          return false;
                                                      if (superValue.$gt || superValue.$gte) {
                                                          if ((superValue.$gt || superValue.$gte) > (subValue.$gt || subValue.$gte))
                              Severity: Major
                              Found in src/data/queries/queries.js and 1 other location - About 3 hrs to fix
                              src/data/queries/queries.js on lines 344..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 109.

                              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 (conditions["$gte" + add] && (gt === null || compare(gt, conditions["$gte" + add]) < 0)) {
                                                      gte = true;
                                                      gt = conditions["$gte" + add];
                                                  }
                              Severity: Major
                              Found in src/data/queries/queries.js and 1 other location - About 1 hr to fix
                              src/data/queries/queries.js on lines 540..543

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

                              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 (conditions["$lte" + add] && (lt === null || compare(lt, conditions["$lte" + add]) > 0)) {
                                                      lte = true;
                                                      lt = conditions["$lte" + add];
                                                  }
                              Severity: Major
                              Found in src/data/queries/queries.js and 1 other location - About 1 hr to fix
                              src/data/queries/queries.js on lines 536..539

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

                              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

                                      validate_conditions: function(conditions, capabilities) {
                                          return Types.is_object(conditions) && Objs.all(conditions, function(value, key) {
                                              return this.validate_condition(value, key, capabilities);
                                          }, this);
                                      },
                              Severity: Major
                              Found in src/data/queries/queries.js and 1 other location - About 1 hr to fix
                              src/data/queries/queries.js on lines 130..134

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

                              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

                                      validate_query: function(query, capabilities) {
                                          return Types.is_object(query) && Objs.all(query, function(value, key) {
                                              return this.validate_pair(value, key, capabilities);
                                          }, this);
                                      },
                              Severity: Major
                              Found in src/data/queries/queries.js and 1 other location - About 1 hr to fix
                              src/data/queries/queries.js on lines 159..163

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

                              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

                                      validate_queries: function(queries, capabilities) {
                                          return Types.is_array(queries) && Objs.all(queries, function(query) {
                                              return this.validate_query(query, capabilities);
                                          }, this);
                                      },
                              Severity: Major
                              Found in src/data/queries/queries.js and 1 other location - About 1 hr to fix
                              src/data/queries/queries.js on lines 114..118

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 55.

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

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

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

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

                              Refactorings

                              Further Reading

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

                                      validate_atoms: function(atoms, capabilities) {
                                          return Types.is_array(atoms) && Objs.all(atoms, function(atom) {
                                              return this.validate_atom(atom, capabilities);
                                          }, this);
                                      },
                              Severity: Major
                              Found in src/data/queries/queries.js and 1 other location - About 1 hr to fix
                              src/data/queries/queries.js on lines 124..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 55.

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

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

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

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

                              Refactorings

                              Further Reading

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

                                      evaluate_value: function(value, object_value) {
                                          return !this.is_query_atom(value) ? this.evaluate_conditions(value, object_value) : this.evaluate_atom(value, object_value);
                                      },
                              Severity: Minor
                              Found in src/data/queries/queries.js and 1 other location - About 40 mins to fix
                              src/data/queries/queries.js on lines 155..157

                              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

                                      validate_value: function(value, capabilities) {
                                          return !this.is_query_atom(value) ? this.validate_conditions(value, capabilities) : this.validate_atom(value, capabilities);
                                      },
                              Severity: Minor
                              Found in src/data/queries/queries.js and 1 other location - About 40 mins to fix
                              src/data/queries/queries.js on lines 247..249

                              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

                              There are no issues that match your filters.

                              Category
                              Status