leafjs/orient

View on GitHub
src/query.js

Summary

Maintainability
F
4 days
Test Coverage

File query.js has 462 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import OrientjsQuery from 'orientjs/lib/db/query';
import debug from 'debug';
import _ from 'lodash';
import Document from './document';
import GraphSchema from './schemas/graph';
Severity: Minor
Found in src/query.js - About 7 hrs to fix

    Function exec has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        exec(fn) {
    
            var model = this.model;
            var schema = model.schema;
            var operation = this._operation;
    Severity: Minor
    Found in src/query.js - About 6 hrs 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

    Query has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Query {
        constructor(model, options) {
            options = options || {};
    
            if(!model) {
    Severity: Minor
    Found in src/query.js - About 5 hrs to fix

      Function exec has 104 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          exec(fn) {
      
              var model = this.model;
              var schema = model.schema;
              var operation = this._operation;
      Severity: Major
      Found in src/query.js - About 4 hrs to fix

        Function createComparisonQuery has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            createComparisonQuery(propertyName, operator, value) {
                var param;
                var type = this.schema.getSchemaType(propertyName);
                if ( value && true === value.__orientose_raw__ ) {
                    param = value;
        Severity: Minor
        Found in src/query.js - About 3 hrs 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 queryLanguage has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            queryLanguage(conditions) {
                var items = [];
        
                Object.keys(conditions).forEach(propertyName => {
        
        
        Severity: Minor
        Found in src/query.js - About 1 hr to fix

          Function createComparisonQuery has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              createComparisonQuery(propertyName, operator, value) {
                  var param;
                  var type = this.schema.getSchemaType(propertyName);
                  if ( value && true === value.__orientose_raw__ ) {
                      param = value;
          Severity: Minor
          Found in src/query.js - About 1 hr to fix

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

                constructor(model, options) {
                    options = options || {};
            
                    if(!model) {
                        throw new Error('Model is not defined');
            Severity: Minor
            Found in src/query.js - About 1 hr to fix

              Function condExec has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  condExec(conditions, callback) {
                      if(typeof conditions === 'function') {
                          callback = conditions;
                          conditions = void 0;
                      }
              Severity: Minor
              Found in src/query.js - About 35 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

              Avoid too many return statements within this function.
              Open

                      return propertyName + ' ' + operator + ' ' + param;
              Severity: Major
              Found in src/query.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return items.push(query);
                Severity: Major
                Found in src/query.js - About 30 mins to fix

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

                              } else if(operation === Operation.DELETE) {
                                  query = query.delete(graphType, target);
                              } else if(operation === Operation.SELECT) {
                                  query = query.select(selects).from(target);
                              } else {
                  Severity: Major
                  Found in src/query.js and 1 other location - About 1 hr to fix
                  src/query.js on lines 500..506

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

                  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

                              } else if(operation === Operation.DELETE) {
                                  query = query.delete().from(target);
                              } else if(operation === Operation.SELECT) {
                                  query = query.select(selects).from(target);
                              } else {
                  Severity: Major
                  Found in src/query.js and 1 other location - About 1 hr to fix
                  src/query.js on lines 490..496

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

                  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

                      and(conditions) {
                          var self = this;
                          conditions.forEach(function(condition) {
                              self = self.operator(Operator.AND, condition);
                          });
                  Severity: Major
                  Found in src/query.js and 1 other location - About 1 hr to fix
                  src/query.js on lines 274..280

                  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

                          if(this._to) {
                              query.to(this._to && this._to['@rid'] ? this._to['@rid'] : this._to);
                          }
                  Severity: Major
                  Found in src/query.js and 1 other location - About 1 hr to fix
                  src/query.js on lines 509..511

                  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

                      or(conditions) {
                          var self = this;
                          conditions.forEach(function(condition) {
                              self = self.operator(Operator.OR, condition);
                          });
                  Severity: Major
                  Found in src/query.js and 1 other location - About 1 hr to fix
                  src/query.js on lines 282..288

                  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

                          if(this._from) {
                              query.from(this._from && this._from['@rid'] ? this._from['@rid'] : this._from);
                          }
                  Severity: Major
                  Found in src/query.js and 1 other location - About 1 hr to fix
                  src/query.js on lines 513..515

                  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

                  Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
                  Open

                  import OrientjsQuery from 'orientjs/lib/db/query';
                  Severity: Minor
                  Found in src/query.js by eslint

                  For more information visit Source: http://eslint.org/docs/rules/

                  There are no issues that match your filters.

                  Category
                  Status