conveyal/transitive.js

View on GitHub
lib/core/network.js

Summary

Maintainability
D
2 days
Test Coverage

File network.js has 464 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { forEach } from 'lodash'
import Emitter from 'component-emitter'

import Stop from '../point/stop'
import Place from '../point/place'
Severity: Minor
Found in lib/core/network.js - About 7 hrs to fix

    Function load has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      load(data) {
        debug('loading', data)
    
        // check data
        if (!data) data = {}
    Severity: Major
    Found in lib/core/network.js - About 3 hrs to fix

      Function populateGraphEdges has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        populateGraphEdges() {
          // vertex associated with the last vertex point we passed in this sequence
          let lastVertex = null
      
          // collection of 'internal' (i.e. non-vertex) points passed
      Severity: Major
      Found in lib/core/network.js - About 3 hrs to fix

        Function load has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          load(data) {
            debug('loading', data)
        
            // check data
            if (!data) data = {}
        Severity: Minor
        Found in lib/core/network.js - About 2 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 createInternalVertexPoints has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          createInternalVertexPoints() {
            this.internalVertexPoints = []
        
            for (const i in this.graph.edgeGroups) {
              const edgeGroup = this.graph.edgeGroups[i]
        Severity: Minor
        Found in lib/core/network.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 annotateTransitPoints has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          annotateTransitPoints() {
            this.paths.forEach(function (path) {
              const transitSegments = []
              path.segments.forEach(function (pathSegment) {
                if (pathSegment.type === 'TRANSIT') transitSegments.push(pathSegment)
        Severity: Minor
        Found in lib/core/network.js - About 1 hr to fix

          Function createRenderedEdge has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            createRenderedEdge(pathSegment, gEdge, forward, patterns) {
              let rEdge
          
              // construct the edge key, disregarding mode qualifiers (e.g. "_RENT")
              const type = pathSegment.getType().split('_')[0]
          Severity: Minor
          Found in lib/core/network.js - About 1 hr to fix

            Function createRenderedSegments has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              createRenderedSegments() {
                this.reLookup = {}
                this.renderedEdges = []
                this.renderedSegments = []
            
            
            Severity: Minor
            Found in lib/core/network.js - About 1 hr to fix

              Function createInternalVertexPoints has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                createInternalVertexPoints() {
                  this.internalVertexPoints = []
              
                  for (const i in this.graph.edgeGroups) {
                    const edgeGroup = this.graph.edgeGroups[i]
              Severity: Minor
              Found in lib/core/network.js - About 1 hr to fix

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

                  createRenderedEdge(pathSegment, gEdge, forward, patterns) {
                    let rEdge
                
                    // construct the edge key, disregarding mode qualifiers (e.g. "_RENT")
                    const type = pathSegment.getType().split('_')[0]
                Severity: Minor
                Found in lib/core/network.js - 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

                There are no issues that match your filters.

                Category
                Status