uu-cubitt/graph

View on GitHub

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> = {};
Severity: Minor
Found in src/Graph.ts - About 5 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 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";
Severity: Minor
Found in src/Graph.ts - About 3 hrs to fix

    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>;
    Severity: Minor
    Found in src/AbstractElement.ts - About 3 hrs to fix

      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> = {};
      Severity: Major
      Found in src/Graph.ts - About 2 hrs to fix

        Graph has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class Graph implements GraphInterface {
            private elements: Common.Dictionary<AbstractElement>;
        
            constructor() {
                this.elements = {};
        Severity: Minor
        Found in src/Graph.ts - About 2 hrs to fix

          Function serialize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public serialize() {
                  let graph = {
                      "models": {},
                      "nodes": {},
                      "edges": {},
          Severity: Minor
          Found in src/Graph.ts - About 1 hr to fix

            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");
            Severity: Minor
            Found in src/Graph.ts - About 1 hr 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 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");
            Severity: Minor
            Found in src/Graph.ts - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                          for (let connectorId of edge["neighbours"]["connectors"]["parent"]) {
                                              if (inQueue[connectorId] !== true) {
                                                  isInQueue = false;
                                              }
                                          }
              Severity: Major
              Found in src/Graph.ts - About 45 mins to fix

                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");
                Severity: Minor
                Found in src/Graph.ts - About 45 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 deeply nested control flow statements.
                Open

                                            if (isInQueue === true) {
                                                edges.push(edgeId);
                                            }
                Severity: Major
                Found in src/Graph.ts - About 45 mins to fix

                  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()];
                  Severity: Minor
                  Found in src/Graph.ts - 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

                  Function serialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public serialize() {
                          let graph = {
                              "models": {},
                              "nodes": {},
                              "edges": {},
                  Severity: Minor
                  Found in src/Graph.ts - About 25 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

                  Severity
                  Category
                  Status
                  Source
                  Language