Showing 22 of 71 total issues
File Model.ts
has 426 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as MongoDB from "mongodb";
import * as Bluebird from "bluebird";
import * as util from "util";
import * as _ from "lodash";
import * as Skmatc from "skmatc";
- Create a ticketCreate a ticket
Model
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
export class Model<TDocument extends { _id?: any }, TInstance> {
/**
* Creates a new Iridium model representing a given ISchema and backed by a collection whose name is specified
* @param core The Iridium core that this model should use for database access
* @param instanceType The class which will be instantiated for each document retrieved from the database
- Create a ticketCreate a ticket
Function save
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
save(...args: any[]): Bluebird<TInstance> {
let callback: General.Callback<any>|undefined = undefined;
let changes: any = null;
let conditions: any = {};
- Create a ticketCreate a ticket
Omnom
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export class Omnom {
constructor(public options: {
atomicNumbers?: boolean;
} = {}) {
this._changes = {};
- Create a ticketCreate a ticket
Function insert
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
insert(objs: TDocument | TDocument[], ...args: any[]): Bluebird<any> {
let objects: TDocument[];
let options: ModelOptions.CreateOptions = {};
let callback: General.Callback<any>|undefined = undefined;
if (typeof args[0] === "function") callback = args[0];
- Create a ticketCreate a ticket
Function onSomething
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private onSomething(original: any, modified: any, changePath?: string): void {
if (changePath) {
if (original === undefined || original === null)
return this.onUndefined(original, modified, changePath);
- Read upRead up
- Create a ticketCreate a ticket
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 findOne
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
findOne(...args: any[]): Bluebird<TInstance|null> {
let conditions: { _id?: any, [key: string]: any }|undefined;
let options: ModelOptions.QueryOptions|undefined;
let callback: General.Callback<TInstance>|undefined;
- Create a ticketCreate a ticket
Function remove
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
remove(conds?: any, options?: ModelOptions.RemoveOptions, callback?: General.Callback<number>): Bluebird<number> {
let conditions: { _id?: string; } | Conditions = conds;
if (typeof options === "function") {
callback = <General.Callback<number>>options;
- Create a ticketCreate a ticket
Function almostEqual
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private almostEqual(o1: any, o2: any): number {
if (!_.isPlainObject(o1) || !_.isPlainObject(o2)) return o1 == o2 ? 1 : 0;
let object1Keys = Object.keys(o1);
let object2Keys = Object.keys(o2);
- Read upRead up
- Create a ticketCreate a ticket
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 ModelSpecificInstance
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function ModelSpecificInstance<TDocument extends { _id?: any }, TInstance>(model: Model<TDocument, TInstance>, instanceType: InstanceImplementation<TDocument, TInstance>): ModelSpecificInstanceConstructor<TDocument, TInstance> {
const instanceTypeConstructor = <InstanceConstructor><any>instanceType;
let virtualClass = class extends instanceTypeConstructor {
constructor(...args: any[]) {
- Create a ticketCreate a ticket
Function mapReduce
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
mapReduce<Key, Value>(functions: InstanceImplementation<MapReducedDocument<Key, Value>, any> |
MapReduceFunctions<TDocument, Key, Value>, options: MapReduceOptions) {
type fn = MapReduceFunctions<TDocument, Key, Value>;
type instance = InstanceImplementation<MapReducedDocument<Key, Value>, any>
- Create a ticketCreate a ticket
Function transformFromDB
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
transformFromDB(document: TDocument, options: TransformOptions = { properties: true }): TDocument {
if(options.document && this.model.transforms.$document)
document = this.model.transforms.$document.fromDB(document, "$document", this.model);
if(!options.properties) return document;
- Read upRead up
- Create a ticketCreate a ticket
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 transformToDB
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
transformToDB<T>(document: T, options: TransformOptions = { properties: true }): T {
if(options.document && this.model.transforms.$document)
document = <any>this.model.transforms.$document.toDB(document, "$document", this.model);
if(!options.properties) return document;
- Read upRead up
- Create a ticketCreate a ticket
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 parseRefspec
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function parseRefspec(refSpec) {
let properties = {
localHead: false,
version: false,
tags: [],
- Read upRead up
- Create a ticketCreate a ticket
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 onSmallerArray
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private onSmallerArray(original: any[], modified: any[], changePath: string): void {
let pulls: any[] = [];
let i = 0;
let j = 0;
- Read upRead up
- Create a ticketCreate a ticket
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 onSimilarArray
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private onSimilarArray(original: any[], modified: any[], changePath: string): void {
// Check how many manipulations would need to be performed, if it's more than half the array size
// then rather re-create the array
let sets: number[] = [];
let partials: number[] = [];
- Read upRead up
- Create a ticketCreate a ticket
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 pull
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private pull(path: string, value: any) {
if (!this.changes.$pull)
this.changes.$pull = {};
if (this.changes.$pullAll && this.changes.$pullAll[path]) {
- Read upRead up
- Create a ticketCreate a ticket
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 findOne
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
findOne(...args: any[]): Bluebird<TInstance|null> {
let conditions: { _id?: any, [key: string]: any }|undefined;
let options: ModelOptions.QueryOptions|undefined;
let callback: General.Callback<TInstance>|undefined;
- Read upRead up
- Create a ticketCreate a ticket
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 this.onScalar(original, modified, changePath);
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return this.onObject(original, modified, changePath);
- Create a ticketCreate a ticket