leafjs/orient

View on GitHub

Showing 143 of 143 total issues

File index.js has 500 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const glob = require('glob');
const debug = require('debug')("leafjs:http:middleware:orient");
const Orientose = require('../dist/orientose').default;
const Schema = Orientose.Schema;

Severity: Minor
Found in lib/index.js - About 1 day to fix

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

          buildschema(parent) {
              var self = this;
              parent = parent || Schema.V;
              var schema = new parent(self._props, {
                  className: this._name
      Severity: Major
      Found in lib/index.js - About 6 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

        File index.js has 377 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import {EventEmitter} from 'events';
        import Kareem from 'kareem';
        import _ from 'lodash';
        import VirtualType from '../types/virtual';
        import Data from '../data';
        Severity: Minor
        Found in src/schemas/index.js - About 5 hrs to fix

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

                _ensureClass(callback) {
                    var model = this;
                    var db = this.db;
                    var schema = this.schema;
                    var className = schema._options.className || this.name;
            Severity: Major
            Found in src/model.js - About 4 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

                Schema has 32 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export default class Schema extends EventEmitter {
                    constructor(props, options) {
                        super();
                
                        props = props || {};
                Severity: Minor
                Found in src/schemas/index.js - About 4 hrs to fix

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

                  ModelBuilder.prototype.embedded = function(name, fn) {
                      this._later = this._later || [];
                      this._later.push(function(schemas) {
                          if (require("util").isFunction(fn)) {
                              this.attr(name, fn(schemas));
                  Severity: Major
                  Found in lib/index.js and 1 other location - About 3 hrs to fix
                  lib/index.js on lines 285..294

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

                  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

                  ModelBuilder.prototype.embeddedlist = function(name, fn) {
                      this._later = this._later || [];
                      this._later.push(function(schemas) {
                          if (require("util").isFunction(fn)) {
                              this.attr(name, fn(schemas));
                  Severity: Major
                  Found in lib/index.js and 1 other location - About 3 hrs to fix
                  lib/index.js on lines 296..305

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

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

                  File model.js has 306 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { EventEmitter } from 'events';
                  import Schema from './schemas/index';
                  import Document from './document';
                  import { waterfall, each, serial } from 'async';
                  import convertType from './types/convert';
                  Severity: Minor
                  Found in src/model.js - About 3 hrs to fix

                    Function normalizeOptions has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                        normalizeOptions(options) {
                            if(!options) {
                                return null;
                            }
                    
                    
                    Severity: Minor
                    Found in src/schemas/index.js - About 2 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 _ensureIndex has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _ensureIndex(OClass, callback) {
                            var db = this.db;
                            var className = this.name;
                            var schema = this.schema;
                            var model = this;
                    Severity: Major
                    Found in src/model.js - About 2 hrs to fix

                      Type has 25 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      export default class Type {
                          constructor (data, prop, name, mainData) {
                              if(!data || !prop || !name || !mainData) {
                                  throw new Error('Data or prop is undefined');
                              }
                      Severity: Minor
                      Found in src/types/type.js - About 2 hrs to fix

                        Document has 25 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        export default class Document extends EventEmitter {
                            constructor(model, properties, options) {
                                super()
                                properties = properties || {};
                        
                        
                        Severity: Minor
                        Found in src/document.js - About 2 hrs to fix

                          Function buildschema has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          Open

                              buildschema(parent) {
                                  var self = this;
                                  parent = parent || Schema.V;
                                  var schema = new parent(self._props, {
                                      className: this._name
                          Severity: Minor
                          Found in lib/index.js - About 2 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 initialize has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              * initialize(next) {
                                  let koa = this.koa;
                                  let http = this;
                          
                                  let _config = require("extend")({}, DEFAULTCONFIG, {
                          Severity: Major
                          Found in lib/index.js - About 2 hrs to fix

                            Function has a complexity of 12.
                            Open

                                                (function(name) {
                            Severity: Minor
                            Found in lib/index.js by eslint

                            Limit Cyclomatic Complexity (complexity)

                            Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                            function a(x) {
                                if (true) {
                                    return x; // 1st path
                                } else if (false) {
                                    return x+1; // 2nd path
                                } else {
                                    return 4; // 3rd path
                                }
                            }

                            Rule Details

                            This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                            Examples of incorrect code for a maximum of 2:

                            /*eslint complexity: ["error", 2]*/
                            
                            function a(x) {
                                if (true) {
                                    return x;
                                } else if (false) {
                                    return x+1;
                                } else {
                                    return 4; // 3rd path
                                }
                            }

                            Examples of correct code for a maximum of 2:

                            /*eslint complexity: ["error", 2]*/
                            
                            function a(x) {
                                if (true) {
                                    return x;
                                } else {
                                    return 4;
                                }
                            }

                            Options

                            Optionally, you may specify a max object property:

                            "complexity": ["error", 2]

                            is equivalent to

                            "complexity": ["error", { "max": 2 }]

                            Deprecated: the object property maximum is deprecated. Please use the property max instead.

                            When Not To Use It

                            If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                            Further Reading

                            Related Rules

                            • [max-depth](max-depth.md)
                            • [max-len](max-len.md)
                            • [max-nested-callbacks](max-nested-callbacks.md)
                            • [max-params](max-params.md)
                            • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/
                            Severity
                            Category
                            Status
                            Source
                            Language