railpage/railpagecore

View on GitHub

Showing 708 of 9,214 total issues

Function lookupText has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function lookupText($text) {
        
        $cachekey = sprintf("railpage:glossary.lookup.text=%s", md5($text)); 
        
        if ($id = $this->Redis->fetch($cachekey)) {
Severity: Minor
Found in lib/Glossary/Glossary.php - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
Open

        public function validate() {
            if (empty($this->title)) {
                throw new Exception("Cannot validate news topic - no title provided"); 
                return false;
            }
Severity: Minor
Found in lib/News/Topic.php - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function commit() {
        $this->validate();
        
        $timer = Debug::getTimer();
        
Severity: Minor
Found in lib/Locos/LocoClass.php - About 45 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

Method bulkAddLocos has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function bulkAddLocos($firstLoco = null, $lastLoco = null, $gaugeId = null, $statusId = null, $manufacturerId = null, $prefix = "") {
Severity: Minor
Found in lib/Locos/LocoClass.php - About 45 mins to fix

    Function addNote has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addNote($noteText = false, $userId = false, $noteId = false) {
            if (!$noteText || empty($noteText)) {
                throw new Exception("No note text given"); 
            } 
            
    Severity: Minor
    Found in lib/Locos/Locomotive.php - About 45 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 send has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            public function send() {
                
                $this->validate();
                
                $from_email = $this->data['author']['username'] == "Railpage System User" ? $this->Config->SMTP->username : $this->data['author']['email'];
    Severity: Minor
    Found in lib/Notifications/Transport/Email.php - About 45 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 getRandomClass has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getRandomClass() {
            $query = "SELECT `id`, `desc`, flickr_image_id FROM loco_class WHERE `desc` != '' AND flickr_image_id > 0";
            
            $ids = array();
            
    Severity: Minor
    Found in lib/Locos/Locos.php - About 45 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 getLocoIDFromClassIDAndLocoNumber has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function getLocoIDFromClassIDAndLocoNumber($class_id, $loco_num) {
    
            $Memcached = AppCore::getMemcached();
            $Database = (new AppCore)->getDatabaseConnection();
    
    
    Severity: Minor
    Found in lib/Locos/Utility/LocomotiveUtility.php - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

            private function validate() {
                if (!filter_var($this->transport, FILTER_VALIDATE_INT)) {
                    $this->transport = Notifications::TRANSPORT_EMAIL;
                }
                
    Severity: Minor
    Found in lib/Notifications/Notification.php - About 45 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 findFromTags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private function findFromTags($tags) {
            if (!is_array($tags)) {
                $tags = array($tags);
            }
            
    Severity: Minor
    Found in lib/Locos/Maintainers/Finder.php - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private function validate() {
            
            if (!filter_var($this->catid, FILTER_VALIDATE_INT) && !$this->category instanceof Category) {
                throw new Exception("No valid forum category has been set (hint: Forum::setCategory");
            }
    Severity: Minor
    Found in lib/Forums/Forum.php - About 45 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 posts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function posts($start = false, $end) {
            if (empty($end)) {
                $end = time(); 
            }
            
    Severity: Minor
    Found in lib/Forums/Stats.php - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct($id = null) {
            
            parent::__construct(); 
            
            if (!filter_var($id, FILTER_VALIDATE_INT)) {
    Severity: Minor
    Found in lib/Chronicle/Entry.php - About 45 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 ranks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function ranks() {
            $query = "SELECT * FROM nuke_bbranks WHERE rank_special = 0";
                
            if ($this->db instanceof \sql_db) {
                if ($rs = $this->db->query($query)) {
    Severity: Minor
    Found in lib/Forums/Forums.php - About 45 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 getPhoto has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            public function getPhoto($id) {
                $mckey = sprintf("railpage:railcam.provider=%s;railcam.image=%d", self::PROVIDER_NAME, $id);
                
                if ($this->photo = $this->Memcached->fetch($mckey)) {
                    return $this->photo;
    Severity: Minor
    Found in lib/Railcams/Provider/Flickr.php - About 45 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 getPath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getPath() {
            $mckey = sprintf("railpage:gtfs.path;provider=%s;route=%s", $this->Provider->getProviderName(), $this->short_name);
            
            $Memcached = AppCore::GetMemcached(); 
            
    Severity: Minor
    Found in lib/GTFS/StandardRoute.php - About 45 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

    Consider simplifying this complex logical expression.
    Open

                if (empty($this->oauthToken) || empty($this->oauth_secret) || empty($this->flickrApiKey) ||
                    is_null($this->oauthToken) || is_null($this->oauth_secret) || is_null($this->flickrApiKey)) {
                    return false;
                }
    Severity: Major
    Found in lib/Railcams/Provider/Flickr.php - About 40 mins to fix

      Method addMember has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function addMember($username = null, $userId = null, $orgRole = null, $orgContact = null, $orgPerms = null) {
      Severity: Minor
      Found in lib/Users/Group.php - About 35 mins to fix

        Method addTiming has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
        Severity: Minor
        Found in lib/Timetables/Train.php - About 35 mins to fix

          Method vincentyGreatCircleDistance has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public static function vincentyGreatCircleDistance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $earthRadius = 6371000) {
          Severity: Minor
          Found in lib/PlaceUtility.php - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language