railpage/railpagecore

View on GitHub
lib/GTFS/StandardRoute.php

Summary

Maintainability
D
1 day
Test Coverage

Method getPath has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getPath() {
        $mckey = sprintf("railpage:gtfs.path;provider=%s;route=%s", $this->Provider->getProviderName(), $this->short_name);
        
        $Memcached = AppCore::GetMemcached(); 
        
Severity: Minor
Found in lib/GTFS/StandardRoute.php - About 1 hr to fix

    Method __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct($routeId = null, $gtfsProvider = null) {
            
            if (function_exists("getRailpageConfig")) {
                $this->Config = getRailpageConfig();
            }
    Severity: Minor
    Found in lib/GTFS/StandardRoute.php - About 1 hr to fix

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

          public function getPath() {
              $mckey = sprintf("railpage:gtfs.path;provider=%s;route=%s", $this->Provider->getProviderName(), $this->short_name);
              
              $Memcached = AppCore::GetMemcached(); 
              
      Severity: Minor
      Found in lib/GTFS/StandardRoute.php - 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

      Avoid assigning values to variables in if clauses and the like (line '135', column '13').
      Open

          public function getPath() {
              $mckey = sprintf("railpage:gtfs.path;provider=%s;route=%s", $this->Provider->getProviderName(), $this->short_name);
              
              $Memcached = AppCore::GetMemcached(); 
              
      Severity: Minor
      Found in lib/GTFS/StandardRoute.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

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

              $this->adapter = new Adapter(array(
                  "driver" => "Mysqli",
                  "database" => $this->Config->GTFS->PTV->db_name,
                  "username" => $this->Config->GTFS->PTV->db_user,
                  "password" => $this->Config->GTFS->PTV->db_pass,
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 2 other locations - About 3 hrs to fix
      lib/GTFS/AU/VIC/PTV/PTV.php on lines 192..198
      lib/GTFS/StandardProvider.php on lines 66..72

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

      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 3 locations. Consider refactoring.
      Open

              $query = sprintf("SELECT id, service_id, trip_id, trip_headsign, shape_id, meta FROM %s_trips WHERE route_id = '%s'", $this->Provider->getDbPrefix(), $this->short_name);
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 2 other locations - About 50 mins to fix
      lib/GTFS/StandardRoute.php on lines 131..131
      lib/GTFS/StandardRoute.php on lines 139..139

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

      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 3 locations. Consider refactoring.
      Open

              $query = sprintf("SELECT id, service_id, trip_id, trip_headsign, shape_id, meta FROM %s_trips WHERE route_id = '%s' LIMIT 1", $this->Provider->getDbPrefix(), $this->short_name);
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 2 other locations - About 50 mins to fix
      lib/GTFS/StandardRoute.php on lines 99..99
      lib/GTFS/StandardRoute.php on lines 131..131

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

      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 3 locations. Consider refactoring.
      Open

              $mckey = sprintf("railpage:gtfs.path;provider=%s;route=%s", $this->Provider->getProviderName(), $this->short_name);
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 2 other locations - About 50 mins to fix
      lib/GTFS/StandardRoute.php on lines 99..99
      lib/GTFS/StandardRoute.php on lines 139..139

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

      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 3 locations. Consider refactoring.
      Open

              if (function_exists("getRailpageConfig")) {
                  $this->Config = getRailpageConfig();
              }
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 2 other locations - About 45 mins to fix
      lib/GTFS/AU/VIC/PTV/PTV.php on lines 184..186
      lib/Graphite/Graph.php on lines 69..71

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

      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 7 locations. Consider refactoring.
      Open

              $result = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 6 other locations - About 30 mins to fix
      lib/GTFS/AU/VIC/PTV/PTV.php on lines 344..344
      lib/GTFS/StandardProvider.php on lines 136..136
      lib/GTFS/StandardProvider.php on lines 180..180
      lib/GTFS/StandardRoute.php on lines 103..103
      lib/GTFS/StandardRoute.php on lines 141..141
      lib/GTFS/StandardRoute.php on lines 160..160

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

      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 7 locations. Consider refactoring.
      Open

              $result = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 6 other locations - About 30 mins to fix
      lib/GTFS/AU/VIC/PTV/PTV.php on lines 344..344
      lib/GTFS/StandardProvider.php on lines 136..136
      lib/GTFS/StandardProvider.php on lines 180..180
      lib/GTFS/StandardRoute.php on lines 74..74
      lib/GTFS/StandardRoute.php on lines 103..103
      lib/GTFS/StandardRoute.php on lines 160..160

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

      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 7 locations. Consider refactoring.
      Open

              $result = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 6 other locations - About 30 mins to fix
      lib/GTFS/AU/VIC/PTV/PTV.php on lines 344..344
      lib/GTFS/StandardProvider.php on lines 136..136
      lib/GTFS/StandardProvider.php on lines 180..180
      lib/GTFS/StandardRoute.php on lines 74..74
      lib/GTFS/StandardRoute.php on lines 141..141
      lib/GTFS/StandardRoute.php on lines 160..160

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

      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 7 locations. Consider refactoring.
      Open

              $result = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 6 other locations - About 30 mins to fix
      lib/GTFS/AU/VIC/PTV/PTV.php on lines 344..344
      lib/GTFS/StandardProvider.php on lines 136..136
      lib/GTFS/StandardProvider.php on lines 180..180
      lib/GTFS/StandardRoute.php on lines 74..74
      lib/GTFS/StandardRoute.php on lines 103..103
      lib/GTFS/StandardRoute.php on lines 141..141

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

      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 9 locations. Consider refactoring.
      Open

              if (!filter_var($routeId, FILTER_VALIDATE_INT)) {
                  return;
              }
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 8 other locations - About 30 mins to fix
      lib/Chronicle/Entry.php on lines 140..142
      lib/Chronicle/EntryType.php on lines 80..82
      lib/Events/EventDate.php on lines 143..145
      lib/Feedback/FeedbackItem.php on lines 120..122
      lib/GTFS/StandardStop.php on lines 97..99
      lib/Ideas/Ideas.php on lines 185..187
      lib/Images/Camera.php on lines 98..100
      lib/Users/Group.php on lines 127..129

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

      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 6 locations. Consider refactoring.
      Open

              if (is_object($gtfsProvider)) {
                  $this->Provider = $gtfsProvider;
              }
      Severity: Major
      Found in lib/GTFS/StandardRoute.php and 5 other locations - About 30 mins to fix
      lib/Jobs/Scraper.php on lines 73..75
      lib/Jobs/Scraper.php on lines 77..79
      lib/News/Scraper.php on lines 70..72
      lib/News/Scraper.php on lines 74..76
      lib/Users/User.php on lines 1448..1450

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

      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 closing brace must go on the next line following the body; found 1 blank lines before brace
      Open

          }
      Severity: Minor
      Found in lib/GTFS/StandardRoute.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status