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;
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';
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
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;
- Read upRead up
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';
Query
has 38 functions (exceeds 20 allowed). Consider refactoring. Open
export default class Query {
constructor(model, options) {
options = options || {};
if(!model) {
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;
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;
Schema
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
export default class Schema extends EventEmitter {
constructor(props, options) {
super();
props = props || {};
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));
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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));
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- Read upRead up
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';
Function normalizeOptions
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
normalizeOptions(options) {
if(!options) {
return null;
}
- Read upRead up
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;
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');
}
Document
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
export default class Document extends EventEmitter {
constructor(model, properties, options) {
super()
properties = properties || {};
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
- Read upRead up
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, {
Function has a complexity of 12. Open
(function(name) {
- Read upRead up
- Exclude checks
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/