railpage/railpagecore

View on GitHub

Showing 708 of 9,214 total issues

Function StopsNearLocation has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function StopsNearLocation($latitude = null, $longitude = null) {
        if ($latitude == null) {
            throw new Exception("Cannot fetch " . __METHOD__ . " - no latitude given");
        }
        
Severity: Minor
Found in lib/GTFS/AU/VIC/PTV/PTV.php - 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

File Template.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Templating engine
 * Simple wrapper for Smarty, in this case allowing for subthemes (eg handheld, kiosk, etc)
Severity: Minor
Found in lib/Template.php - About 2 hrs to fix

    Method fetchOld has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function fetchOld() {
    
            if (!is_string($this->feed)) {
                throw new Exception("Cannot fetch jobs from RSS feed because no RSS feed was provided");
            }
    Severity: Major
    Found in lib/Jobs/Scraper.php - About 2 hrs to fix

      Method load has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function load($option = null) {
      
              Debug::RecordInstance();
      
              $this->mckey = sprintf("railpage:image=%d", $this->id);
      Severity: Major
      Found in lib/Images/Image.php - About 2 hrs to fix

        Method getImage has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getImage($id, $force = 0) {
                $params = array(
                    "ImageKey" => $id
                );
                
        Severity: Major
        Found in lib/Images/Provider/SmugMug.php - About 2 hrs to fix

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

              public function __construct($postid = false) {
                  $post_timer_start = Debug::GetTimer(); 
                  
                  parent::__construct();
                  
          Severity: Major
          Found in lib/Forums/Post.php - About 2 hrs to fix

            Method load has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function load() {
                    $photodata = $this->Provider->getPhoto($this->id);
                            
                    $this->title = $photodata['title'];
                    $this->description = $photodata['description'];
            Severity: Major
            Found in lib/Railcams/Photo.php - About 2 hrs to fix

              Method LatLonWoELookup has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function LatLonWoELookup($lat, $lon, $force = false) {
                      
                      if (is_null($lon) && strpos($lat, ",") !== false) {
                          $tmp = explode(",", $lat); 
                          $lat = $tmp[0];
              Severity: Major
              Found in lib/PlaceUtility.php - About 2 hrs to fix

                File MultimediaUtility.php has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                /**
                 * Multimedia formatter
                 * @since Version 3.10.0
                Severity: Minor
                Found in lib/Formatting/MultimediaUtility.php - About 2 hrs to fix

                  Method getTimeline has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getTimeline() {
                          $query = "SELECT d.*, lu.loco_num, ld.loco_date_text FROM loco_unit_date AS d INNER JOIN loco_date_type AS ld ON ld.loco_date_id = d.loco_date_id INNER JOIN loco_unit AS lu ON lu.loco_id = d.loco_unit_id WHERE lu.class_id = ? ORDER BY timestamp ASC";
                          
                          $return = array(
                              "timeline" => array(
                  Severity: Major
                  Found in lib/Locos/LocoClass.php - About 2 hrs to fix

                    Method tagLoco has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function tagLoco(Locomotive $Loco) {
                            
                            if (!filter_var($Loco->id, FILTER_VALIDATE_INT)) {
                                throw new Exception("An invalid instance of Railpage\\Locos\\Locomotive was supplied");
                            }
                    Severity: Major
                    Found in lib/Railcams/Photo.php - About 2 hrs to fix

                      Thread has 22 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Thread extends Forums {
                          
                          /**
                           * Thread ID
                           * @since Version 3.0.1
                      Severity: Minor
                      Found in lib/Forums/Thread.php - About 2 hrs to fix

                        Method createSlug has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                public function createSlug($story_id = false) {
                                    if (RP_DEBUG) {
                                        global $site_debug;
                                        $debug_timer_start = microtime(true);
                                    }
                        Severity: Major
                        Found in lib/News/Base.php - About 2 hrs to fix

                          Method commit has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function commit() {
                                  $this->validate();
                                  
                                  $timer = Debug::getTimer();
                                  
                          Severity: Major
                          Found in lib/Locos/LocoClass.php - About 2 hrs to fix

                            Method newPosts has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function newPosts($forums = false, $from_time = false, $items_per_page = 25, $start = 0) {
                                    if (!$forums || !is_array($forums)) {
                                        throw new \Exception("You must provide a list of forums this user has permission to view");
                                        return false;
                                    }
                            Severity: Major
                            Found in lib/Forums/Forums.php - About 2 hrs to fix

                              Method validatePassword has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function validatePassword($password = false, $username = false) {
                                      
                                      Utility\PasswordUtility::validateParameters($password, $username, $this); 
                              
                                      /**
                              Severity: Major
                              Found in lib/Users/User.php - About 2 hrs to fix

                                Method unBanUser has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function unBanUser($banId, $userId = null) {
                                        $success = false;
                                        
                                        /**
                                         * Empty the cache
                                Severity: Major
                                Found in lib/BanControl/BanControl.php - About 2 hrs to fix

                                  Function getAddress has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function getAddress() {
                                          
                                          $mckey = sprintf("railpage.place.address.lat=%s&lon=%s", $this->lat, $this->lon);
                                          
                                          if ($address = $this->Memcached->fetch($mckey)) {
                                  Severity: Minor
                                  Found in lib/Place.php - 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 autoPopulateNextComp has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function autoPopulateNextComp() {
                                          $month = new DateTime("first day of next month"); 
                                          
                                          $title = $month->format("F Y");
                                          
                                  Severity: Minor
                                  Found in lib/Images/Competitions.php - 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 getStylesheets has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function getStylesheets() {
                                          $tags = array(); 
                                          
                                          $minify = array(); 
                                          
                                  Severity: Minor
                                  Found in lib/Template.php - 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