railpage/railpagecore

View on GitHub

Showing 1,011 of 9,214 total issues

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/Organisations/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 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 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 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 getLogger has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getLogger() {
        
        $Registry = Registry::getInstance();
        
        $Config = self::getConfig();
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 getEventsForDates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEventsForDates($dateFrom = null, $dateTo = null) {
        
        $events = array(); 
        
        $Railcams = new Module_Railcams;
Severity: Minor
Found in lib/Chronicle/Provider/Railcams.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 getAllowedForumsIDsForUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAllowedForumsIDsForUser(User $User, $permission = self::AUTH_ALL) {
        $acl = $this->setUser($User)->getACL(); 
        
        $ids = array(); 
        $allforums = $this->getAllForums();
Severity: Minor
Found in lib/Forums/Forums.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 tagLoco has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function tagLoco(Locomotive $Loco) {
        
        if (!filter_var($Loco->id, FILTER_VALIDATE_INT)) {
            throw new Exception("An invalid instance of Railpage\\Locos\\Locomotive was supplied");
        }
Severity: Minor
Found in lib/Railcams/Photo.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 addDividers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function addDividers() {
        
        $links = $this->getParam("links");
        
        end($links); 
Severity: Minor
Found in lib/Pagination.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 updateUserThreadView has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function updateUserThreadView(Thread $Thread, $User = false) {
        
        // Prevent browser prefetch/preview from creating a timestamp
        if (
            (isset($_SERVER["HTTP_X_PURPOSE"]) && (strtolower($_SERVER["HTTP_X_PURPOSE"]) == "preview")) || 
Severity: Minor
Found in lib/Forums/Utility/ForumsUtility.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 formatDepartures has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function formatDepartures($departures) {
        $return = array();
        
        if (isset($departures['values'])) {
            foreach ($departures['values'] as $row) {
Severity: Minor
Found in lib/GTFS/AU/VIC/PTV/Stop.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

The method NominateImage() has an NPath complexity of 1040. The configured NPath complexity threshold is 200.
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 by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method generate() has an NPath complexity of 6147. The configured NPath complexity threshold is 200.
Open

    public function generate() {
        $string = '';
        
        global $handheld;
        
Severity: Minor
Found in lib/PageControls.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method process() has an NPath complexity of 2304. The configured NPath complexity threshold is 200.
Open

        private function process(array $item) {
            
            /**
             * Process the description field
             */
Severity: Minor
Found in lib/RSS/Consume.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method addTiming() has an NPath complexity of 576. The configured NPath complexity threshold is 200.
Open

        public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
            if (!$this->Point instanceof Point) {
                throw new Exception("Cannot add a timing because no valid timetable point has been set");
            }
            
Severity: Minor
Found in lib/Timetables/Train.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method load() has an NPath complexity of 720. The configured NPath complexity threshold is 200.
Open

        private function load() {
            
            $this->mckey = sprintf("railpage:locations.location=%d", $this->id); 
            
            if (!$row = $this->Memcached->fetch($this->mckey)) {
Severity: Minor
Found in lib/Locations/Location.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method geocode() has 104 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

        private function geocode() {
            
            if (!empty($this->region) && !empty($this->country) && !empty($this->locality)) {
                #return;
            }
Severity: Minor
Found in lib/Locations/Location.php by phpmd

The method fetch() has an NPath complexity of 3456. The configured NPath complexity threshold is 200.
Open

    public function fetch() {
        if (empty($this->id)) {
            throw new Exception("Cannot fetch download object - no download ID given"); 
        }
        
Severity: Minor
Found in lib/Downloads/Download.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method getPhotosForSite() has 105 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

        public function getPhotosForSite($num = 10, $start = 0) {
            
            $Place = new Place($this->lat, $this->lon); 
            
            return $Place->getPhotosFromSphinx($num); 
Severity: Minor
Found in lib/Locations/Location.php by phpmd

The method find() has 114 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public static function find() {
        
        $args       = func_get_args(); 
        $Loco       = false;
        $LocoClass  = false;
Severity: Minor
Found in lib/Images/Utility/Finder.php by phpmd
Severity
Category
Status
Source
Language