railpage/railpagecore

View on GitHub
lib/PrivateMessages/PrivateMessages.php

Summary

Maintainability
F
3 days
Test Coverage

Function deleteObjects has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

        public function deleteObjects($object_id = false) {
            if (!$object_id) {
                //throw new Exception("Cannot delete objects - no object ID given"); 
                return false;
            } 
Severity: Minor
Found in lib/PrivateMessages/PrivateMessages.php - About 4 hrs 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 getDeleted has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

        public function getDeleted($user_id = false) {
            if (!$user_id) {
                throw new Exception("Cannot fetch deleted message IDs - no user ID given"); 
                return false;
            }
Severity: Minor
Found in lib/PrivateMessages/PrivateMessages.php - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method deleteObjects has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function deleteObjects($object_id = false) {
            if (!$object_id) {
                //throw new Exception("Cannot delete objects - no object ID given"); 
                return false;
            } 
Severity: Minor
Found in lib/PrivateMessages/PrivateMessages.php - About 1 hr to fix

    Method getUnread has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function getUnread() {
                if (!$this->User->id) {
                    throw new Exception("Cannot fetch unread PMs - not a registered user");
                    return false;
                }
    Severity: Minor
    Found in lib/PrivateMessages/PrivateMessages.php - About 1 hr to fix

      Function getUnread has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              public function getUnread() {
                  if (!$this->User->id) {
                      throw new Exception("Cannot fetch unread PMs - not a registered user");
                      return false;
                  }
      Severity: Minor
      Found in lib/PrivateMessages/PrivateMessages.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method getDeleted has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function getDeleted($user_id = false) {
                  if (!$user_id) {
                      throw new Exception("Cannot fetch deleted message IDs - no user ID given"); 
                      return false;
                  }
      Severity: Minor
      Found in lib/PrivateMessages/PrivateMessages.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                            return true;
        Severity: Major
        Found in lib/PrivateMessages/PrivateMessages.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                                  return false;
          Severity: Major
          Found in lib/PrivateMessages/PrivateMessages.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                return false;
            Severity: Major
            Found in lib/PrivateMessages/PrivateMessages.php - About 30 mins to fix

              The method deleteObjects() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
              Open

                      public function deleteObjects($object_id = false) {
                          if (!$object_id) {
                              //throw new Exception("Cannot delete objects - no object ID given"); 
                              return false;
                          } 

              CyclomaticComplexity

              Since: 0.1

              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

              Example

              // Cyclomatic Complexity = 11
              class Foo {
              1   public function example() {
              2       if ($a == $b) {
              3           if ($a1 == $b1) {
                              fiddle();
              4           } elseif ($a2 == $b2) {
                              fiddle();
                          } else {
                              fiddle();
                          }
              5       } elseif ($c == $d) {
              6           while ($c == $d) {
                              fiddle();
                          }
              7        } elseif ($e == $f) {
              8           for ($n = 0; $n < $h; $n++) {
                              fiddle();
                          }
                      } else {
                          switch ($z) {
              9               case 1:
                                  fiddle();
                                  break;
              10              case 2:
                                  fiddle();
                                  break;
              11              case 3:
                                  fiddle();
                                  break;
                              default:
                                  fiddle();
                                  break;
                          }
                      }
                  }
              }

              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

              The method __construct has a boolean flag argument $user, which is a certain sign of a Single Responsibility Principle violation.
              Open

                      public function __construct($db = false, $user = false) {

              BooleanArgumentFlag

              Since: 1.4.0

              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

              Example

              class Foo {
                  public function bar($flag = true) {
                  }
              }

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

              The method deleteObjects has a boolean flag argument $object_id, which is a certain sign of a Single Responsibility Principle violation.
              Open

                      public function deleteObjects($object_id = false) {

              BooleanArgumentFlag

              Since: 1.4.0

              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

              Example

              class Foo {
                  public function bar($flag = true) {
                  }
              }

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

              The method __construct has a boolean flag argument $db, which is a certain sign of a Single Responsibility Principle violation.
              Open

                      public function __construct($db = false, $user = false) {

              BooleanArgumentFlag

              Since: 1.4.0

              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

              Example

              class Foo {
                  public function bar($flag = true) {
                  }
              }

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

              The method getDeleted has a boolean flag argument $user_id, which is a certain sign of a Single Responsibility Principle violation.
              Open

                      public function getDeleted($user_id = false) {

              BooleanArgumentFlag

              Since: 1.4.0

              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

              Example

              class Foo {
                  public function bar($flag = true) {
                  }
              }

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

              The method deleteObjects uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                          } else {
                              $query = "SELECT privmsgs_id FROM nuke_bbprivmsgs WHERE object_id = ?";
                              
                              $ids = array();
                              

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method deleteObjects uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                              } else {
                                  throw new Exception($this->db->error."\n".$query); 
                                  return false;
                              }

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

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

                      public function getUnread() {
                          if (!$this->User->id) {
                              throw new Exception("Cannot fetch unread PMs - not a registered user");
                              return false;
                          }

              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

              The method getUnread uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                          } else {
                              $query = "SELECT DISTINCT p.privmsgs_id, p.privmsgs_subject, p.privmsgs_from_userid AS from_user_id, p.privmsgs_date, u.username AS from_username, pt.privmsgs_text
                                          FROM nuke_bbprivmsgs AS p
                                          LEFT JOIN nuke_bbprivmsgs_text AS pt ON p.privmsgs_id = pt.privmsgs_text_id
                                          LEFT JOIN nuke_users AS u ON u.user_id = p.privmsgs_from_userid

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method deleteObjects uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                                          } else {
                                              throw new Exception($this->db->error."\n".$query); 
                                              return false;
                                          }

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method getDeleted uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                          } else {
                              $query = "SELECT privmsgs_id FROM privmsgs_hidelist WHERE user_id = ?";
                              
                              $return = array();
                              foreach ($this->db->fetchAll($query, $user_id) as $row) {

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method getUnread uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                              } else {
                                  throw new Exception($this->db->error); 
                                  return false;
                              }

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

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

                      public function getAllMessages($items_per_page = 25, $page = 1) {
                          if (!filter_var($items_per_page, FILTER_VALIDATE_INT)) {
                              throw new Exception("Cannot fetch messages - invalid items_per_page parameter provided");
                          }
                          

              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 '196', column '21').
              Open

                      public function getDeleted($user_id = false) {
                          if (!$user_id) {
                              throw new Exception("Cannot fetch deleted message IDs - no user ID given"); 
                              return false;
                          }

              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

              The method deleteObjects uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                                      } else {
                                          throw new Exception($this->db->error."\n".$query); 
                                          return false;
                                      }

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

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

                      public function deleteObjects($object_id = false) {
                          if (!$object_id) {
                              //throw new Exception("Cannot delete objects - no object ID given"); 
                              return false;
                          } 

              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

              The method getDeleted uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                              } else {
                                  throw new Exception($this->db->error."\n\n".$query); 
                              }

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method deleteObjects uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                                  } else {
                                      return false;
                                  }

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              Avoid unused parameters such as '$user'.
              Open

                      public function __construct($db = false, $user = false) {

              UnusedFormalParameter

              Since: 0.2

              Avoid passing parameters to methods or constructors and then not using those parameters.

              Example

              class Foo
              {
                  private function bar($howdy)
                  {
                      // $howdy is not used
                  }
              }

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

              Avoid unused parameters such as '$db'.
              Open

                      public function __construct($db = false, $user = false) {

              UnusedFormalParameter

              Since: 0.2

              Avoid passing parameters to methods or constructors and then not using those parameters.

              Example

              class Foo
              {
                  private function bar($howdy)
                  {
                      // $howdy is not used
                  }
              }

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

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

                              $users[$key]['avatar'] = array(
                                  "tiny" => AvatarUtility::Format($row['user_avatar'], 25, 25),
                                  "thumb" => AvatarUtility::Format($row['user_avatar'], 50, 50),
                                  "small" => AvatarUtility::Format($row['user_avatar'], 75, 75),
                                  "medium" => AvatarUtility::Format($row['user_avatar'], 100, 100)
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 1 other location - About 3 hrs to fix
              lib/Images/Camera.php on lines 287..292

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

              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 ($rs = $this->db->query($query)) {
                                  $return = array(); 
                                  while ($row = $rs->fetch_assoc()) {
                                      $return[$row['privmsgs_id']] = $row; 
                                  }
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 1 other location - About 3 hrs to fix
              lib/Forums/Stats.php on lines 232..242

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

              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

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

                              foreach ($this->db->fetchAll($query, $user_id) as $row) {
                                  if (!in_array($row['privmsgs_id'], $return)) {
                                      $return[] = $row['privmsgs_id']; 
                                  }
                              }
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 1 other location - About 1 hr to fix
              lib/PrivateMessages/PrivateMessages.php on lines 199..203

              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

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

                                  while ($row = $rs->fetch_assoc()) {
                                      if (!in_array($row['privmsgs_id'], $return)) {
                                          $return[] = $row['privmsgs_id']; 
                                      }
                                  }
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 1 other location - About 1 hr to fix
              lib/PrivateMessages/PrivateMessages.php on lines 213..217

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

                                  $this->db->delete("nuke_bbprivmsgs_text", "privmsgs_text_id IN ('" . implode("','", $ids) . "')"); 
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 1 other location - About 1 hr to fix
              lib/PrivateMessages/PrivateMessages.php on lines 173..173

              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

                                  $this->db->delete("nuke_bbprivmsgs", "privmsgs_id IN ('" . implode("','", $ids) . "')"); 
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 1 other location - About 1 hr to fix
              lib/PrivateMessages/PrivateMessages.php on lines 174..174

              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

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

                              if ($rs = $this->db->query($query)) {
                                  $ids = array(); 
                                  while ($row = $rs->fetch_assoc()) {
                                      $ids[] = $row['privmsgs_id']; 
                                  }
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 2 other locations - About 1 hr to fix
              lib/PrivateMessages/PrivateMessages.php on lines 146..151
              lib/PrivateMessages/PrivateMessages.php on lines 145..155

              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

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

                                      if ($this->db->query("DELETE FROM nuke_bbprivmsgs WHERE privmsgs_id IN ('".implode("','", $ids)."')")) {
                                          if ($this->db->query("DELETE FROM nuke_bbprivmsgs_text WHERE privmsgs_text_id IN ('".implode("','", $ids)."')")) {
                                              return true;
                                          } else {
                                              throw new Exception($this->db->error."\n".$query); 
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 2 other locations - About 1 hr to fix
              lib/PrivateMessages/PrivateMessages.php on lines 146..151
              lib/PrivateMessages/PrivateMessages.php on lines 138..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 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

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

                                          if ($this->db->query("DELETE FROM nuke_bbprivmsgs_text WHERE privmsgs_text_id IN ('".implode("','", $ids)."')")) {
                                              return true;
                                          } else {
                                              throw new Exception($this->db->error."\n".$query); 
                                              return false;
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 2 other locations - About 1 hr to fix
              lib/PrivateMessages/PrivateMessages.php on lines 145..155
              lib/PrivateMessages/PrivateMessages.php on lines 138..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 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

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

                              if ($rs = $this->db->query($query)) {
                                  $return = array(); 
                                  
                                  while ($row = $rs->fetch_assoc()) {
                                      if (!in_array($row['privmsgs_id'], $return)) {
              Severity: Minor
              Found in lib/PrivateMessages/PrivateMessages.php and 1 other location - About 45 mins to fix
              lib/Jobs/Locations.php on lines 35..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 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

                          if ($result = $this->db->fetchAll($query, array($page, $items_per_page))) {
                              $return['total'] = $this->db_readonly->fetchOne("SELECT FOUND_ROWS() AS total"); 
                              
                              foreach ($result as $row) {
                                  $Date = new DateTime;
              Severity: Major
              Found in lib/PrivateMessages/PrivateMessages.php and 3 other locations - About 40 mins to fix
              lib/SiteEvent/Base.php on lines 44..60
              lib/Timetables/Point.php on lines 82..87
              lib/Users/Admin.php on lines 161..182

              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

                                  while ($row = $rs->fetch_assoc()) {
                                      $ids[] = $row['privmsgs_id']; 
                                  }
              Severity: Minor
              Found in lib/PrivateMessages/PrivateMessages.php and 1 other location - About 40 mins to fix
              lib/PrivateMessages/User.php on lines 62..64

              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

              The parameter $items_per_page is not named in camelCase.
              Open

                      public function getAllMessages($items_per_page = 25, $page = 1) {
                          if (!filter_var($items_per_page, FILTER_VALIDATE_INT)) {
                              throw new Exception("Cannot fetch messages - invalid items_per_page parameter provided");
                          }
                          

              CamelCaseParameterName

              Since: 0.2

              It is considered best practice to use the camelCase notation to name parameters.

              Example

              class ClassName {
                  public function doSomething($user_name) {
                  }
              }

              Source

              The parameter $object_id is not named in camelCase.
              Open

                      public function deleteObjects($object_id = false) {
                          if (!$object_id) {
                              //throw new Exception("Cannot delete objects - no object ID given"); 
                              return false;
                          } 

              CamelCaseParameterName

              Since: 0.2

              It is considered best practice to use the camelCase notation to name parameters.

              Example

              class ClassName {
                  public function doSomething($user_name) {
                  }
              }

              Source

              The parameter $user_id is not named in camelCase.
              Open

                      public function getDeleted($user_id = false) {
                          if (!$user_id) {
                              throw new Exception("Cannot fetch deleted message IDs - no user ID given"); 
                              return false;
                          }

              CamelCaseParameterName

              Since: 0.2

              It is considered best practice to use the camelCase notation to name parameters.

              Example

              class ClassName {
                  public function doSomething($user_name) {
                  }
              }

              Source

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

                      }

              There must be one blank line after the namespace declaration
              Open

                  namespace Railpage\PrivateMessages;

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  while ($row = $rs->fetch_assoc()) {

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  if (count($ids)) {

              Line indented incorrectly; expected 24 spaces, found 28
              Open

                                          if ($this->db->query("DELETE FROM nuke_bbprivmsgs_text WHERE privmsgs_text_id IN ('".implode("','", $ids)."')")) {

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              if ($rs = $this->db->query($query)) {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      }

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      public function __construct($db = false, $user = false) {

              Line indented incorrectly; expected 0 spaces, found 4
              Open

                  }

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      public $db;

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          if (!$this->User->id) {

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  } else {

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              if (count($ids)) {

              Line indented incorrectly; expected 12 spaces, found 16
              Open

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

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          } else {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          if (!$user_id) {

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      public function getMostContactedUsers() {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          foreach (func_get_args() as $arg) {

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              foreach ($this->db->fetchAll($query, array(PRIVMSGS_UNREAD_MAIL, PRIVMSGS_NEW_MAIL, $this->User->id)) as $row) {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          if ($this->db instanceof \sql_db) {

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              } else {

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  if (!in_array($row['privmsgs_id'], $return)) {

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              }

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  }

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      public function deleteObjects($object_id = false) {

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 20 spaces, found 24
              Open

                                      if ($this->db->query("DELETE FROM nuke_bbprivmsgs WHERE privmsgs_id IN ('".implode("','", $ids)."')")) {

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              if ($rs = $this->db->query($query)) {

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

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

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

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

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              foreach ($result as $row) {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          if (!$this->Author instanceof User) {

              Line indented incorrectly; expected 0 spaces, found 4
              Open

                  if (!defined("PRIVMSGS_READ_MAIL")) {

              Line indented incorrectly; expected 0 spaces, found 4
              Open

                  class PrivateMessages extends AppCore {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          } else {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          if ($result = $this->db->fetchAll($query, array($page, $items_per_page))) {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          foreach ($users as $key => $row) {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          if ($this->db instanceof \sql_db) {

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              if ($rs = $this->db->query($query)) {

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  while ($row = $rs->fetch_assoc()) {

              Line indented incorrectly; expected 20 spaces, found 24
              Open

                                      }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          } else {

              Line indented incorrectly; expected 20 spaces, found 24
              Open

                                      }

              Line indented incorrectly; expected 0 spaces, found 4
              Open

                  }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              }

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      public function getUnread() {

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      public function getAllMessages($items_per_page = 25, $page = 1) {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              if ($arg instanceof User) {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          if (!$object_id) {

              Line indented incorrectly; expected 24 spaces, found 28
              Open

                                          }

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      }

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  while ($row = $rs->fetch_assoc()) {

              Line indented incorrectly; expected 20 spaces, found 24
              Open

                                      if (!in_array($row['privmsgs_id'], $return)) {

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

                          if ($this->db instanceof \sql_db) {

              Line indented incorrectly; expected 16 spaces, found 20
              Open

                                  }

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              } else {

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              } else {

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      public function getDeleted($user_id = false) {

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      }

              Line indented incorrectly; expected 8 spaces, found 12
              Open

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

              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

                          } 

              Line indented incorrectly; expected 24 spaces, found 28
              Open

                                          } else {

              Line indented incorrectly; expected 20 spaces, found 24
              Open

                                      } else {

              Line indented incorrectly; expected 12 spaces, found 16
              Open

                              }

              There are no issues that match your filters.

              Category
              Status