conveyal/modeify

View on GitHub
client/components/conveyal/otp-profiler/master/index.js

Summary

Maintainability
F
3 days
Test Coverage

Function convertOtpData has 180 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Profiler.prototype.convertOtpData = function(opts) {
  var self = this;
  self.data = {
    journeys: [],
    patterns: [],
Severity: Major
Found in client/components/conveyal/otp-profiler/master/index.js - About 7 hrs to fix

    File index.js has 453 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var Batch = require('batch');
    var clone, each;
    var superagent = require('superagent');
    
    try {
    Severity: Minor
    Found in client/components/conveyal/otp-profiler/master/index.js - About 6 hrs to fix

      Function journey has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Profiler.prototype.journey = function(opts, callback) {
        var batch = new Batch();
        var profiler = this;
      
        // If a profile isn't passed, retrieve the profile
      Severity: Minor
      Found in client/components/conveyal/otp-profiler/master/index.js - About 1 hr to fix

        Function processBikeRentalSegment has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Profiler.prototype.processBikeRentalSegment = function(edges, from, to) {
          var self = this;
        
          var preWalkEdges = [], bikeRentalEdges = [], postWalkEdges = [];
          var currentLeg = preWalkEdges;
        Severity: Minor
        Found in client/components/conveyal/otp-profiler/master/index.js - About 1 hr to fix

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

          Profiler.prototype.convertOtpData = function(opts) {
            var self = this;
            self.data = {
              journeys: [],
              patterns: [],
          Severity: Minor
          Found in client/components/conveyal/otp-profiler/master/index.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 processBikeRentalSegment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          Profiler.prototype.processBikeRentalSegment = function(edges, from, to) {
            var self = this;
          
            var preWalkEdges = [], bikeRentalEdges = [], postWalkEdges = [];
            var currentLeg = preWalkEdges;
          Severity: Minor
          Found in client/components/conveyal/otp-profiler/master/index.js - About 25 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 routes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          Profiler.prototype.routes = function(callback) {
            if (store.routes !== null) {
              callback(null, store.routes);
            } else {
              this.request('/index/routes', function(err, routes) {
          Severity: Minor
          Found in client/components/conveyal/otp-profiler/master/index.js - About 25 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 pattern has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          Profiler.prototype.pattern = function(id, callback) {
            if (store.patterns[id]) {
              callback(null, store.patterns[id]);
            } else {
              this.request('/index/patterns/' + encodeURIComponent(id), function(err,
          Severity: Minor
          Found in client/components/conveyal/otp-profiler/master/index.js - About 25 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

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

                  if(pattern.routeId in routePatterns) { // if we already have a pattern for this route
                    // replace the existing pattern only if the new one has more trips
                    if(segmentPattern.nTrips > routePatterns[pattern.routeId].nTrips) {
                      routePatterns[pattern.routeId] = segmentPattern;
                    }
          Severity: Major
          Found in client/components/conveyal/otp-profiler/master/index.js and 1 other location - About 2 hrs to fix
          lib/plan/profile-to-transitive.js on lines 72..79

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

          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

                  if (alightStop.id !== boardStop.id) {
                    journey.segments.push({
                      type: 'WALK',
                      from: {
                        type: 'STOP',
          Severity: Major
          Found in client/components/conveyal/otp-profiler/master/index.js and 1 other location - About 2 hrs to fix
          lib/plan/profile-to-transitive.js on lines 98..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 80.

          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

          function getGtfsRouteType(mode) {
            switch (mode) {
              case 'TRAM':
                return 0;
              case 'SUBWAY':
          Severity: Major
          Found in client/components/conveyal/otp-profiler/master/index.js and 1 other location - About 1 hr to fix
          lib/plan/profile-to-transitive.js on lines 290..309

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

          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 (opts.from) {
              self.data.places.push({
                place_id: 'from',
                place_name: opts.from.name,
                place_lat: opts.from.lat,
          Severity: Major
          Found in client/components/conveyal/otp-profiler/master/index.js and 1 other location - About 1 hr to fix
          client/components/conveyal/otp-profiler/master/index.js on lines 184..191

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

          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 (opts.to) {
              self.data.places.push({
                place_id: 'to',
                place_name: opts.to.name,
                place_lat: opts.to.lat,
          Severity: Major
          Found in client/components/conveyal/otp-profiler/master/index.js and 1 other location - About 1 hr to fix
          client/components/conveyal/otp-profiler/master/index.js on lines 175..182

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

          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

                self.data.routes.push({
                  agency_id: route.agency,
                  route_id: route.id,
                  route_short_name: route.shortName,
                  route_long_name: route.longName,
          Severity: Major
          Found in client/components/conveyal/otp-profiler/master/index.js and 1 other location - About 1 hr to fix
          lib/plan/profile-to-transitive.js on lines 346..353

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

          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(edge.bikeRentalOnStation) {
                currentLeg = bikeRentalEdges;
                var onStation = self.addBikeRentalStation(edge.bikeRentalOnStation);
                onStationEndpoint = constructPlaceEndpoint(onStation.place_id);
              }
          Severity: Minor
          Found in client/components/conveyal/otp-profiler/master/index.js and 1 other location - About 50 mins to fix
          client/components/conveyal/otp-profiler/master/index.js on lines 386..390

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

          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(edge.bikeRentalOffStation) {
                currentLeg = postWalkEdges;
                var offStation = self.addBikeRentalStation(edge.bikeRentalOffStation);
                offStationEndpoint = constructPlaceEndpoint(offStation.place_id);
              }
          Severity: Minor
          Found in client/components/conveyal/otp-profiler/master/index.js and 1 other location - About 50 mins to fix
          client/components/conveyal/otp-profiler/master/index.js on lines 392..396

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

          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

          There are no issues that match your filters.

          Category
          Status