railpage/railpagecore

View on GitHub

Showing 708 of 9,214 total issues

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

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

    public static function GetOpenGraphTags($url) {
        
        $Memcached = AppCore::GetMemcached(); 
        
        $mckey = md5($url); 
Severity: Minor
Found in lib/ContentUtility.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 populate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function populate() {
        
        $this->mckey = sprintf("railpage:gallery.album.image=%d", $this->id);
        
        if (!$row = $this->Memcached->fetch($this->mckey)) {
Severity: Minor
Found in lib/Gallery/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 populate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function populate() {
        
        $timer = Debug::getTimer();
        
        $row = Utility\LocomotiveUtility::fetchLocomotive($this); 
Severity: Minor
Found in lib/Locos/Locomotive.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 members has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function members() {
        $query = "SELECT l.*, s.name AS loco_status, o.operator_name, ow.operator_name AS owner_name, g.*
                    FROM loco_unit AS l 
                    LEFT JOIN loco_status AS s ON l.loco_status_id = s.id 
                    LEFT JOIN operators AS ow ON l.owner_id = ow.operator_id 
Severity: Minor
Found in lib/Locos/LocoClass.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->name)) {
            throw new Exception("Locomotive class name cannot be empty");
        }
        
Severity: Minor
Found in lib/Locos/LocoClass.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 __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 hasCoverImage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function hasCoverImage($Object) {
        
        /**
         * Image stored in meta data
         */
Severity: Minor
Found in lib/Locos/Utility/CoverImageUtility.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 getRedis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getRedis($reload = false) {
        if (!extension_loaded("redis") || (defined("NOREDIS") && NOREDIS == true)) {
            return new NullCacheDriver;
        }
        
Severity: Minor
Found in lib/AppCore.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 closeCorrection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function closeCorrection($type, $reason) {
        
        if (!isset($this->Resolution->User) || !$this->Resolution->User instanceof User) {
            throw new Exception("Cannot close correction - User resolving this correction not specified");
        }
Severity: Minor
Found in lib/Locos/Correction.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 fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function fetch() {
        if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
            throw new Exception("Cannot load loco object - loco ID not provided");
            return false;
        }
Severity: Minor
Found in lib/Locos/Locomotive.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 getMemcache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getMemcache($reload = false) {
        
        if (!extension_loaded("memcache") || defined("PHPUNIT_RAILPAGE_TESTSUITE")) {
            return new NullCacheDriver;
        }
Severity: Minor
Found in lib/AppCore.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 loadNotes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadNotes() {
        $query = "SELECT n.*, u.username, user_avatar FROM loco_notes AS n LEFT JOIN nuke_users AS u ON n.user_id = u.user_id WHERE n.loco_id = ?";
        
        $notes = array(); 
        
Severity: Minor
Found in lib/Locos/Locomotive.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 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 makePermaLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function makePermaLink($entity = false) {
            if (!$entity) {
                return false;
            }
            
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 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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function validate() {
        
        if (empty($this->name)) {
            throw new Exception("Album name is empty"); 
        }
Severity: Minor
Found in lib/Gallery/Album.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