railpage/railpagecore

View on GitHub

Showing 708 of 9,214 total issues

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

    public static function isClientBanned($userId, $remoteAddr, $force = null) {
        
        if ($remoteAddr == "58.96.64.238" || $userId == 71317) {
            $force = true;
        }
Severity: Minor
Found in lib/BanControl/BanControl.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 Process has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public static function Process( $text ) {
        
        $timer = Debug::GetTimer(); 
        
        $r = '';
Severity: Minor
Found in lib/Formatting/MakeClickable.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 getTimeline has a Cognitive Complexity of 17 (exceeds 5 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: Minor
Found in lib/Locos/LocoClass.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 commit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function commit() {
        if (empty($this->bbcode_uid)) {
            $this->bbcode_uid = crc32($this->text);
        }
        
Severity: Minor
Found in lib/Forums/Post.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 hybi10Encode has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    private function hybi10Encode($payload, $type = 'text', $masked = true)
    {
        $frameHead = array();
        $payloadLength = strlen($payload);
        switch ($type) {
Severity: Minor
Found in lib/SocketIO.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 process has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private function process(array $item) {
            
            /**
             * Process the description field
             */
Severity: Major
Found in lib/RSS/Consume.php - About 2 hrs to fix

    Method fetch has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function fetch() {
    
            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

      File Weekly.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
          /**
           * Curate a weekly newsletter
           * @since Version 3.10.0
           * @package Railpage
      Severity: Minor
      Found in lib/Newsletters/Weekly.php - About 2 hrs to fix

        File CountryCodes.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
            /**
             * ISO 3166-1 country codes
             * @since Version 3.10.0
             * @package Railpage
        Severity: Minor
        Found in lib/Locations/Utility/CountryCodes.php - About 2 hrs to fix

          Method GetLoadingSVG has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function GetLoadingSVG(Image $imageObject) {
                  
                  $cachekey = sprintf("railpage:base64.image.svg=%d", $imageObject->id); 
                  
                  $Memcached = AppCore::GetMemcached(); 
          Severity: Major
          Found in lib/Images/Utility/ImageUtility.php - About 2 hrs to fix

            Method EmbedGoogleMap has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function EmbedGoogleMap(DOMElement $e) {
                    
                    $timer = Debug::GetTimer(); 
                    
                    $Config = AppCore::GetConfig(); 
            Severity: Major
            Found in lib/Formatting/MultimediaUtility.php - About 2 hrs to fix

              Method getThumbnail has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getThumbnail() {
                      
                      $mime = explode("/", $this->mime); 
                      $thumbnail = sprintf("%s.thumbnail.jpg", $this->filepath);
                      
              Severity: Major
              Found in lib/Downloads/Download.php - About 2 hrs to fix

                Method isClientBanned has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function isClientBanned($userId, $remoteAddr, $force = null) {
                        
                        if ($remoteAddr == "58.96.64.238" || $userId == 71317) {
                            $force = true;
                        }
                Severity: Major
                Found in lib/BanControl/BanControl.php - About 2 hrs to fix

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

                          public function send($markAsSent = false) {
                              
                              $this->validate(); 
                              
                              $Smarty = AppCore::getSmarty(); 
                  Severity: Major
                  Found in lib/Reminders/Reminder.php - About 2 hrs to fix

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

                        public function fetch() {
                    
                            if (!is_string($this->feed)) {
                                throw new Exception("Cannot fetch jobs from RSS feed because no RSS feed was provided");
                            }
                    Severity: Minor
                    Found in lib/Jobs/Scraper.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 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

                    Severity
                    Category
                    Status
                    Source
                    Language