uu-cubitt/graph

View on GitHub

Showing 72 of 72 total issues

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

    addNode(id: Common.Guid, type: string, modelId: Common.Guid, properties ?: Common.Dictionary<any>): void;
Severity: Minor
Found in src/GraphInterface.ts and 1 other location - About 55 mins to fix
src/GraphInterface.ts on lines 38..38

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

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

    addConnector(id: Common.Guid, type: string, nodeId: Common.Guid, properties ?: Common.Dictionary<any>): void;
Severity: Minor
Found in src/GraphInterface.ts and 1 other location - About 55 mins to fix
src/GraphInterface.ts on lines 16..16

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

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

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

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

          public addParentEdgeNeighbour(id: Common.Guid): void {
              this.parentEdgeNeighbours[id.toString()] = id;
          }
      Severity: Major
      Found in src/AbstractElement.ts and 6 other locations - About 40 mins to fix
      src/AbstractElement.ts on lines 79..81
      src/AbstractElement.ts on lines 97..99
      src/AbstractElement.ts on lines 106..108
      src/AbstractElement.ts on lines 115..117
      src/AbstractElement.ts on lines 124..126
      src/AbstractElement.ts on lines 133..135

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

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

          public addChildConnectorNeighbour(id: Common.Guid): void {
              this.childConnectorNeighbours[id.toString()] = id;
          }
      Severity: Major
      Found in src/AbstractElement.ts and 6 other locations - About 40 mins to fix
      src/AbstractElement.ts on lines 79..81
      src/AbstractElement.ts on lines 88..90
      src/AbstractElement.ts on lines 97..99
      src/AbstractElement.ts on lines 106..108
      src/AbstractElement.ts on lines 124..126
      src/AbstractElement.ts on lines 133..135

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

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

          public addParentConnectorNeighbour(id: Common.Guid): void {
              this.parentConnectorNeighbours[id.toString()] = id;
          }
      Severity: Major
      Found in src/AbstractElement.ts and 6 other locations - About 40 mins to fix
      src/AbstractElement.ts on lines 79..81
      src/AbstractElement.ts on lines 88..90
      src/AbstractElement.ts on lines 97..99
      src/AbstractElement.ts on lines 115..117
      src/AbstractElement.ts on lines 124..126
      src/AbstractElement.ts on lines 133..135

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

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

          public addChildModelNeighbour(id: Common.Guid): void {
              this.childModelNeighbours[id.toString()] = id;
          }
      Severity: Major
      Found in src/AbstractElement.ts and 6 other locations - About 40 mins to fix
      src/AbstractElement.ts on lines 79..81
      src/AbstractElement.ts on lines 88..90
      src/AbstractElement.ts on lines 97..99
      src/AbstractElement.ts on lines 106..108
      src/AbstractElement.ts on lines 115..117
      src/AbstractElement.ts on lines 124..126

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

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

          public addChildEdgeNeighbour(id: Common.Guid): void {
              this.childEdgeNeighbours[id.toString()] = id;
          }
      Severity: Major
      Found in src/AbstractElement.ts and 6 other locations - About 40 mins to fix
      src/AbstractElement.ts on lines 79..81
      src/AbstractElement.ts on lines 88..90
      src/AbstractElement.ts on lines 106..108
      src/AbstractElement.ts on lines 115..117
      src/AbstractElement.ts on lines 124..126
      src/AbstractElement.ts on lines 133..135

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

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

          public addParentModelNeighbour(id: Common.Guid): void {
              this.parentModelNeighbours[id.toString()] = id;
          }
      Severity: Major
      Found in src/AbstractElement.ts and 6 other locations - About 40 mins to fix
      src/AbstractElement.ts on lines 79..81
      src/AbstractElement.ts on lines 88..90
      src/AbstractElement.ts on lines 97..99
      src/AbstractElement.ts on lines 106..108
      src/AbstractElement.ts on lines 115..117
      src/AbstractElement.ts on lines 133..135

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

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

          public addChildNodeNeighbour(id: Common.Guid): void {
              this.childNodeNeighbours[id.toString()] = id;
          }
      Severity: Major
      Found in src/AbstractElement.ts and 6 other locations - About 40 mins to fix
      src/AbstractElement.ts on lines 88..90
      src/AbstractElement.ts on lines 97..99
      src/AbstractElement.ts on lines 106..108
      src/AbstractElement.ts on lines 115..117
      src/AbstractElement.ts on lines 124..126
      src/AbstractElement.ts on lines 133..135

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

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

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

              for (let parentNodeId of parentNodes) {
                  let parentNode = graph.getElement(parentNodeId);
                  parentNode.unlinkChildModelNeighbour(this.id);
              }
      Severity: Minor
      Found in src/ModelElement.ts and 2 other locations - About 30 mins to fix
      src/EdgeElement.ts on lines 54..57
      src/EdgeElement.ts on lines 60..63

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

      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 addStartConnector(connectorId: Common.Guid) {
              this.start = connectorId;
              this.addParentConnectorNeighbour(connectorId);
          }
      Severity: Minor
      Found in src/EdgeElement.ts and 1 other location - About 30 mins to fix
      src/EdgeElement.ts on lines 44..47

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

      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 addEndConnector(connectorId: Common.Guid) {
              this.end = connectorId;
              this.addParentConnectorNeighbour(connectorId);
          }
      Severity: Minor
      Found in src/EdgeElement.ts and 1 other location - About 30 mins to fix
      src/EdgeElement.ts on lines 34..37

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

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

              for (let modelId of modelIds) {
                  let model = graph.getElement(modelId);
                  model.unlinkChildEdgeNeighbour(this.id);
              }
      Severity: Minor
      Found in src/EdgeElement.ts and 2 other locations - About 30 mins to fix
      src/EdgeElement.ts on lines 54..57
      src/ModelElement.ts on lines 35..38

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

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

              for (let connectorId of connectorIds) {
                  let connector = graph.getElement(connectorId);
                  connector.unlinkChildEdgeNeighbour(this.id);
              }
      Severity: Minor
      Found in src/EdgeElement.ts and 2 other locations - About 30 mins to fix
      src/EdgeElement.ts on lines 60..63
      src/ModelElement.ts on lines 35..38

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

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

      Fenced code blocks should be surrounded by blank lines
      Open

      ```bash
      Severity: Info
      Found in README.md by markdownlint

      MD031 - Fenced code blocks should be surrounded by blank lines

      Tags: code, blank_lines

      Aliases: blanks-around-fences

      This rule is triggered when fenced code blocks are either not preceded or not followed by a blank line:

      Some text
      ```
      Code block
      ```
      
      ```
      Another code block
      ```
      Some more text

      To fix this, ensure that all fenced code blocks have a blank line both before and after (except where the block is at the beginning or end of the document):

      Some text
      
      ```
      Code block
      ```
      
      ```
      Another code block
      ```
      
      Some more text

      Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse fenced code blocks that don't have blank lines before and after them.

      Severity
      Category
      Status
      Source
      Language