railpage/railpagecore

View on GitHub

Showing 1,011 of 9,214 total issues

Function getPhotos has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getPhotos($items_per_page = 25, $page_num = 1, $date_from = false, $date_to = false) {
        if (!empty($this->flickr_oauth_secret) && !empty($this->flickr_oauth_token)) {
            // Fetch photos using OAuth
            $f = new flickr_railpage(RP_FLICKR_API_KEY);
            $f->oauth_token     = $this->flickr_oauth_token;
Severity: Minor
Found in lib/Railcams/Camera.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 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate() {
        
        if (is_null($this->bbcode_uid)) {
            $this->bbcode_uid = "sausages";
        }
Severity: Minor
Found in lib/Forums/Post.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 photos has a Cognitive Complexity of 14 (exceeds 5 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

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 fetch has 43 lines of code (exceeds 25 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 1 hr to fix

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

      Method getImageExif has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getImageExif(Image $imageObject, $force = false) {
              
              Debug::LogCLI("Fetching EIXF data for image ID " . $imageObject->id);
              
              if (!$force && isset($imageObject->meta['exif']) && $imageObject->meta['exif_format_version'] >= self::EXIF_FORMAT_VERSION) {
      Severity: Minor
      Found in lib/Images/Exif.php - About 1 hr to fix

        Method notifyWinner has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function notifyWinner(Competition $compObject) {
                    
                if (isset($compObject->meta['winnernotified']) && $compObject->meta['winnernotified'] === true) {
                    return $this;
                }
        Severity: Minor
        Found in lib/Images/Utility/CompNotify.php - About 1 hr to fix

          Method getIcon has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getIcon() {
                  
                  $mime = explode("/", $this->mime); 
                  
                  switch ($mime[0]) {
          Severity: Minor
          Found in lib/Downloads/Download.php - About 1 hr to fix

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

                public function commit() {
                    if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                        throw new Exception("Cannot commit changes to PM - PM does not exist!"); 
                    } 
                    
            Severity: Minor
            Found in lib/PrivateMessages/Message.php - About 1 hr to fix

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

                      public function send() {
                          
                          $this->validate();
                          
                          $from_email = $this->data['author']['username'] == "Railpage System User" ? $this->Config->SMTP->username : $this->data['author']['email'];
              Severity: Minor
              Found in lib/Notifications/Transport/Email.php - About 1 hr to fix

                Method activeThreads has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function activeThreads($num_threads = 1, $age) {
                        if (empty($age)) {
                            $age = strtotime("30 days ago"); 
                        }
                        
                Severity: Minor
                Found in lib/Forums/Stats.php - About 1 hr to fix

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

                      public function validate($ignore = false) {
                  
                          if (empty( $this->username )) {
                              throw new Exception("Username cannot be empty");
                          }
                  Severity: Minor
                  Found in lib/Users/User.php - About 1 hr to fix

                    Method getArray has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getArray() {
                            //$now = new DateTime;
                            
                            $voting_open = Utility\CompetitionUtility::isVotingWindowOpen($this);
                            $submissions_open = Utility\CompetitionUtility::isSubmissionWindowOpen($this);
                    Severity: Minor
                    Found in lib/Images/Competition.php - About 1 hr to fix

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

                          public function commit() {
                      
                              $this->validate();
                      
                              $user_id = isset( $this->author->User ) && $this->author->User instanceof User ? $this->author->User->id : 0;
                      Severity: Minor
                      Found in lib/Images/Image.php - About 1 hr to fix

                        Method deleteObjects has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                public function deleteObjects($object_id = false) {
                                    if (!$object_id) {
                                        //throw new Exception("Cannot delete objects - no object ID given"); 
                                        return false;
                                    } 
                        Severity: Minor
                        Found in lib/PrivateMessages/PrivateMessages.php - About 1 hr to fix

                          Method Process has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function Process( $text ) {
                                  
                                  $timer = Debug::GetTimer(); 
                                  
                                  $r = '';
                          Severity: Minor
                          Found in lib/Formatting/MakeClickable.php - About 1 hr to fix

                            Method getEmoticons has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function getEmoticons() {
                                    
                                    return [
                                        'icon_mad'      => [ ':angry:', '>(', '>:(', '>[', '>:[' ],
                                        'icon_cool'     => [ ':sunglasses:', ':cool:', '8)', '8]', '[:cool:]', '8-)' ],
                            Severity: Minor
                            Found in lib/Formatting/EmoticonsUtility.php - About 1 hr to fix

                              Method getArray has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function getArray() {
                                      $array = array(
                                          "id" => $this->id,
                                          "date" => array(
                                              "absolute" => $this->Date->format("Y-m-d H:i:s"),
                              Severity: Minor
                              Found in lib/Events/EventDate.php - About 1 hr to fix

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

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

                                  Method cleanupBadHtml has 40 lines of code (exceeds 25 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 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language