conveyal/transitive.js

View on GitHub

Showing 105 of 165 total issues

Function lineIntersection has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

function lineIntersection(x1, y1, x2, y2, x3, y3, x4, y4) {
Severity: Major
Found in lib/util/index.js - About 1 hr to fix

    Function rayIntersection has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function rayIntersection(ax, ay, avx, avy, bx, by, bvx, bvy) {
    Severity: Major
    Found in lib/util/index.js - About 1 hr to fix

      Function componentDidUpdate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        componentDidUpdate(prevProps) {
          // Check if we received new transitive data
          if (
            this.transitive &&
            !isEqual(prevProps.transitiveData, this.props.transitiveData)
      Severity: Minor
      Found in stories/transitive-overlay.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 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 setOrientation has a Cognitive Complexity of 9 (exceeds 5 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 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 computeDomainsFromBounds has a Cognitive Complexity of 9 (exceeds 5 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: Minor
      Found in lib/display/display.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 decode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export function decode(polyline) {
        let currentPosition = 0
      
        let currentLat = 0
        let currentLng = 0
      Severity: Minor
      Found in lib/util/polyline.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 calculateWorldLengthAndMidpoint has a Cognitive Complexity of 8 (exceeds 5 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 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

      Function ccw has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function ccw(ax, ay, bx, by, cx, cy) {
      Severity: Minor
      Found in lib/util/index.js - About 45 mins to fix

        Function getBBox has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          getBBox() {
            if (this.orientation === 'E') {
              return {
                height: this.textHeight,
                width: this.textWidth,
        Severity: Minor
        Found in lib/labeler/pointlabel.js - 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

        Function ccwRaw has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function ccwRaw(ax, ay, bx, by, cx, cy) {
        Severity: Minor
        Found in lib/util/index.js - About 45 mins to fix

          Function angleFromThreePoints has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function angleFromThreePoints(ax, ay, bx, by, cx, cy) {
          Severity: Minor
          Found in lib/util/index.js - About 45 mins to fix

            Function constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              constructor(options: TransitiveOptions) {
                if (!(this instanceof Transitive)) return new Transitive(options)
            
                this.options = options
                if (this.options.zoomEnabled === undefined) this.options.zoomEnabled = true
            Severity: Minor
            Found in lib/transitive.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

            Consider simplifying this complex logical expression.
            Open

                if (!p1 || !p2 || !v1 || !v2 || (p1.x === p2.x && p1.y === p2.y)) return
            Severity: Major
            Found in lib/renderer/renderededge.js - About 40 mins to fix

              Function equalVectors has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function equalVectors(x1, y1, x2, y2, tol) {
              Severity: Minor
              Found in lib/graph/edge.js - About 35 mins to fix

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

                  load(styles) {
                    for (const i in types) {
                      const type = types[i]
                      if (styles[type]) {
                        for (const key in styles[type]) {
                Severity: Minor
                Found in lib/styler/styler.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

                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

                Function updateActiveZoomFactors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  updateActiveZoomFactors(scale) {
                    let updated = false
                    for (let i = 0; i < this.zoomFactors.length; i++) {
                      const min = this.zoomFactors[i].minScale
                      const max =
                Severity: Minor
                Found in lib/display/display.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

                Function reset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  reset() {
                    for (const i in types) {
                      const type = types[i]
                      this[type] = Object.assign({}, styles[type] || {})
                      for (const key in this[type]) {
                Severity: Minor
                Found in lib/styler/styler.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

                Function drawText has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  drawText(text, anchor, attrs) {
                    // For equivalence w/ SVG text rendering
                    this.ctx.textBaseline = 'top'
                
                    this.ctx.font = `${attrs['font-size'] || '14px'} ${
                Severity: Minor
                Found in lib/display/canvas-display.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

                Severity
                Category
                Status
                Source
                Language