railpage/railpagecore

View on GitHub
lib/PrivateMessages/Conversation.php

Summary

Maintainability
A
3 hrs
Test Coverage

Method fetch has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function fetch() {
            $user_ids = array_keys($this->users);
            
            // If only one user account found, we must've sent ourselves a PM...
            if (count($user_ids) === 1) {
Severity: Minor
Found in lib/PrivateMessages/Conversation.php - About 1 hr to fix

    Avoid using undefined variables such as '$User' which will lead to PHP notices.
    Open

                        $this->setUser($User);
    Severity: Minor
    Found in lib/PrivateMessages/Conversation.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid unused local variables such as '$User'.
    Open

                        $this->setUser($User);
    Severity: Minor
    Found in lib/PrivateMessages/Conversation.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

                    if (filter_var($arg, FILTER_VALIDATE_INT)) {
                        $this->load($arg); 
                    }
    Severity: Major
    Found in lib/PrivateMessages/Conversation.php and 2 other locations - About 50 mins to fix
    lib/Forums/Category.php on lines 74..76
    lib/Locos/Operator.php on lines 81..83

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

                $this->subject = str_replace("Re: ", "", $row['privmsgs_subject']); 
    Severity: Minor
    Found in lib/PrivateMessages/Conversation.php and 1 other location - About 45 mins to fix
    lib/Downloads/Download.php on lines 227..227

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

                $exclude_sql = count($deleted) > 0 ? " AND privmsgs_id NOT IN ('".implode("', '", $deleted)."') " : "";
    Severity: Minor
    Found in lib/PrivateMessages/Conversation.php and 1 other location - About 30 mins to fix
    lib/Users/Admin.php on lines 149..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 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

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $subject;

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach (func_get_args() as $arg) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $users;

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!filter_var($id, FILTER_VALIDATE_INT)) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->subject) || empty($this->users) || count($user_ids) != 2) {

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        class Conversation extends PrivateMessages {

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if (filter_var($arg, FILTER_VALIDATE_INT)) {

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            } 

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function fetch() {

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function load($id = NULL) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (count($user_ids) === 1) {

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if ($arg instanceof User) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach ($this->db->fetchAll($query, $params) as $row) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function __construct() {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    There are no issues that match your filters.

    Category
    Status