railpage/railpagecore

View on GitHub

Showing 708 of 9,214 total issues

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

        public function fetch($id = false) {
            if ($id) {
                $this->id = $id;
            }
Severity: Minor
Found in lib/News/Article.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 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function fetch($recurse) {
        
        if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
            $this->id = Utility\LocomotiveUtility::getClassId($this->id); 
        }
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 getReadItemsForUser has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getReadItemsForUser(User $User, $type = "t") {
        
        /**
         * Not logged in - no threads/forums
         */
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

Function send has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

        public function send($markAsSent = false) {
            
            $this->validate(); 
            
            $Smarty = AppCore::getSmarty(); 
Severity: Minor
Found in lib/Reminders/Reminder.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 makeJSON has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function makeJSON() {

            if ($this->date instanceof DateTime) {
                $timezone = $this->date->getTimezone();
            } else {
Severity: Major
Found in lib/News/Article.php - About 2 hrs to fix

    Image has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Image extends AppCore {
    
        /**
         * Max age of data before it requires refreshing
         */
    Severity: Minor
    Found in lib/Images/Image.php - About 2 hrs to fix

      Method getPhotos has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getPhotos($num = 10) {
              $lat = $this->lat;
              $lon = $this->lon;
              
              $query = "SELECT flickr_geodata.*, 3956 * 2 * ASIN(SQRT(POWER(SIN((" . $lat . " - flickr_geodata.lat) * pi() / 180 / 2), 2) + COS(" . $lat . " * pi() / 180) * COS(" . $lat . " * pi() / 180) * POWER(SIN((" . $lon . " - flickr_geodata.lon) * pi() / 180 / 2), 2))) AS distance 
      Severity: Major
      Found in lib/Place.php - About 2 hrs to fix

        File Idea.php has 270 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        /**
         * Suggestions for side ideas and improvements, ala Wordpress.org/ideas
         * @since Version 3.8.7
        Severity: Minor
        Found in lib/Ideas/Idea.php - About 2 hrs to fix

          Method banUser has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function banUser($userId = null, $reason = null, $expiry = "0", $adminUserId = null) {
                  
                  if (!filter_var($userId, FILTER_VALIDATE_INT)) {
                      throw new InvalidArgumentException("No user ID supplied"); 
                  }
          Severity: Major
          Found in lib/BanControl/BanControl.php - About 2 hrs to fix

            Method latest has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public function latest($number = 5, $offset = 0) {
                        $return = false;
                        $mckey = "railpage:news.latest.count=" . $number .".offset=" . $offset;
                        $mcexp = strtotime("+5 minutes"); // Store for five minutes
                        
            Severity: Major
            Found in lib/News/Base.php - About 2 hrs to fix

              Method latestPosts has 61 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function latestPosts($is_auth_ary, $since, $limit = 10) {
                      if (empty($is_auth_ary) || !is_array($is_auth_ary)) {
                          return false;
                      }
                      
              Severity: Major
              Found in lib/Forums/Forums.php - About 2 hrs to fix

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

                    public function getWeatherForecast($days = 14) {
                        
                        return false;
                        
                        $weather = false;
                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 NominateImage has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function NominateImage(Image $imageObject, DateTime $dateWeek, User $userObject) {
                        
                        $query = "SELECT id FROM image_weekly WHERE datefrom = ?";
                        
                        if ($this->db->fetchOne($query, $dateWeek->format("Y-m-d"))) {
                Severity: Minor
                Found in lib/Images/PhotoOfTheWeek.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 getPhotoContext has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function getPhotoContext(Image $imageObject, $unapprovedOnly = null) {
                        
                        $Database = (new AppCore)->getDatabaseConnection(); 
                        
                        if ($unapprovedOnly == false || $unapprovedOnly == null) {
                Severity: Minor
                Found in lib/Images/Utility/Finder.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 recent has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function recent($activeOnly = null) {
                        
                        $Database = (new AppCore)->getDatabaseConnection(); 
                        
                        $query = "SELECT b.id, b.user_id, un.username AS username, b.ban_active, b.ban_time, b.ban_expire, b.ban_reason, b.banned_by, u.username AS banned_by_username 
                Severity: Minor
                Found in lib/BanControl/LookupUtility.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 updateAuthors has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function updateAuthors() {
                        
                        $userlookup = array(); 
                        
                        $Database = (new AppCore)->getDatabaseConnection(); 
                Severity: Minor
                Found in lib/Images/Utility/Updater.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 setPushSubscription has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                        public static function setPushSubscription(User $User, $subscription, $enabled = null) {
                            
                            $endpoint = false;
                            $registration_id = false;
                            $provider = false;
                Severity: Minor
                Found in lib/Notifications/Notifications.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 Add has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function Add($title = null, $url = null, $grouping = null, $meta = null) {
                        if (empty(filter_var($title, FILTER_SANITIZE_STRING))) {
                            throw new InvalidArgumentException("Cannot add item to menu - no title given"); 
                        }
                        
                Severity: Minor
                Found in lib/Submenu.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 getDeleted has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                        public function getDeleted($user_id = false) {
                            if (!$user_id) {
                                throw new Exception("Cannot fetch deleted message IDs - no user ID given"); 
                                return false;
                            }
                Severity: Minor
                Found in lib/PrivateMessages/PrivateMessages.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 findArticles has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                        public function findArticles($offset = 0, $limit = 25, $orderby = "story_time_unix") {
                            
                            if (empty($this->filter_topics) || empty($this->filter_words)) {
                                $this->getFilters();
                            }
                Severity: Minor
                Found in lib/News/Feed.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