conveyal/transitive.js

View on GitHub

Showing 165 of 165 total issues

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

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

        addPathSegment(pathSegment) {
          if (!this.pathSegments) this.pathSegments = []
          if (this.pathSegments.indexOf(pathSegment) !== -1) return
          this.pathSegments.push(pathSegment)
      
      
      Severity: Major
      Found in lib/renderer/renderededge.js and 1 other location - About 2 hrs to fix
      lib/renderer/renderededge.js on lines 30..37

      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 92.

      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

        addPattern(pattern) {
          if (!this.patterns) this.patterns = []
          if (this.patterns.indexOf(pattern) !== -1) return
          this.patterns.push(pattern)
      
      
      Severity: Major
      Found in lib/renderer/renderededge.js and 1 other location - About 2 hrs to fix
      lib/renderer/renderededge.js on lines 39..46

      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 92.

      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 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 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 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

            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

              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 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

                  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 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

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

                      intersects(obj) {
                        if (obj instanceof Label) {
                          // todo: handle label-label intersection for diagonally placed labels separately
                          return this.intersectsBBox(obj.getBBox())
                        } else if (obj.x && obj.y && obj.width && obj.height) {
                    Severity: Major
                    Found in lib/labeler/segmentlabel.js and 1 other location - About 2 hrs to fix
                    lib/labeler/pointlabel.js on lines 231..240

                    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 85.

                    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

                      intersects(obj) {
                        if (obj instanceof Label) {
                          // todo: handle label-label intersection for diagonally placed labels separately
                          return this.intersectsBBox(obj.getBBox())
                        } else if (obj.x && obj.y && obj.width && obj.height) {
                    Severity: Major
                    Found in lib/labeler/pointlabel.js and 1 other location - About 2 hrs to fix
                    lib/labeler/segmentlabel.js on lines 116..125

                    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 85.

                    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 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

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

                        color: [
                          '#fff', // Text color falls back on white.
                          function (display, segment) {
                            if (segment.type === 'TRANSIT') {
                              if (segment.patterns) {
                      Severity: Major
                      Found in lib/styler/styles.js and 1 other location - About 2 hrs to fix
                      lib/styler/styles.js on lines 211..221

                      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 84.

                      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

                        background: [
                          '#008', // Background color falls back on dark blue.
                          function (display, segment) {
                            if (segment.type === 'TRANSIT') {
                              if (segment.patterns) {
                      Severity: Major
                      Found in lib/styler/styles.js and 1 other location - About 2 hrs to fix
                      lib/styler/styles.js on lines 222..232

                      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 84.

                      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 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

                        Severity
                        Category
                        Status
                        Source
                        Language