conveyal/transitive.js

View on GitHub

Showing 165 of 165 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    } else {
      // x-axis limiting
      padding = paddingFactor * xRange
      dispX1 = xmin - padding
      dispX2 = xmax + padding
Severity: Major
Found in lib/display/display.js and 1 other location - About 1 day to fix
lib/display/display.js on lines 167..184

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 260.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (usableDisplayAspect > graphAspect) {
      // y-axis is limiting
      padding = paddingFactor * yRange
      dispY1 = ymin - padding
      dispY2 = ymax + padding
Severity: Major
Found in lib/display/display.js and 1 other location - About 1 day to fix
lib/display/display.js on lines 184..201

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 260.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      adjustFromAngle() {
        const isCcw = ccw(
          this.tx,
          this.ty,
          this.tx + this.tvx,
    Severity: Major
    Found in lib/graph/edge.js and 1 other location - About 1 day to fix
    lib/graph/edge.js on lines 259..282

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 254.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      adjustToAngle() {
        const isCcw = ccw(
          this.fx,
          this.fy,
          this.fx + this.fvx,
    Severity: Major
    Found in lib/graph/edge.js and 1 other location - About 1 day to fix
    lib/graph/edge.js on lines 289..312

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 254.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

          computeLineWidth(display, includeEnvelope) {
            const styler = display.styler
            if (styler && display) {
              // compute the line width
              const env = styler.compute(styler.segments.envelope, display, this)
        Severity: Major
        Found in lib/renderer/renderededge.js and 1 other location - About 6 hrs to fix
        lib/renderer/renderedsegment.js on lines 94..110

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 157.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

          computeLineWidth(display, includeEnvelope) {
            const styler = display.styler
            if (styler && display) {
              // compute the line width
              const env = styler.compute(styler.segments.envelope, display, this)
        Severity: Major
        Found in lib/renderer/renderedsegment.js and 1 other location - About 6 hrs to fix
        lib/renderer/renderededge.js on lines 169..185

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 157.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              _setTransform: function (el, offset, scale) {
                  var pos = offset || new L.Point(0, 0);
          
                  el.style[L.DomUtil.TRANSFORM] =
                      (L.Browser.ie3d ?
          Severity: Major
          Found in stories/leaflet-canvas-layer.js and 1 other location - About 4 hrs to fix
          stories/leaflet-canvas-layer.js on lines 12..20

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 132.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          L.DomUtil.setTransform = L.DomUtil.setTransform || function (el, offset, scale) {
              var pos = offset || new L.Point(0, 0);
          
              el.style[L.DomUtil.TRANSFORM] =
                  (L.Browser.ie3d ?
          Severity: Major
          Found in stories/leaflet-canvas-layer.js and 1 other location - About 4 hrs to fix
          stories/leaflet-canvas-layer.js on lines 143..151

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 132.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    if (i > 0) {
                      const prevCoord = geomCoords[i - 1]
                      const x0 = display.xScale.compute(prevCoord[0])
                      const y0 = display.yScale.compute(prevCoord[1])
                      if (x1 === x0 && y1 === y0) return
              Severity: Major
              Found in lib/graph/edge.js and 1 other location - About 3 hrs to fix
              lib/graph/edge.js on lines 479..489

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    if (i < geomCoords.length - 1) {
                      const nextCoord = geomCoords[i + 1]
                      const x2 = display.xScale.compute(nextCoord[0])
                      const y2 = display.yScale.compute(nextCoord[1])
                      if (x2 === x1 && y2 === y1) return
              Severity: Major
              Found in lib/graph/edge.js and 1 other location - About 3 hrs to fix
              lib/graph/edge.js on lines 466..476

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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
                    Severity
                    Category
                    Status
                    Source
                    Language