railpage/railpagecore

View on GitHub

Showing 708 of 9,214 total issues

Function populateFromArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function populateFromArray($row) {

        $this->provider = $row['provider'];
        $this->photo_id = $row['photo_id'];
        $this->Date = new DateTime($row['modified']);
Severity: Minor
Found in lib/Images/Image.php - About 25 mins 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 latest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function latest($limit = 25, $keys = false, $page = 1) {
            if (is_array($keys)) {
                $sql_keys = " WHERE `key` IN ('".implode("','", $keys)."')";
            } elseif (is_string($keys)) {
                $sql_keys = $this->db instanceof sql_db ? " WHERE `key` = '".$this->db->real_escape_string($keys)."'" : " WHERE `key` = " . $keys; 
Severity: Minor
Found in lib/SiteEvent/Base.php - About 25 mins 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 find has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function find($keys = false, $value = false, $limit = 25) {
            
            $timer = Debug::getTimer(); 
            
            if (!$keys) {
Severity: Minor
Found in lib/SiteEvent/Base.php - About 25 mins 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        private function load() {
            if (filter_var($this->id, FILTER_VALIDATE_INT)) {
                $this->mckey = sprintf("railpage:timetable.train=%d", $this->id);
                
                if (!$row = $this->Memcached->fetch($this->mckey)) {
Severity: Minor
Found in lib/Timetables/Train.php - About 25 mins 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 setDefaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function setDefaults() {
        
        if (!$this->Date instanceof DateTime) {
            $this->Date = new DateTime;
        }
Severity: Minor
Found in lib/Ideas/Idea.php - About 25 mins 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 makeOpenGraphTag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function makeOpenGraphTag(Competition $photoComp, $tag) {
        
        switch ($tag) {
            case "description":
            case "desc":
Severity: Minor
Found in lib/Images/Utility/CompetitionUtility.php - About 25 mins 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 GuessCoverPhoto has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function GuessCoverPhoto($searchQuery) {
        
        $defaultPhoto = "https://static.railpage.com.au/i/logo-fb.jpg";
        
        $cachekey = sprintf("railpage:coverphoto=%s", md5($searchQuery)); 
Severity: Minor
Found in lib/Images/Utility/Finder.php - About 25 mins 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($params = null) {
        
        parent::__construct(); 
        
        if (!is_array($params)) {
Severity: Minor
Found in lib/Images/Provider/Flickr.php - About 25 mins 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 createNewsArticle_Winner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function createNewsArticle_Winner(Competition $photoComp) {
        
        /**
         * Get the winning photo
         */
Severity: Minor
Found in lib/Images/Utility/CompetitionUtility.php - About 25 mins 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 notificationDoRecipients has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function notificationDoRecipients(Notification $notificationObject, Competition $photoComp, $notificationOptions = null) {
        
        $contestants = (new Competitions)->getPreviousContestants(); 
        
        $replacements = array(); 
Severity: Minor
Found in lib/Images/Utility/CompetitionUtility.php - About 25 mins 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 deactivate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function deactivate() {
            if (!$this->id) {
                return false;
            }
            
Severity: Minor
Found in lib/SiteMessage/Message.php - About 25 mins 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function validate() {
            if (empty($this->lat)) {
                throw new Exception("Cannot validate sighting - latitude cannot be empty"); 
                return false;
            }
Severity: Minor
Found in lib/Sightings/Sighting.php - About 25 mins 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 FormatArticleText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public static function FormatArticleText($Article, $section = "lead") {
            
            $Memcached = AppCore::GetMemcached(); 
            
            $cachekey = $section == "lead" ? Article::CACHE_KEY_FORMAT_LEAD : Article::CACHE_KEY_FORMAT_PARAGRAPHS;
Severity: Minor
Found in lib/News/Utility/ArticleUtility.php - About 25 mins 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 loadFromCache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        private function loadFromCache() {

            $mckey = sprintf("railpage:locations.country=%s", strtoupper($this->code));
            
            #printArray($mckey);die;
Severity: Minor
Found in lib/Locations/Country.php - About 25 mins 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 geocode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        private function geocode() {
            
            if (!empty($this->region) && !empty($this->country) && !empty($this->locality)) {
                #return;
            }
Severity: Minor
Found in lib/Locations/Location.php - About 25 mins 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function __construct($topic_id = false) {
            parent::__construct();
            
            if (filter_var($topic_id, FILTER_VALIDATE_INT)) {
                $this->id = $topic_id;
Severity: Minor
Found in lib/News/Topic.php - About 25 mins 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 getPending has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function getPending() {
            
            #$query = "SELECT s.*, t.topicname, t.topicimage, t.topictext, u.username FROM nuke_stories AS s, nuke_topics AS t, nuke_users AS u WHERE s.user_id = u.user_id AND s.topic = t.topicid";
            $query = "SELECT s.*, t.topicname, t.topictext, u.username, 'newqueue' AS queue
                FROM nuke_stories AS s
Severity: Minor
Found in lib/News/Base.php - About 25 mins 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 getStory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function getStory($id = false, $pending = false) {
            if (!$id || !$this->db) {
                return false;
            }
            
Severity: Minor
Found in lib/News/News.php - About 25 mins 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($type = null) {
        parent::__construct();
        
        $this->Module = new Module("glossary");
        
Severity: Minor
Found in lib/Glossary/Type.php - About 25 mins 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 getFilters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function getFilters() {
            if (!$this->User instanceof User) {
                throw new Exception("Cannot get filters for news feed because no valid user was specified");
            }
            
Severity: Minor
Found in lib/News/Feed.php - About 25 mins 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