Showing 13 of 72 total issues
Function deserialize
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public deserialize(jsonObject: Object): GraphInterface {
let graph = new Graph();
let models = jsonObject["models"];
let queue: Collections.Queue<Object> = new Collections.Queue<Object>();
let inQueue: Common.Dictionary<Boolean> = {};
- 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 Graph.ts
has 315 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as Common from "cubitt-common";
import * as Collections from "typescript-collections";
import {AbstractElement} from "./AbstractElement";
import {NodeElement} from "./NodeElement";
import {EdgeElement} from "./EdgeElement";
AbstractElement
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
export abstract class AbstractElement {
protected id: Common.Guid;
protected type: ElementType;
protected properties: Common.Dictionary<any>;
protected parentNodeNeighbours: Common.Dictionary<Common.Guid>;
Function deserialize
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
public deserialize(jsonObject: Object): GraphInterface {
let graph = new Graph();
let models = jsonObject["models"];
let queue: Collections.Queue<Object> = new Collections.Queue<Object>();
let inQueue: Common.Dictionary<Boolean> = {};
Graph
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export class Graph implements GraphInterface {
private elements: Common.Dictionary<AbstractElement>;
constructor() {
this.elements = {};
Function serialize
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public serialize() {
let graph = {
"models": {},
"nodes": {},
"edges": {},
Function addModel
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public addModel(id: Common.Guid, type: string, properties: Common.Dictionary<any>, parentId?: Common.Guid) {
// Validate GUID
/* istanbul ignore if */
if (this.hasElement(id)) {
throw new Error("An Element with GUID " + id.toString() + " already exists");
- 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 addEdge
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public addEdge(id: Common.Guid, type: string, modelId: Common.Guid, startConnectorId: Common.Guid, endConnectorId: Common.Guid, properties: Common.Dictionary<any> = {}) {
// Validate GUID
/* istanbul ignore if */
if (this.hasElement(id)) {
throw new Error("An Element with GUID " + id.toString() + " already exists");
Function addEdge
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public addEdge(id: Common.Guid, type: string, modelId: Common.Guid, startConnectorId: Common.Guid, endConnectorId: Common.Guid, properties: Common.Dictionary<any> = {}) {
// Validate GUID
/* istanbul ignore if */
if (this.hasElement(id)) {
throw new Error("An Element with GUID " + id.toString() + " already exists");
- 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
Avoid deeply nested control flow statements. Open
for (let connectorId of edge["neighbours"]["connectors"]["parent"]) {
if (inQueue[connectorId] !== true) {
isInQueue = false;
}
}
Avoid deeply nested control flow statements. Open
if (isInQueue === true) {
edges.push(edgeId);
}
Function deleteElement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public deleteElement(id: Common.Guid, ofType?: ElementType): void {
if (ofType === undefined) {
delete this.elements[id.toString()];
} else {
let elem = this.elements[id.toString()];
- 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 serialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public serialize() {
let graph = {
"models": {},
"nodes": {},
"edges": {},
- 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"