railpage/railpagecore

View on GitHub
lib/Feedback/Feedback.php

Summary

Maintainability
C
1 day
Test Coverage

Method getAssignedItems has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getAssignedItems() {
        if (!$this->Staff instanceof User) {
            throw new Exception("You must assign a valid User object before fetching assigned feedback items");
        }
        
Severity: Minor
Found in lib/Feedback/Feedback.php - About 1 hr to fix

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

        public function getFeedbackItems() {
            $query = "SELECT f.*, fs.name AS status_text, fa.feedback_title AS area_text
                    FROM feedback AS f 
                    INNER JOIN feedback_status AS fs ON f.status = fs.id
                    INNER JOIN feedback_area AS fa ON f.area = fa.feedback_id
    Severity: Major
    Found in lib/Feedback/Feedback.php and 5 other locations - About 1 hr to fix
    lib/Forums/Forums.php on lines 499..505
    lib/Ideas/Ideas.php on lines 92..100
    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 2 locations. Consider refactoring.
    Open

                    $data['author']['avatar'] = array(
                        "large" => format_avatar($Author->avatar, 120),
                        "small" => format_avatar($Author->avatar, 40)
                    );
    Severity: Major
    Found in lib/Feedback/Feedback.php and 1 other location - About 1 hr to fix
    lib/Gallery/Album.php on lines 404..407

    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

                if (filter_var($row['user_id'], FILTER_VALIDATE_INT) && $row['user_id'] > 0) {
                    $Author = new User($row['user_id']);
                    $data['author']['id'] = $Author->id;
                    $data['author']['username'] = $Author->username;
                    $data['author']['realname'] = $Author->real_name;
    Severity: Major
    Found in lib/Feedback/Feedback.php and 1 other location - About 1 hr to fix
    lib/Forums/Forum.php on lines 235..237

    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

                $date = new DateTime(sprintf("@%s", $row['time']));
    Severity: Minor
    Found in lib/Feedback/Feedback.php and 1 other location - About 55 mins to fix
    lib/Forums/Forums.php on lines 768..768

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

    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

                    "status" => array(
                        "id" => $row['status'],
                        "text" => $row['status_text'],
                    ),
    Severity: Major
    Found in lib/Feedback/Feedback.php and 4 other locations - About 40 mins to fix
    lib/Feedback/Feedback.php on lines 88..91
    lib/Locations/Locations.php on lines 577..580
    lib/Timetables/Timetables.php on lines 138..141
    lib/Place.php on lines 511..514

    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 5 locations. Consider refactoring.
    Open

                    "area" => array(
                        "id" => $row['area'],
                        "text" => $row['area_text'],
                    ),
    Severity: Major
    Found in lib/Feedback/Feedback.php and 4 other locations - About 40 mins to fix
    lib/Feedback/Feedback.php on lines 92..95
    lib/Locations/Locations.php on lines 577..580
    lib/Timetables/Timetables.php on lines 138..141
    lib/Place.php on lines 511..514

    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 25 locations. Consider refactoring.
    Open

        public function setStaff(User $userObject) {
            $this->Staff = $userObject;
            
            return $this;
        }
    Severity: Major
    Found in lib/Feedback/Feedback.php and 24 other locations - About 40 mins to fix
    lib/Gallery/Album.php on lines 279..285
    lib/Gallery/Album.php on lines 317..323
    lib/Gallery/Image.php on lines 278..284
    lib/Gallery/Image.php on lines 460..466
    lib/Glossary/Entry.php on lines 302..306
    lib/Locations/Correction.php on lines 118..124
    lib/News/Article.php on lines 941..945
    lib/Prerender/Prerender.php on lines 89..94
    lib/Railcams/Footage.php on lines 89..95
    lib/Railcams/Photo.php on lines 143..147
    lib/Railcams/Storage.php on lines 95..101
    lib/Railcams/Storage.php on lines 110..116
    lib/SiteMessages/SiteMessage.php on lines 206..210
    lib/Timetables/Timetables.php on lines 52..56
    lib/Timetables/Timetables.php on lines 64..68
    lib/Timetables/Timetables.php on lines 76..80
    lib/Users/SockpuppetManager.php on lines 61..67
    lib/Warnings/Warning.php on lines 249..255
    lib/Warnings/Warning.php on lines 267..273
    lib/AppCore.php on lines 401..407
    lib/AppCore.php on lines 416..422
    lib/AppCore.php on lines 431..437
    lib/AppCore.php on lines 463..469
    lib/AppCore.php on lines 478..484

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

    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

    There are no issues that match your filters.

    Category
    Status