uu-cubitt/graph

View on GitHub

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

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

              public addConnector(id: Common.Guid, type: string, nodeId: Common.Guid, properties: Common.Dictionary<any> = {}): void {
                  this.graph.addConnector(id, type, nodeId, properties);
              }
          Severity: Major
          Found in src/Project.ts and 1 other location - About 2 hrs to fix
          src/Project.ts on lines 16..18

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

          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

              public addNode(id: Common.Guid, type: string, modelId: Common.Guid, properties: Common.Dictionary<any> = {}): void {
                  this.graph.addNode(id, type, modelId, properties);
              }
          Severity: Major
          Found in src/Project.ts and 1 other location - About 2 hrs to fix
          src/Project.ts on lines 30..32

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

          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 4 locations. Consider refactoring.
          Open

              public hasModel(id: Common.Guid): boolean {
                  let elem = this.elements[id.toString()];
                  return elem !== undefined && elem.getType() === ElementType.Model;
              }
          Severity: Major
          Found in src/Graph.ts and 3 other locations - About 2 hrs to fix
          src/Graph.ts on lines 56..59
          src/Graph.ts on lines 64..67
          src/Graph.ts on lines 72..75

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

          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 4 locations. Consider refactoring.
          Open

              public hasNode(id: Common.Guid): boolean {
                  let elem = this.elements[id.toString()];
                  return elem !== undefined && elem.getType() === ElementType.Node;
              }
          Severity: Major
          Found in src/Graph.ts and 3 other locations - About 2 hrs to fix
          src/Graph.ts on lines 48..51
          src/Graph.ts on lines 64..67
          src/Graph.ts on lines 72..75

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

          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 4 locations. Consider refactoring.
          Open

              public hasConnector(id: Common.Guid): boolean {
                  let elem = this.elements[id.toString()];
                  return elem !== undefined && elem.getType() === ElementType.Connector;
              }
          Severity: Major
          Found in src/Graph.ts and 3 other locations - About 2 hrs to fix
          src/Graph.ts on lines 48..51
          src/Graph.ts on lines 56..59
          src/Graph.ts on lines 72..75

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

          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 4 locations. Consider refactoring.
          Open

              public hasEdge(id: Common.Guid): boolean {
                  let elem = this.elements[id.toString()];
                  return elem !== undefined && elem.getType() === ElementType.Edge;
              }
          Severity: Major
          Found in src/Graph.ts and 3 other locations - About 2 hrs to fix
          src/Graph.ts on lines 48..51
          src/Graph.ts on lines 56..59
          src/Graph.ts on lines 64..67

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

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

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

                                "connectors": {
                                    "parent": elem.getParentConnectorNeighbours().map(g => g.toString()),
                                    "child": elem.getChildConnectorNeighbours().map(g => g.toString())
                                }
            Severity: Major
            Found in src/Graph.ts and 3 other locations - About 1 hr to fix
            src/Graph.ts on lines 443..446
            src/Graph.ts on lines 447..450
            src/Graph.ts on lines 451..454

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

            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 4 locations. Consider refactoring.
            Open

                                "nodes": {
                                    "parent": elem.getParentNodeNeighbours().map(g => g.toString()),
                                    "child": elem.getChildNodeNeighbours().map(g => g.toString())
                                },
            Severity: Major
            Found in src/Graph.ts and 3 other locations - About 1 hr to fix
            src/Graph.ts on lines 443..446
            src/Graph.ts on lines 451..454
            src/Graph.ts on lines 455..458

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

            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 4 locations. Consider refactoring.
            Open

                                "models": {
                                    "parent": elem.getParentModelNeighbours().map(g => g.toString()),
                                    "child": elem.getChildModelNeighbours().map(g => g.toString())
                                },
            Severity: Major
            Found in src/Graph.ts and 3 other locations - About 1 hr to fix
            src/Graph.ts on lines 447..450
            src/Graph.ts on lines 451..454
            src/Graph.ts on lines 455..458

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

            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 4 locations. Consider refactoring.
            Open

                                "edges": {
                                    "parent": elem.getParentEdgeNeighbours().map(g => g.toString()),
                                    "child": elem.getChildEdgeNeighbours().map(g => g.toString())
                                },
            Severity: Major
            Found in src/Graph.ts and 3 other locations - About 1 hr to fix
            src/Graph.ts on lines 443..446
            src/Graph.ts on lines 447..450
            src/Graph.ts on lines 455..458

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

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

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

                                } else if (elem["neighbours"]["edges"]["parent"].length > 0) {
                                    graph.addModel(Common.Guid.parse(elem.id), properties["type"], properties, Common.Guid.parse(elem["neighbours"]["edges"]["parent"][0]));
                                } else {
                                    graph.addModel(Common.Guid.parse(elem.id), properties["type"], properties);
                                }
            Severity: Major
            Found in src/Graph.ts and 1 other location - About 1 hr to fix
            src/Graph.ts on lines 336..342

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

            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

                                if (elem["neighbours"]["nodes"]["parent"].length > 0) {
                                    graph.addModel(Common.Guid.parse(elem.id), properties["type"], properties, Common.Guid.parse(elem["neighbours"]["nodes"]["parent"][0]));
                                } else if (elem["neighbours"]["edges"]["parent"].length > 0) {
                                    graph.addModel(Common.Guid.parse(elem.id), properties["type"], properties, Common.Guid.parse(elem["neighbours"]["edges"]["parent"][0]));
                                } else {
            Severity: Major
            Found in src/Graph.ts and 1 other location - About 1 hr to fix
            src/Graph.ts on lines 338..342

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

            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 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
              Severity
              Category
              Status
              Source
              Language