conveyal/transitive.js

View on GitHub
lib/graph/graph.js

Summary

Maintainability
F
3 days
Test Coverage

File graph.js has 510 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import d3 from 'd3'
import { forEach } from 'lodash'

import MultiPoint from '../point/multipoint'
import { ccw, isOutwardVector, sm } from '../util'
Severity: Major
Found in lib/graph/graph.js - About 1 day to fix

    Function apply2DOffsets has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

      apply2DOffsets() {
        this.initComparisons()
    
        const alignmentBundles = {} // maps alignment ID to array of range-bounded bundles on that alignment
    
    
    Severity: Minor
    Found in lib/graph/graph.js - About 3 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

    Function apply2DOffsets has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      apply2DOffsets() {
        this.initComparisons()
    
        const alignmentBundles = {} // maps alignment ID to array of range-bounded bundles on that alignment
    
    
    Severity: Major
    Found in lib/graph/graph.js - About 2 hrs to fix

      Function splitEdgeAtInternalPoints has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        splitEdgeAtInternalPoints(edge, points) {
          let subEdgePoints = []
          let newEdge
          const newEdgeInfoArr = []
          let fromVertex = edge.fromVertex
      Severity: Major
      Found in lib/graph/graph.js - About 2 hrs to fix

        Function mergeVertices has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          mergeVertices(vertexArray) {
            let xTotal = 0
            let yTotal = 0
        
            const vertexGroups = {
        Severity: Major
        Found in lib/graph/graph.js - About 2 hrs to fix

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

            initComparisons() {
              this.bundleComparisons = {}
          
              forEach(this.vertices, (vertex) => {
                const incidentGraphEdges = vertex.incidentEdges()
          Severity: Minor
          Found in lib/graph/graph.js - About 1 hr to fix

            Function mergeEdges has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              mergeEdges(edge1, edge2) {
                // check for infinite recursion loop case
                if (
                  edge1.fromVertex === edge2.toVertex &&
                  edge2.fromVertex === edge1.toVertex
            Severity: Minor
            Found in lib/graph/graph.js - About 1 hr to fix

              Function bounds has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                bounds() {
                  let xmax = null
                  let xmin = null
                  let ymax = null
                  let ymin = null
              Severity: Minor
              Found in lib/graph/graph.js - 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 mergeVertices has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                mergeVertices(vertexArray) {
                  let xTotal = 0
                  let yTotal = 0
              
                  const vertexGroups = {
              Severity: Minor
              Found in lib/graph/graph.js - About 55 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 mergeEdges has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                mergeEdges(edge1, edge2) {
                  // check for infinite recursion loop case
                  if (
                    edge1.fromVertex === edge2.toVertex &&
                    edge2.fromVertex === edge1.toVertex
              Severity: Minor
              Found in lib/graph/graph.js - 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

              Avoid too many return statements within this function.
              Open

                    if (a.point && a.point.getType() === 'STOP') return -1
              Severity: Major
              Found in lib/graph/graph.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      if (b.point && b.point.getType() === 'STOP') return 1
                Severity: Major
                Found in lib/graph/graph.js - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status