railpage/railpagecore

View on GitHub

Showing 1,011 of 9,214 total issues

Function newAPIKey has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function newAPIKey() {

        $len = 32;

        if (@is_readable('/dev/urandom')) {
Severity: Minor
Found in lib/Users/User.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 load has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function load() {

        if (!$row = $this->db->fetchRow("SELECT * FROM asset WHERE id = ?", $this->id)) {
            return;
        }
Severity: Minor
Found in lib/Assets/Asset.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 getHeadTags has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function getHeadTags() {
        $tags = array(); 
        
        if (count($this->rp_meta_tags)) {
            
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

Function cleanupBadHtml has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public static function cleanupBadHtml($string, $editorVersion = 1) {
        
        $timer = Debug::getTimer(); 
            
        if (is_string($string)) {
Severity: Minor
Found in lib/Formatting/Html.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 getRegions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        public function getRegions($country = false) {
            
            $timer = Debug::GetTimer();
            
            $return = false;
Severity: Minor
Found in lib/Locations/Locations.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 validate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function validate() {
        
        if ($this->class instanceof LocoClass && !$this->Class instanceof LocoClass) {
            $this->Class = &$this->class;
        }
Severity: Minor
Found in lib/Locos/Locomotive.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 fetch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function fetch($method = null, $parameters = array(), $other = array()) {
        if ($method == null && empty($parameters)) {
            throw new Exception("Cannot fetch API query - no API method defined");
        }
        
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

Function newPosts has a Cognitive Complexity of 16 (exceeds 5 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: Minor
Found in lib/Forums/Forums.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

Method validate has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function validate() {
        if (empty($this->title)) {
            throw new Exception("Competition title cannot be empty");
        }
        
Severity: Major
Found in lib/Images/Competition.php - About 2 hrs to fix

    Method cacheGeoData has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function cacheGeoData() {
    
            if (!$this->Place instanceof Place) {
                return $this;
            }
    Severity: Major
    Found in lib/Images/Image.php - About 2 hrs to fix

      Method send has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function send() {
              
              $this->validate();
              
              $data = array(
      Severity: Major
      Found in lib/PrivateMessages/Message.php - About 2 hrs to fix

        Method getRegions has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function getRegions($country = false) {
                    
                    $timer = Debug::GetTimer();
                    
                    $return = false;
        Severity: Major
        Found in lib/Locations/Locations.php - About 2 hrs to fix

          Method bulkAddLocos has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function bulkAddLocos($firstLoco = null, $lastLoco = null, $gaugeId = null, $statusId = null, $manufacturerId = null, $prefix = "") {
                  if ($firstLoco == null) {
                      throw new Exception("Cannot add locomotives to class - first loco number was not provided");
                  }
                  
          Severity: Major
          Found in lib/Locos/LocoClass.php - About 2 hrs to fix

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

                public function __construct($user = false) {
                    if (!$user || !($user instanceof \Railpage\Users\User)) {
                        throw new \Exception("Cannot instantiate " . __CLASS__ . "::" . __FUNCTION__ . " - no \$user object given"); 
                        return false;
                    }
            Severity: Major
            Found in lib/Forums/Permissions.php - About 2 hrs to fix

              File LocomotiveUtility.php has 253 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              /**
               * Locomotive utility class
               * @since Version 3.9.1
              Severity: Minor
              Found in lib/Locos/Utility/LocomotiveUtility.php - About 2 hrs to fix

                Method generate has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function generate() {
                        $string = '';
                        
                        global $handheld;
                        
                Severity: Major
                Found in lib/PageControls.php - About 2 hrs to fix

                  Method validate has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          public function validate() {
                              if (empty( $this->title )) {
                                  throw new Exception("Validation failed: title is empty");
                              }
                  
                  Severity: Major
                  Found in lib/News/Article.php - About 2 hrs to fix

                    Method formatExif has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function formatExif($exif) {
                            
                            $format = array();
                            
                            // Aperture
                    Severity: Minor
                    Found in lib/Images/Exif.php - About 2 hrs to fix

                      Method getUpcoming has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              public function getUpcoming($Date = false) {
                                  if (!$Date) {
                                      $Date = new DateTime;
                                      $Date->add(new DateInterval("PT60M"));
                                  }
                      Severity: Minor
                      Found in lib/Timetables/Timetables.php - About 2 hrs to fix

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

                            public function load() {
                                if (empty($this->id) || $this->id === false) {
                                    throw new Exception("Cannot load Railcam - empty or invalid ID given"); 
                                }
                                
                        Severity: Minor
                        Found in lib/Railcams/Camera.php - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language