conveyal/transitive.js

View on GitHub

Showing 105 of 165 total issues

File edge.js has 630 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { forEach } from 'lodash'

import {
  ccw,
  distance,
Severity: Major
Found in lib/graph/edge.js - About 1 day to fix

    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

      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

        Edge has 42 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default class Edge {
          /**
           * Initialize a new edge
           * @constructor
           * @param {Point[]} pointArray - the internal Points for this Edge
        Severity: Minor
        Found in lib/graph/edge.js - About 5 hrs 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

          File labeler.js has 327 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { forEach } from 'lodash'
          import measureText from 'measure-text'
          import d3 from 'd3' // TODO: replace w/ other quadtree library
          
          import { getFontSizeWithUnit } from '../util'
          Severity: Minor
          Found in lib/labeler/labeler.js - About 3 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 getRenderCoords has 89 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                getRenderCoords(fromOffsetPx, toOffsetPx, display, forward) {
                  const isBase = fromOffsetPx === 0 && toOffsetPx === 0
              
                  if (!this.baseRenderCoords && !isBase) {
                    this.calculateBaseRenderCoords(display)
              Severity: Major
              Found in lib/graph/edge.js - About 3 hrs to fix

                Point has 29 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export default class Point {
                  constructor(data) {
                    for (const key in data) {
                      this[key] = data[key]
                    }
                Severity: Minor
                Found in lib/point/point.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

                    File transitive.ts has 297 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    /* eslint-disable camelcase */ // FIXME remove camel case
                    /* globals Display */
                    
                    import d3 from 'd3'
                    import Emitter from 'component-emitter'
                    Severity: Minor
                    Found in lib/transitive.ts - About 3 hrs to fix

                      Function addSegmentsToQuadtree has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        addSegmentsToQuadtree() {
                          forEach(this.transitive.renderSegments, (segment) => {
                            if (segment.getType() !== 'TRANSIT') return
                      
                            let lw = this.transitive.style.compute(
                      Severity: Major
                      Found in lib/labeler/labeler.js - About 2 hrs to fix

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

                          constructMergedMarker(display) {
                            const dataArray = this.getRenderDataArray()
                            const xValues = []
                            const yValues = []
                            dataArray.forEach(function (data) {
                        Severity: Major
                        Found in lib/point/point.js - About 2 hrs to fix

                          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 constructor has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              constructor(data, network) {
                                this.network = network
                            
                                for (const key in data) {
                                  this[key] = data[key]
                            Severity: Major
                            Found in lib/core/journey.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

                                File styles.js has 277 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import d3 from 'd3'
                                
                                /**
                                 * Scales for utility functions to use
                                 */
                                Severity: Minor
                                Found in lib/styler/styles.js - About 2 hrs to fix

                                  Function getBBox has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    getBBox() {
                                      if (this.orientation === 'E') {
                                        return {
                                          height: this.textHeight,
                                          width: this.textWidth,
                                  Severity: Major
                                  Found in lib/labeler/pointlabel.js - About 2 hrs to fix

                                    Function calculateGeometry has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      calculateGeometry(cellSize, angleConstraint) {
                                        // if(!this.hasTransit()) angleConstraint = 5;
                                        angleConstraint = angleConstraint || 45
                                    
                                        this.angleConstraintR = (angleConstraint * Math.PI) / 180
                                    Severity: Minor
                                    Found in lib/graph/edge.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 getRenderCoords has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      getRenderCoords(fromOffsetPx, toOffsetPx, display, forward) {
                                        const isBase = fromOffsetPx === 0 && toOffsetPx === 0
                                    
                                        if (!this.baseRenderCoords && !isBase) {
                                          this.calculateBaseRenderCoords(display)
                                    Severity: Minor
                                    Found in lib/graph/edge.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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language