railpage/railpagecore

View on GitHub

Showing 1,011 of 9,214 total issues

Avoid too many return statements within this method.
Open

            return $result === false ? 0 : count($result); 
Severity: Major
Found in lib/Forums/Stats.php - About 30 mins to fix

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

        public function getPreferences($section = false) {
    
            $prefs = is_object($this->preferences) ? json_decode(json_encode($this->preferences), true) : $this->preferences;
    
            if (is_string($prefs)) {
    Severity: Minor
    Found in lib/Users/User.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() {
            
            $mckey = sprintf("railpage:group=%d", intval($this->id)); 
            
            if (!$row = $this->Redis->fetch($mckey)) {
    Severity: Minor
    Found in lib/Users/Group.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 getStatsForCamera has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getStatsForCamera(Camera $cameraObject) {
            
            $query = "(SELECT 'Photos on Railpage' AS label, COUNT(*) AS value FROM image_exif WHERE camera_id = ?)
                UNION (SELECT 'Most used lens' AS label, l.model AS value FROM image_exif AS e LEFT JOIN image_lens AS l ON e.lens_id = l.id WHERE e.camera_id = ? GROUP BY e.lens_id ORDER BY COUNT(*) DESC LIMIT 1)
                UNION (SELECT 'Screener\'s Choice' AS label, COUNT(*) AS value FROM image_flags AS f LEFT JOIN image_exif AS e ON e.image_id = f.image_id WHERE e.camera_id = ? AND f.screened_pick = 1)";
    Severity: Minor
    Found in lib/Images/Statistics.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 getWatchedThreads has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getWatchedThreads($page = 1, $limit = null) {
    
            // Assume Zend_Db
    
            if (!filter_var($limit, FILTER_VALIDATE_INT)) {
    Severity: Minor
    Found in lib/Users/User.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("Link title cannot be empty"); 
                    return false;
                }
    Severity: Minor
    Found in lib/Links/Link.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 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 getCompetitions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getCompetitions($status = NULL) {
            $query = "SELECT id FROM image_competition";
            $where = array(); 
            
            if (!is_null($status)) {
    Severity: Minor
    Found in lib/Images/Competitions.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 assemble has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        private function assemble() {
            
            Debug::LogCLI("Assembling the collage"); 
            
            $imageSize = $this->findThumbnailSize(); 
    Severity: Minor
    Found in lib/Images/Collage.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 getExifIDs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getExifIDs($exif) {
            
            $required = [ 
                "camera_make", 
                "camera_model",
    Severity: Minor
    Found in lib/Images/Exif.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 getAlerts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getAlerts(\Zend_Acl $acl) {
    
            $query = array();
            $params = array();
    
    Severity: Minor
    Found in lib/Users/User.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 canUserSubmitPhoto has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function canUserSubmitPhoto(User $userObject) {
            if (!filter_var($userObject->id, FILTER_VALIDATE_INT)) {
                return false;
            }
            
    Severity: Minor
    Found in lib/Images/Competition.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 addMember has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addMember($username = null, $userId = null, $orgRole = null, $orgContact = null, $orgPerms = null) {
            
            $mckey = sprintf("railpage:group=%d", intval($this->id)); 
            $this->Redis->delete($mckey); 
            
    Severity: Minor
    Found in lib/Users/Group.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 getGroups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getGroups($force = null) {
    
            if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                return false;
            }
    Severity: Minor
    Found in lib/Users/User.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 getNewest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getNewest($categoryId = false, $limit = 20, $start = 0) {
            
            $params = array(); 
            $query = "SELECT l.*, c.title as category_title, c.cdescription as category_description FROM nuke_links_links l, nuke_links_categories c WHERE l.cid = c.cid AND l.link_approved = 1";
            
    Severity: Minor
    Found in lib/Links/Links.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 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 formatObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function formatObject($row) {
            if ($row['module'] == "locos" && $row['event']['object'] == "class") {
                $row['event']['object'] = "locomotive class";
                
                if ($row['event']['action'] == "modified") {
    Severity: Minor
    Found in lib/Users/Timeline/Utility/General.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 validatePassword has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function validatePassword($password = null, $storedPassword = null, $storedBcrypt = null) {
            
            if (is_null($password)) {
                throw new InvalidArgumentException("No password supplied"); 
            }
    Severity: Minor
    Found in lib/Users/Utility/PasswordUtility.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 commit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function commit() {
    
            $data = array(
                "jn_location_name" => $this->name,
                "jn_parent_id"     => $this->parent_id
    Severity: Minor
    Found in lib/Jobs/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

    Severity
    Category
    Status
    Source
    Language