railpage/railpagecore

View on GitHub

Showing 1,011 of 9,214 total issues

Method mostReadThisWeek has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function mostReadThisWeek($limit = 5) {
            $return = false;
            
            $params = array(); 
            
Severity: Minor
Found in lib/News/Base.php - About 1 hr to fix

    Method Add has 33 lines of code (exceeds 25 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 1 hr to fix

      Method guessTopic has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              static public function guessTopic($topic) {
                  
                  /**
                   * Normalise the topic name
                   */
      Severity: Minor
      Found in lib/News/News.php - About 1 hr to fix

        Method photos has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function photos($items_per_page, $page, $extras, $sort = true) {
                $url = "https://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=" . RP_FLICKR_API_KEY . "&user_id=" . $this->nsid . "&extras=" . $extras . "&per_page=" . $items_per_page . "&page=" . $page . "&format=json&nojsoncallback=1";
                
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
        Severity: Minor
        Found in lib/Railcams/Camera.php - About 1 hr to fix

          Method populate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function populate() {
                  $query = "SELECT organisation_id, conversions, job_added, reference_id, job_urls, job_location_id, job_classification_id, job_thread_id, job_title, job_description, job_expiry, DATEDIFF(job_expiry, NOW()) AS job_expiry_until, job_salary, job_special_cond, job_duration FROM jn_jobs WHERE job_id = ?";
                  
                  if (!$result = $this->Memcached->fetch($this->mckey)) {         
                      $result = $this->db->fetchRow($query, $this->id);
          Severity: Minor
          Found in lib/Jobs/Job.php - About 1 hr to fix

            Method getImageFromUrl has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getImageFromUrl($url = null, $option = null) {
                    
                    /**
                     * Flickr
                     */
            Severity: Minor
            Found in lib/Images/Images.php - About 1 hr to fix

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

                  private function load() {
                      
                      $query = "SELECT * FROM image_competition WHERE id = ?";
                      
                      $row = $this->db->fetchRow($query, $this->id);
              Severity: Minor
              Found in lib/Images/Competition.php - About 1 hr to fix

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

                    public function commit() {
                        
                        $this->validate();
                        
                        $data = array(
                Severity: Minor
                Found in lib/Downloads/Download.php - About 1 hr to fix

                  Method banIP has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function banIP($ipAddress = null, $reason = null, $expiry = "0", $adminUserId = null) {
                          
                          if (is_null($ipAddress)) {
                              throw new InvalidArgumentException("No IP address supplied"); 
                          }
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php - About 1 hr to fix

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

                            private function validate() {
                                
                                if (!filter_var($this->lat, FILTER_VALIDATE_FLOAT)) {
                                    throw new Exception("Cannot validate location - no latitude value"); 
                                }
                    Severity: Minor
                    Found in lib/Locations/Location.php - About 1 hr to fix

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

                          public function fetch() {
                              if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                                  throw new Exception("Cannot fetch PM - no message ID provided");
                              }
                              
                      Severity: Minor
                      Found in lib/PrivateMessages/Message.php - About 1 hr to fix

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

                                public function fetch() {
                                    $user_ids = array_keys($this->users);
                                    
                                    // If only one user account found, we must've sent ourselves a PM...
                                    if (count($user_ids) === 1) {
                        Severity: Minor
                        Found in lib/PrivateMessages/Conversation.php - About 1 hr to fix

                          Method getSite has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  public function getSite($id = false, $pending = false) {
                                      if (!$this->db) {
                                          return false;
                                      }
                                      
                          Severity: Minor
                          Found in lib/Locations/Locations.php - About 1 hr to fix

                            Method getRecipients has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    public function getRecipients() {
                                        $query = "SELECT * FROM notifications_recipients WHERE notification_id = ?";
                                        
                                        $recipients = array(); 
                                        
                            Severity: Minor
                            Found in lib/Notifications/Notification.php - About 1 hr to fix

                              Method validate has 32 lines of code (exceeds 25 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 1 hr to fix

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

                                    public function fetch() {
                                        if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                                            throw new Exception("Cannot fetch Livery object - no ID given"); 
                                            return false;
                                        }
                                Severity: Minor
                                Found in lib/Locos/Liveries/Livery.php - About 1 hr to fix

                                  Function memberList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function memberList($page = 1, $items_per_page = 25) {
                                          
                                          $start = $page > 0 ? ($page - 1) * $items_per_page : 0;
                                          $return = array(); 
                                          
                                  Severity: Minor
                                  Found in lib/Users/Admin.php - About 1 hr 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 11 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function validate() {
                                          if (!is_object($this->Organisation) || empty($this->Organisation->id)) {
                                              throw new Exception("Cannot save job - organisation is empty or invalid"); 
                                              return false;
                                          }
                                  Severity: Minor
                                  Found in lib/Jobs/Job.php - About 1 hr 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 __construct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                          public function __construct($category_id = false, $recurse = true) {
                                              parent::__construct(); 
                                              
                                              if (filter_var($category_id, FILTER_VALIDATE_INT)) {
                                                  $this->id = $category_id;
                                  Severity: Minor
                                  Found in lib/Links/Category.php - About 1 hr 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 fetchOld has a Cognitive Complexity of 11 (exceeds 5 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: Minor
                                  Found in lib/Jobs/Scraper.php - About 1 hr 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