railpage/railpagecore

View on GitHub
lib/Users/Group.php

Summary

Maintainability
F
3 days
Test Coverage

Method addMember has 33 lines of code (exceeds 25 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 1 hr to fix

    Method fetch has 27 lines of code (exceeds 25 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 1 hr 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

        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 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

        Avoid assigning values to variables in if clauses and the like (line '471', column '14').
        Open

            public function userInGroup($userId = null) {
                if ($userId instanceof User) {
                    $userId = $userId->id;
                }
                
        Severity: Minor
        Found in lib/Users/Group.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

        Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

        Avoid assigning values to variables in if clauses and the like (line '146', column '14').
        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 by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

        Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                if (!$row = $this->Redis->fetch($mckey)) {
                
                    $query = "SELECT g.group_attrs, g.organisation_id, g.group_id AS id, g.group_name AS name, g.group_type AS type, 
                                g.group_description AS description, g.group_moderator AS owner_user_id, u.username AS owner_username 
                            FROM nuke_bbgroups AS g 
        Severity: Major
        Found in lib/Users/Group.php and 1 other location - About 2 hrs to fix
        lib/Sightings/Sighting.php on lines 139..149

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 63.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

            public function setOwner(User $userObject) {
                
                $this->owner_user_id = $userObject->id;
                $this->owner_username = $userObject->username;
                
        Severity: Major
        Found in lib/Users/Group.php and 5 other locations - About 1 hr to fix
        lib/Locos/LocoClass.php on lines 1214..1219
        lib/Locos/LocoClass.php on lines 1228..1233
        lib/Locos/LocoClass.php on lines 1242..1247
        lib/Locos/Locomotive.php on lines 1471..1476
        lib/Users/Group.php on lines 205..211

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 36.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

            public function setOrganisation(Organisation $orgObject) {
                
                $this->organisation_id = $orgObject->id;
                $this->organisation = $orgObject->name;
                
        Severity: Major
        Found in lib/Users/Group.php and 5 other locations - About 1 hr to fix
        lib/Locos/LocoClass.php on lines 1214..1219
        lib/Locos/LocoClass.php on lines 1228..1233
        lib/Locos/LocoClass.php on lines 1242..1247
        lib/Locos/Locomotive.php on lines 1471..1476
        lib/Users/Group.php on lines 190..196

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 36.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        $data = [
                            "group_id" => $this->id,
                            "user_id" => $userId,
                            "organisation_role" => $orgRole,
                            "organisation_contact" => $orgContact,
        Severity: Major
        Found in lib/Users/Group.php and 1 other location - About 1 hr to fix
        lib/Users/User.php on lines 2588..2594

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 35.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 7 locations. Consider refactoring.
        Open

                if (!filter_var($this->type, FILTER_VALIDATE_INT)) {
                    $this->type = self::TYPE_OPEN;
                }
        Severity: Major
        Found in lib/Users/Group.php and 6 other locations - About 1 hr to fix
        lib/Events/EventDate.php on lines 219..221
        lib/Forums/Forum.php on lines 286..288
        lib/Ideas/Idea.php on lines 264..266
        lib/Locations/Correction.php on lines 180..182
        lib/Notifications/Notification.php on lines 179..181
        lib/Notifications/Notification.php on lines 183..185

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 34.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 25 locations. Consider refactoring.
        Open

                if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                    throw new Exception("Cannot fetch group - group ID cannot be empty");
                }
        Severity: Major
        Found in lib/Users/Group.php and 24 other locations - About 1 hr to fix
        lib/Downloads/Download.php on lines 313..315
        lib/Events/Event.php on lines 425..427
        lib/Events/Events.php on lines 130..132
        lib/Images/Competition.php on lines 624..626
        lib/Images/Competition.php on lines 654..656
        lib/Images/Competition.php on lines 823..825
        lib/Images/Competition.php on lines 860..862
        lib/Images/Favourites.php on lines 112..114
        lib/Images/Favourites.php on lines 178..180
        lib/Jobs/Classification.php on lines 80..82
        lib/Locations/Location.php on lines 406..408
        lib/Locations/Location.php on lines 410..412
        lib/Locos/Locomotive.php on lines 622..624
        lib/Locos/Locomotive.php on lines 626..628
        lib/Locos/Locomotive.php on lines 897..899
        lib/News/Article.php on lines 361..363
        lib/News/Article.php on lines 834..836
        lib/Newsletters/Newsletters.php on lines 135..137
        lib/PrivateMessages/Message.php on lines 244..246
        lib/PrivateMessages/Message.php on lines 452..454
        lib/Railcams/Photo.php on lines 330..332
        lib/Railcams/Storage.php on lines 224..226
        lib/Sightings/Sighting.php on lines 133..135
        lib/Warnings/Warning.php on lines 209..211

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 32.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        Debug::logEvent(__METHOD__ . " found user ID " . $userId . " in group ID " . $this->id, $timer); 
        Severity: Major
        Found in lib/Users/Group.php and 1 other location - About 1 hr to fix
        lib/Users/Group.php on lines 483..483

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 31.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                Debug::logEvent(__METHOD__ . " did not find ID " . $userId . " in group ID " . $this->id, $timer); 
        Severity: Major
        Found in lib/Users/Group.php and 1 other location - About 1 hr to fix
        lib/Users/Group.php on lines 478..478

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 31.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 23 locations. Consider refactoring.
        Open

                $this->attributes = json_decode($row['group_attrs'], true);
        Severity: Major
        Found in lib/Users/Group.php and 22 other locations - About 45 mins to fix
        lib/Assets/Asset.php on lines 150..150
        lib/Chronicle/Entry.php on lines 156..156
        lib/Events/Event.php on lines 207..207
        lib/Events/EventDate.php on lines 154..154
        lib/Gallery/Album.php on lines 136..136
        lib/Gallery/Image.php on lines 208..208
        lib/Ideas/Idea.php on lines 166..166
        lib/Images/Camera.php on lines 116..116
        lib/Images/Competition.php on lines 180..180
        lib/Images/Competition.php on lines 790..790
        lib/Locos/Date.php on lines 158..158
        lib/Locos/LocoClass.php on lines 417..417
        lib/News/Feed.php on lines 234..234
        lib/News/Feed.php on lines 235..235
        lib/Newsletters/Newsletter.php on lines 128..128
        lib/Newsletters/Newsletter.php on lines 129..129
        lib/Railcams/Storage.php on lines 201..201
        lib/Sightings/Sighting.php on lines 161..161
        lib/Sightings/Sighting.php on lines 162..162
        lib/Timetables/Train.php on lines 174..174
        lib/Users/User.php on lines 1068..1068
        lib/SiteEvent.php on lines 135..135

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 26.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

                $mckey = sprintf("railpage:group=%d", intval($this->id)); 
        Severity: Major
        Found in lib/Users/Group.php and 5 other locations - About 45 mins to fix
        lib/Locations/Country.php on lines 161..161
        lib/Users/Group.php on lines 144..144
        lib/Users/Group.php on lines 431..431
        lib/Users/Group.php on lines 511..511
        lib/Users/Group.php on lines 537..537

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 26.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

                $mckey = sprintf("railpage:group=%d", intval($this->id)); 
        Severity: Major
        Found in lib/Users/Group.php and 5 other locations - About 45 mins to fix
        lib/Locations/Country.php on lines 161..161
        lib/Users/Group.php on lines 144..144
        lib/Users/Group.php on lines 291..291
        lib/Users/Group.php on lines 431..431
        lib/Users/Group.php on lines 537..537

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 26.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

                $mckey = sprintf("railpage:group=%d", intval($this->id)); 
        Severity: Major
        Found in lib/Users/Group.php and 5 other locations - About 45 mins to fix
        lib/Locations/Country.php on lines 161..161
        lib/Users/Group.php on lines 291..291
        lib/Users/Group.php on lines 431..431
        lib/Users/Group.php on lines 511..511
        lib/Users/Group.php on lines 537..537

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 26.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

                    $mckey = sprintf("railpage:group=%d", intval($this->id)); 
        Severity: Major
        Found in lib/Users/Group.php and 5 other locations - About 45 mins to fix
        lib/Locations/Country.php on lines 161..161
        lib/Users/Group.php on lines 144..144
        lib/Users/Group.php on lines 291..291
        lib/Users/Group.php on lines 511..511
        lib/Users/Group.php on lines 537..537

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 26.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

                $mckey = sprintf("railpage:group=%d", intval($this->id)); 
        Severity: Major
        Found in lib/Users/Group.php and 5 other locations - About 45 mins to fix
        lib/Locations/Country.php on lines 161..161
        lib/Users/Group.php on lines 144..144
        lib/Users/Group.php on lines 291..291
        lib/Users/Group.php on lines 431..431
        lib/Users/Group.php on lines 511..511

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 26.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 23 locations. Consider refactoring.
        Open

                $this->url->edit = sprintf("%s/edit", $this->url->url);
        Severity: Major
        Found in lib/Users/Group.php and 22 other locations - About 45 mins to fix
        lib/Chronicle/Chronicle.php on lines 42..42
        lib/Chronicle/Chronicle.php on lines 43..43
        lib/Chronicle/Chronicle.php on lines 44..44
        lib/Chronicle/Chronicle.php on lines 45..45
        lib/Chronicle/Chronicle.php on lines 46..46
        lib/Images/Competition.php on lines 150..150
        lib/Jobs/Job.php on lines 196..196
        lib/Locos/Locomotive.php on lines 432..432
        lib/Locos/Locomotive.php on lines 433..433
        lib/Railcams/Camera.php on lines 258..258
        lib/Railcams/Camera.php on lines 259..259
        lib/Railcams/Camera.php on lines 261..261
        lib/Railcams/Camera.php on lines 262..262
        lib/Railcams/Camera.php on lines 263..263
        lib/Railcams/Camera.php on lines 264..264
        lib/Railcams/Camera.php on lines 266..266
        lib/Timetables/Point.php on lines 115..115
        lib/Timetables/Timetables.php on lines 41..41
        lib/Timetables/Timetables.php on lines 42..42
        lib/Timetables/Timetables.php on lines 43..43
        lib/Timetables/Train.php on lines 183..183
        lib/Users/Group.php on lines 223..223

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 25.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 23 locations. Consider refactoring.
        Open

                $this->url->addMember = sprintf("%s/addmember", $this->url->url);
        Severity: Major
        Found in lib/Users/Group.php and 22 other locations - About 45 mins to fix
        lib/Chronicle/Chronicle.php on lines 42..42
        lib/Chronicle/Chronicle.php on lines 43..43
        lib/Chronicle/Chronicle.php on lines 44..44
        lib/Chronicle/Chronicle.php on lines 45..45
        lib/Chronicle/Chronicle.php on lines 46..46
        lib/Images/Competition.php on lines 150..150
        lib/Jobs/Job.php on lines 196..196
        lib/Locos/Locomotive.php on lines 432..432
        lib/Locos/Locomotive.php on lines 433..433
        lib/Railcams/Camera.php on lines 258..258
        lib/Railcams/Camera.php on lines 259..259
        lib/Railcams/Camera.php on lines 261..261
        lib/Railcams/Camera.php on lines 262..262
        lib/Railcams/Camera.php on lines 263..263
        lib/Railcams/Camera.php on lines 264..264
        lib/Railcams/Camera.php on lines 266..266
        lib/Timetables/Point.php on lines 115..115
        lib/Timetables/Timetables.php on lines 41..41
        lib/Timetables/Timetables.php on lines 42..42
        lib/Timetables/Timetables.php on lines 43..43
        lib/Timetables/Train.php on lines 183..183
        lib/Users/Group.php on lines 222..222

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 25.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                foreach ($result as $row) {
                    $return['members'][$row['user_id']] = $row;
                }
        Severity: Major
        Found in lib/Users/Group.php and 2 other locations - About 45 mins to fix
        lib/Forums/Forum.php on lines 511..513
        lib/Users/Utility/UserUtility.php on lines 211..213

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 25.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                $mckey = sprintf("railpage:group=%d.user_id=%d", $this->id, $userObject->id);
        Severity: Major
        Found in lib/Users/Group.php and 3 other locations - About 40 mins to fix
        lib/Locos/Utility/CoverImageUtility.php on lines 83..83
        lib/Place.php on lines 381..381
        lib/Place.php on lines 403..403

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 24.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        $this->Redis->save($mckey, "yes", strtotime("+1 day")); 
        Severity: Minor
        Found in lib/Users/Group.php and 1 other location - About 40 mins to fix
        lib/Users/Timeline.php on lines 231..231

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 24.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 10 locations. Consider refactoring.
        Open

                if (!$userObject instanceof User) {
                    throw new Exception("No instance of \\Railpage\\Users\\User provided"); 
                }
        Severity: Major
        Found in lib/Users/Group.php and 9 other locations - About 35 mins to fix
        lib/Chronicle/Provider/Locos.php on lines 45..47
        lib/Chronicle/Provider/Locos.php on lines 49..51
        lib/Chronicle/Provider/Railcams.php on lines 49..51
        lib/Chronicle/Provider/Railcams.php on lines 53..55
        lib/Events/Event.php on lines 388..390
        lib/Locos/Locos.php on lines 769..771
        lib/Locos/Locos.php on lines 772..774
        lib/Notifications/Notification.php on lines 304..306
        lib/Railcams/Footage.php on lines 139..141

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 22.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                $mckey = sprintf("railpage:group=%d.user_id=%d", $this->id, $userId);
        Severity: Major
        Found in lib/Users/Group.php and 3 other locations - About 35 mins to fix
        lib/Forums/Forums.php on lines 1113..1113
        lib/Forums/Forums.php on lines 1193..1193
        lib/Images/Image.php on lines 1099..1099

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 22.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    $this->owner_user_id = $this->db->fetchOne($query, $this->owner_username); 
        Severity: Minor
        Found in lib/Users/Group.php and 1 other location - About 35 mins to fix
        lib/Links/Category.php on lines 130..130

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 22.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 9 locations. Consider refactoring.
        Open

                if (!filter_var($groupId, FILTER_VALIDATE_INT)) {
                    return;
                }
        Severity: Major
        Found in lib/Users/Group.php and 8 other locations - About 30 mins to fix
        lib/Chronicle/Entry.php on lines 140..142
        lib/Chronicle/EntryType.php on lines 80..82
        lib/Events/EventDate.php on lines 143..145
        lib/Feedback/FeedbackItem.php on lines 120..122
        lib/GTFS/StandardRoute.php on lines 68..70
        lib/GTFS/StandardStop.php on lines 97..99
        lib/Ideas/Ideas.php on lines 185..187
        lib/Images/Camera.php on lines 98..100

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 21.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 5 locations. Consider refactoring.
        Open

                    $data = [
                        "group_id" => $this->id,
                        "user_id" => $userId
                    ];
        Severity: Major
        Found in lib/Users/Group.php and 4 other locations - About 30 mins to fix
        lib/Locations/Location.php on lines 864..867
        lib/PrivateMessages/Message.php on lines 528..531
        lib/Users/Group.php on lines 327..330
        lib/Users/Group.php on lines 504..507

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 20.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 5 locations. Consider refactoring.
        Open

                $data = [ 
                    "group_id" => $this->id,
                    "user_id" => $userId
                ];
        Severity: Major
        Found in lib/Users/Group.php and 4 other locations - About 30 mins to fix
        lib/Locations/Location.php on lines 864..867
        lib/PrivateMessages/Message.php on lines 528..531
        lib/Users/Group.php on lines 304..307
        lib/Users/Group.php on lines 504..507

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 20.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 5 locations. Consider refactoring.
        Open

                $where = [ 
                    "group_id = ?" => $this->id, 
                    "user_id = ?" => $userId
                ]; 
        Severity: Major
        Found in lib/Users/Group.php and 4 other locations - About 30 mins to fix
        lib/Locations/Location.php on lines 864..867
        lib/PrivateMessages/Message.php on lines 528..531
        lib/Users/Group.php on lines 304..307
        lib/Users/Group.php on lines 327..330

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 20.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Blank line found at start of control structure
        Open

                if (filter_var($row['organisation_id'], FILTER_VALIDATE_INT) && $row['organisation_id'] !== 0) {
        Severity: Minor
        Found in lib/Users/Group.php by phpcodesniffer

        Function closing brace must go on the next line following the body; found 1 blank lines before brace
        Open

            }
        Severity: Minor
        Found in lib/Users/Group.php by phpcodesniffer

        Blank line found at end of control structure
        Open

                    
        Severity: Minor
        Found in lib/Users/Group.php by phpcodesniffer

        Blank line found at end of control structure
        Open

                    
        Severity: Minor
        Found in lib/Users/Group.php by phpcodesniffer

        Function closing brace must go on the next line following the body; found 1 blank lines before brace
        Open

            }
        Severity: Minor
        Found in lib/Users/Group.php by phpcodesniffer

        Blank line found at start of control structure
        Open

                if (!$row = $this->Redis->fetch($mckey)) {
        Severity: Minor
        Found in lib/Users/Group.php by phpcodesniffer

        Blank line found at start of control structure
        Open

                if (filter_var($this->id, FILTER_VALIDATE_INT)) {
        Severity: Minor
        Found in lib/Users/Group.php by phpcodesniffer

        Function closing brace must go on the next line following the body; found 1 blank lines before brace
        Open

            }
        Severity: Minor
        Found in lib/Users/Group.php by phpcodesniffer

        There are no issues that match your filters.

        Category
        Status