railpage/railpagecore

View on GitHub
lib/Ideas/Ideas.php

Summary

Maintainability
D
2 days
Test Coverage

Method getStatusDescription has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getStatusDescription($statusId = null) {
        if (!filter_var($statusId, FILTER_VALIDATE_INT)) {
            return;
        }
        
Severity: Minor
Found in lib/Ideas/Ideas.php - About 1 hr to fix

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

        public static function getStatusDescription($statusId = null) {
            if (!filter_var($statusId, FILTER_VALIDATE_INT)) {
                return;
            }
            
    Severity: Minor
    Found in lib/Ideas/Ideas.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

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

        public function getIdeasByUser($page = 1, $itemsPerPage = 25) {
            if (!$this->User instanceof User) {
                throw new Exception("You must set a valid user before you can find ideas created by a user");
            }
            
    Severity: Minor
    Found in lib/Ideas/Ideas.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 3 locations. Consider refactoring.
    Open

        public function getMostVoted($num = 10) {
            
            $query = "SELECT count(v.idea_id) AS num, v.idea_id FROM idea_votes AS v JOIN idea_ideas AS i ON v.idea_id = i.id GROUP BY v.idea_id ORDER BY num DESC LIMIT 0, ?";
            
            foreach ($this->db->fetchAll($query, $num) as $row) {
    Severity: Major
    Found in lib/Ideas/Ideas.php and 2 other locations - About 1 hr to fix
    lib/Ideas/Ideas.php on lines 109..117
    lib/Jobs/Jobs.php on lines 168..175

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

    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

        public function getNewIdeas($num = 10) {
            
            $query = "SELECT id FROM idea_ideas ORDER BY date DESC LIMIT 0, ?";
            
            foreach ($this->db->fetchAll($query, $num) as $row) {
    Severity: Major
    Found in lib/Ideas/Ideas.php and 2 other locations - About 1 hr to fix
    lib/Ideas/Ideas.php on lines 126..134
    lib/Jobs/Jobs.php on lines 168..175

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

    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 getCategories() {
            
            $query = "SELECT id FROM idea_categories ORDER BY title";
            
            foreach ($this->db->fetchAll($query) as $row) {
    Severity: Major
    Found in lib/Ideas/Ideas.php and 5 other locations - About 1 hr to fix
    lib/Feedback/Feedback.php on lines 32..43
    lib/Forums/Forums.php on lines 499..505
    lib/SiteMessage/SiteMessage.php on lines 109..115
    lib/SiteMessages/SiteMessages.php on lines 26..32
    lib/Timetables/Timetables.php on lines 156..162

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

    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

                case self::STATUS_INPROGRESS:
                    $text = "In progress";
                    $badge = sprintf($badge, "info", "wrench", $text);
                    break;
    Severity: Major
    Found in lib/Ideas/Ideas.php and 4 other locations - About 1 hr to fix
    lib/Ideas/Ideas.php on lines 192..195
    lib/Ideas/Ideas.php on lines 202..205
    lib/Ideas/Ideas.php on lines 207..210
    lib/Ideas/Ideas.php on lines 217..220

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

    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

                case self::STATUS_IMPLEMENTED:
                    $text = "Implemented!";
                    $badge = sprintf($badge, "success", "ok", $text);
                    break;
    Severity: Major
    Found in lib/Ideas/Ideas.php and 4 other locations - About 1 hr to fix
    lib/Ideas/Ideas.php on lines 192..195
    lib/Ideas/Ideas.php on lines 202..205
    lib/Ideas/Ideas.php on lines 212..215
    lib/Ideas/Ideas.php on lines 217..220

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

    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

                case self::STATUS_UNDERCONSIDERATION:
                    $text = "Under consideration";
                    $badge = sprintf($badge, "info", "tasks", $text);
                    break;
    Severity: Major
    Found in lib/Ideas/Ideas.php and 4 other locations - About 1 hr to fix
    lib/Ideas/Ideas.php on lines 192..195
    lib/Ideas/Ideas.php on lines 202..205
    lib/Ideas/Ideas.php on lines 207..210
    lib/Ideas/Ideas.php on lines 212..215

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

    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

                case self::STATUS_DELETED:
                    $text = "Deleted";
                    $badge = sprintf($badge, "danger", "remove", $text);
                    break;
    Severity: Major
    Found in lib/Ideas/Ideas.php and 4 other locations - About 1 hr to fix
    lib/Ideas/Ideas.php on lines 202..205
    lib/Ideas/Ideas.php on lines 207..210
    lib/Ideas/Ideas.php on lines 212..215
    lib/Ideas/Ideas.php on lines 217..220

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

    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

                case self::STATUS_NO:
                    $text = "Will not implement";
                    $badge = sprintf($badge, "warning", "remove", $text);
                    break;
    Severity: Major
    Found in lib/Ideas/Ideas.php and 4 other locations - About 1 hr to fix
    lib/Ideas/Ideas.php on lines 192..195
    lib/Ideas/Ideas.php on lines 207..210
    lib/Ideas/Ideas.php on lines 212..215
    lib/Ideas/Ideas.php on lines 217..220

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

    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

            $params = array(
                $this->User->id,
                ($page - 1) * $itemsPerPage, 
                $itemsPerPage 
            );
    Severity: Minor
    Found in lib/Ideas/Ideas.php and 1 other location - About 55 mins to fix
    lib/Images/Screener.php on lines 53..57

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

    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 __construct() {
            
            parent::__construct();
            
            $this->Module = new Module("ideas");
    Severity: Major
    Found in lib/Ideas/Ideas.php and 5 other locations - About 50 mins to fix
    lib/Gallery/Gallery.php on lines 30..36
    lib/Help/Help.php on lines 27..33
    lib/Images/Competitions.php on lines 91..94
    lib/Jobs/Jobs.php on lines 35..41
    lib/Reminders/Reminders.php on lines 28..34

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

    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($statusId, FILTER_VALIDATE_INT)) {
                return;
            }
    Severity: Major
    Found in lib/Ideas/Ideas.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/Images/Camera.php on lines 98..100
    lib/Users/Group.php on lines 127..129

    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

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

        }
    Severity: Minor
    Found in lib/Ideas/Ideas.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/Ideas/Ideas.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/Ideas/Ideas.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/Ideas/Ideas.php by phpcodesniffer

    Blank line found at end of control structure
    Open

                    
    Severity: Minor
    Found in lib/Ideas/Ideas.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status