conveyal/transitive.js

View on GitHub

Showing 105 of 165 total issues

Function constructor has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor(transitive) {
    this.transitive = transitive

    this.clusters = []
    this.clusterLookup = {} // maps Point object to its containing cluster
Severity: Major
Found in lib/point/pointclustermap.js - About 2 hrs to fix

    Function refreshRenderData has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      refreshRenderData(display) {
        if (
          this.graphEdge.fromVertex.x === this.graphEdge.toVertex.x &&
          this.graphEdge.fromVertex.y === this.graphEdge.toVertex.y
        ) {
    Severity: Major
    Found in lib/renderer/renderededge.js - About 2 hrs to fix

      Function calculateGeometry has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        calculateGeometry(cellSize, angleConstraint) {
          // if(!this.hasTransit()) angleConstraint = 5;
          angleConstraint = angleConstraint || 45
      
          this.angleConstraintR = (angleConstraint * Math.PI) / 180
      Severity: Major
      Found in lib/graph/edge.js - About 2 hrs to fix

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

          intersect(rEdge) {
            // do no intersect adjacent edges of unequal bundle size
            if (
              this.graphEdge.renderedEdges.length !==
              rEdge.graphEdge.renderedEdges.length
        Severity: Minor
        Found in lib/renderer/renderededge.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 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 getGeometricCoords has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getGeometricCoords(fromOffsetPx, toOffsetPx, display, forward) {
            const coords = []
        
            // reverse the coords array if needed
            const geomCoords = forward
        Severity: Major
        Found in lib/graph/edge.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 render has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              render(display) {
                const text = this.getText()
                // Do not attempt to render label if there is no label text.
                if (!text) return null
                const x = this.labelAnchor.x - this.containerWidth / 2
            Severity: Major
            Found in lib/labeler/segmentlabel.js - About 2 hrs to fix

              Function computeDomainsFromBounds has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                computeDomainsFromBounds(bounds) {
                  const xmin = bounds[0][0]
                  const xmax = bounds[1][0]
                  const ymin = bounds[0][1]
                  const ymax = bounds[1][1]
              Severity: Major
              Found in lib/display/display.js - About 2 hrs to fix

                Function intersect has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  intersect(rEdge) {
                    // do no intersect adjacent edges of unequal bundle size
                    if (
                      this.graphEdge.renderedEdges.length !==
                      rEdge.graphEdge.renderedEdges.length
                Severity: Major
                Found in lib/renderer/renderededge.js - About 2 hrs to fix

                  Function placePointLabels has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    placePointLabels() {
                      const styler = this.transitive.styler
                  
                      const placedLabels = []
                      // var labeledPoints = []
                  Severity: Minor
                  Found in lib/labeler/labeler.js - About 2 hrs to fix

                    Function setOrientation has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      setOrientation(orientation) {
                        this.orientation = orientation
                    
                        const markerBBox = this.parent.getMarkerBBox()
                        if (!markerBBox) return
                    Severity: Minor
                    Found in lib/labeler/pointlabel.js - About 2 hrs to fix

                      Function placeSegmentLabels has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        placeSegmentLabels() {
                          this.placedLabelKeys = []
                          const placedLabels = []
                      
                          // collect the bus RenderSegments
                      Severity: Minor
                      Found in lib/labeler/labeler.js - About 1 hr to fix

                        Function getModeStyles has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          getModeStyles(mode, display) {
                            const modeStyles = {}
                        
                            // simulate a segment w/ the specified style
                            const segment = {
                        Severity: Minor
                        Found in lib/styler/styler.js - About 1 hr to fix

                          Function calculateWorldLengthAndMidpoint has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            calculateWorldLengthAndMidpoint() {
                              const allPoints = [this.fromVertex.point].concat(this.pointArray, [
                                this.toVertex.point
                              ])
                              this.worldLength = 0
                          Severity: Minor
                          Found in lib/graph/edge.js - About 1 hr 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 focusPath has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                focusPath(path) {
                                  let pathRenderedSegments = []
                                  const graph = this.transitive.network.graph
                              
                                  if (path) {
                              Severity: Minor
                              Found in lib/renderer/default-renderer.js - About 1 hr to fix

                                Function getModeStyles has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  getModeStyles(mode, display) {
                                    const modeStyles = {}
                                
                                    // simulate a segment w/ the specified style
                                    const segment = {
                                Severity: Minor
                                Found in lib/styler/styler.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 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 stroke has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    function (display, segment) {
                                      if (!segment.focused) return notFocusedColor
                                      if (segment.type === 'TRANSIT') {
                                        if (segment.patterns) {
                                          if (patternIsDcCirculatorBusRoute(segment.patterns[0])) return '#f00'
                                Severity: Minor
                                Found in lib/styler/styles.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

                                Severity
                                Category
                                Status
                                Source
                                Language