railpage/railpagecore

View on GitHub

Showing 708 of 9,214 total issues

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

        public function __construct($id = false) {
            parent::__construct(); 
            
            if ($id && filter_var($id, FILTER_VALIDATE_INT)) {
                $this->id = $id;
Severity: Minor
Found in lib/SiteMessages/SiteMessage.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 setRating has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function setRating($userId = false, $rating = false) {
        if (!$userId instanceof User && !filter_var($userId, FILTER_VALIDATE_INT)) {
            throw new Exception("Cannot set user rating for this loco - no user given"); 
        }
        
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 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 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 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 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

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

Severity
Category
Status
Source
Language