railpage/railpagecore

View on GitHub
lib/PrivateMessages/Message.php

Summary

Maintainability
F
3 days
Test Coverage

Method send has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function send() {
        
        $this->validate();
        
        $data = array(
Severity: Major
Found in lib/PrivateMessages/Message.php - About 2 hrs to fix

    Method commit has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function commit() {
            if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                throw new Exception("Cannot commit changes to PM - PM does not exist!"); 
            } 
            
    Severity: Minor
    Found in lib/PrivateMessages/Message.php - About 1 hr to fix

      The class Message has 23 fields. Consider redesigning Message to keep the number of fields under 15.
      Open

      class Message extends PrivateMessages {
          
          /** 
           * Message ID
           * @since Version 3.3
      Severity: Minor
      Found in lib/PrivateMessages/Message.php by phpmd

      TooManyFields

      Since: 0.1

      Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

      Example

      class Person {
         protected $one;
         private $two;
         private $three;
         [... many more fields ...]
      }

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

      Function validate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function validate() {
              if (is_null($this->object_id)) {
                  $this->object_id = "";
              }
              
      Severity: Minor
      Found in lib/PrivateMessages/Message.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 validate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function validate() {
              if (is_null($this->object_id)) {
                  $this->object_id = "";
              }
              
      Severity: Minor
      Found in lib/PrivateMessages/Message.php - About 1 hr to fix

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

            public function fetch() {
                if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                    throw new Exception("Cannot fetch PM - no message ID provided");
                }
                
        Severity: Minor
        Found in lib/PrivateMessages/Message.php - About 1 hr to fix

          The method validate() has an NPath complexity of 3072. The configured NPath complexity threshold is 200.
          Open

              public function validate() {
                  if (is_null($this->object_id)) {
                      $this->object_id = "";
                  }
                  
          Severity: Minor
          Found in lib/PrivateMessages/Message.php by phpmd

          NPathComplexity

          Since: 0.1

          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

          Example

          class Foo {
              function bar() {
                  // lots of complicated code
              }
          }

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

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

              public function validate() {
                  if (is_null($this->object_id)) {
                      $this->object_id = "";
                  }
                  
          Severity: Minor
          Found in lib/PrivateMessages/Message.php by phpmd

          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 delete has a boolean flag argument $user_id, which is a certain sign of a Single Responsibility Principle violation.
          Open

              public function delete($user_id = false) {
          Severity: Minor
          Found in lib/PrivateMessages/Message.php by phpmd

          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 $id, which is a certain sign of a Single Responsibility Principle violation.
          Open

              public function __construct($id = false) {
          Severity: Minor
          Found in lib/PrivateMessages/Message.php by phpmd

          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 commit uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      // Insert
                      
                      $this->db->insert("nuke_bbprivmsgs", $dataArray); 
                      $this->id = $this->db->lastInsertId(); 
          Severity: Minor
          Found in lib/PrivateMessages/Message.php by phpmd

          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 '250', column '14').
          Open

              public function fetch() {
                  if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                      throw new Exception("Cannot fetch PM - no message ID provided");
                  }
                  
          Severity: Minor
          Found in lib/PrivateMessages/Message.php by phpmd

          IfStatementAssignment

          Since: 2.7.0

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

          Example

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

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

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

                  $rs = $this->db->insert("nuke_bbprivmsgs_text", $data); 
          Severity: Minor
          Found in lib/PrivateMessages/Message.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 2 locations. Consider refactoring.
          Open

              public function setRecipient(User $User = NULL) {
                  if ($User instanceof User) {
                      $this->Recipient = $User;
                      
                      $this->to_user_id = $this->Recipient->id;
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 1 other location - About 3 hrs to fix
          lib/PrivateMessages/Message.php on lines 563..574

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

          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

              public function setAuthor(User $User = NULL) {
                  if ($User instanceof User) {
                      $this->Author = $User;
                      
                      $this->from_user_id = $this->Author->id;
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 1 other location - About 3 hrs to fix
          lib/PrivateMessages/Message.php on lines 543..554

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

          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

                  if (!$row = $this->Memcached->fetch($this->mckey)) {
                      $query = "SELECT pm.*, pmt.*, ufrom.user_id AS user_id_from, ufrom.username AS username_from, ufrom.user_avatar AS from_user_avatar, ufrom.user_allow_viewonline AS from_user_viewonline, uto.user_id AS user_id_to, uto.username AS username_to, uto.user_allow_viewonline AS to_user_viewonline
                                  FROM nuke_bbprivmsgs AS pm
                                  LEFT JOIN nuke_bbprivmsgs_text AS pmt ON pm.privmsgs_id = pmt.privmsgs_text_id
                                  LEFT JOIN nuke_users AS ufrom ON pm.privmsgs_from_userid = ufrom.user_id
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 4 other locations - About 2 hrs to fix
          lib/Glossary/Entry.php on lines 152..158
          lib/News/Article.php on lines 375..384
          lib/Organisations/Organisation.php on lines 215..220
          lib/Timetables/Train.php on lines 164..169

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

          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

              public function __construct($id = false) {
                  parent::__construct(); 
                  
                  if (filter_var($id, FILTER_VALIDATE_INT)) {
                      $this->id = $id; 
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 1 other location - About 2 hrs to fix
          lib/Newsletters/Newsletter.php on lines 106..113

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

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

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

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

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

          Refactorings

          Further Reading

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

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

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 32.

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

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

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

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

          Refactorings

          Further Reading

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

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

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 32.

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

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

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

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

          Refactorings

          Further Reading

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

                      $data = array(
                          'privmsgs_bbcode_uid' => $this->bbcode_uid,
                          'privmsgs_text' => $this->body,
                          'privmsgs_text_id' => $this->id
                      );
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 5 other locations - About 55 mins to fix
          lib/Events/EventCategory.php on lines 149..153
          lib/Images/Collection.php on lines 268..272
          lib/Images/Collection.php on lines 291..295
          lib/Locos/Manufacturer.php on lines 162..166
          lib/News/Topic.php on lines 375..379

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

                      "privmsgs_text" => function_exists("prepare_submit") ? prepare_submit($this->body) : $this->body
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 2 other locations - About 55 mins to fix
          lib/Ideas/Idea.php on lines 520..520
          lib/DialogueModal.php on lines 171..171

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

                  $Notification->addRecipient($this->Recipient->id, $this->Recipient->username, $this->Recipient->contact_email);
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 2 other locations - About 50 mins to fix
          lib/Images/Utility/CompNotify.php on lines 72..72
          lib/Reminders/Reminder.php on lines 372..372

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

                  if (is_null($this->object_id)) {
                      $this->object_id = "";
                  }
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 11 other locations - About 40 mins to fix
          lib/Downloads/Download.php on lines 293..295
          lib/Feedback/FeedbackItem.php on lines 180..182
          lib/Forums/Post.php on lines 351..353
          lib/Glossary/Entry.php on lines 262..264
          lib/Locos/Date.php on lines 266..268
          lib/Locos/WheelArrangement.php on lines 170..172
          lib/News/Article.php on lines 766..768
          lib/News/Article.php on lines 770..772
          lib/News/Article.php on lines 786..788
          lib/Sightings/Sighting.php on lines 239..241
          lib/Sightings/Sighting.php on lines 243..245

          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

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

                  $Push->subject = sprintf("[Private Messages] New message from %s", $this->Author->username);
          Severity: Minor
          Found in lib/PrivateMessages/Message.php and 1 other location - About 40 mins to fix
          lib/PrivateMessages/Message.php on lines 423..423

          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

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

                  $Notification->subject = sprintf("[Private Messages] New message from %s", $this->Author->username);
          Severity: Minor
          Found in lib/PrivateMessages/Message.php and 1 other location - About 40 mins to fix
          lib/PrivateMessages/Message.php on lines 400..400

          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

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

                  if (empty($this->enable_html)) {
                      $this->enable_html = true;
                  } 
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 3 other locations - About 30 mins to fix
          lib/PrivateMessages/Message.php on lines 322..324
          lib/PrivateMessages/Message.php on lines 330..332
          lib/PrivateMessages/Message.php on lines 334..336

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 21.

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

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

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

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

          Refactorings

          Further Reading

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

                  if (empty($this->enable_bbcode)) {
                      $this->enable_bbcode = true;
                  }
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 3 other locations - About 30 mins to fix
          lib/PrivateMessages/Message.php on lines 326..328
          lib/PrivateMessages/Message.php on lines 330..332
          lib/PrivateMessages/Message.php on lines 334..336

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 21.

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

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

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

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

          Refactorings

          Further Reading

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

                  if (empty($this->enable_smilies)) {
                      $this->enable_smilies = true;
                  } 
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 3 other locations - About 30 mins to fix
          lib/PrivateMessages/Message.php on lines 322..324
          lib/PrivateMessages/Message.php on lines 326..328
          lib/PrivateMessages/Message.php on lines 334..336

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 21.

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

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

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

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

          Refactorings

          Further Reading

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

                  if (empty($this->enable_signature)) {
                      $this->enable_signature = false;
                  }
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 3 other locations - About 30 mins to fix
          lib/PrivateMessages/Message.php on lines 322..324
          lib/PrivateMessages/Message.php on lines 326..328
          lib/PrivateMessages/Message.php on lines 330..332

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 21.

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

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

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

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

          Refactorings

          Further Reading

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

                  $this->body         = trim($row['privmsgs_text']);
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 7 other locations - About 30 mins to fix
          lib/Forums/Post.php on lines 314..314
          lib/Forums/Post.php on lines 315..315
          lib/Images/Competition.php on lines 420..420
          lib/Locations/Date.php on lines 71..71
          lib/Locations/Location.php on lines 498..498
          lib/Notifications/Notification.php on lines 135..135
          lib/Users/User.php on lines 1060..1060

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 20.

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

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

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

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

          Refactorings

          Further Reading

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

                  $data = array(
                      "privmsgs_id" => $this->id,
                      "user_id" => $user_id
                  );
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 4 other locations - About 30 mins to fix
          lib/Locations/Location.php on lines 864..867
          lib/Users/Group.php on lines 304..307
          lib/Users/Group.php on lines 327..330
          lib/Users/Group.php on lines 504..507

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 20.

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

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

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

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

          Refactorings

          Further Reading

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

                  $this->setRecipient(UserFactory::CreateUser($row['privmsgs_to_userid']));
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 8 other locations - About 30 mins to fix
          lib/Events/Event.php on lines 215..215
          lib/Events/EventDate.php on lines 163..163
          lib/Glossary/Entry.php on lines 170..170
          lib/Ideas/Idea.php on lines 172..172
          lib/Images/Collection.php on lines 137..137
          lib/Images/Competition.php on lines 203..203
          lib/Locations/Correction.php on lines 144..144
          lib/PrivateMessages/Message.php on lines 290..290

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 20.

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

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

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

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

          Refactorings

          Further Reading

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

                  $this->setAuthor(UserFactory::CreateUser($row['privmsgs_from_userid']));
          Severity: Major
          Found in lib/PrivateMessages/Message.php and 8 other locations - About 30 mins to fix
          lib/Events/Event.php on lines 215..215
          lib/Events/EventDate.php on lines 163..163
          lib/Glossary/Entry.php on lines 170..170
          lib/Ideas/Idea.php on lines 172..172
          lib/Images/Collection.php on lines 137..137
          lib/Images/Competition.php on lines 203..203
          lib/Locations/Correction.php on lines 144..144
          lib/PrivateMessages/Message.php on lines 289..289

          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

          The parameter $User is not named in camelCase.
          Open

              public function setRecipient(User $User = NULL) {
                  if ($User instanceof User) {
                      $this->Recipient = $User;
                      
                      $this->to_user_id = $this->Recipient->id;
          Severity: Minor
          Found in lib/PrivateMessages/Message.php by phpmd

          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 is not named in camelCase.
          Open

              public function setAuthor(User $User = NULL) {
                  if ($User instanceof User) {
                      $this->Author = $User;
                      
                      $this->from_user_id = $this->Author->id;
          Severity: Minor
          Found in lib/PrivateMessages/Message.php by phpmd

          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 delete($user_id = false) {
                  if (!$user_id) {
                      throw new Exception("Cannot delete message - no user ID given"); 
                  }
                  
          Severity: Minor
          Found in lib/PrivateMessages/Message.php by phpmd

          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

              }

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

              }

          Only one argument is allowed per line in a multi-line function call
          Open

                                  $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject))

          Only one argument is allowed per line in a multi-line function call
          Open

                                  $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject))

          Only one argument is allowed per line in a multi-line function call
          Open

                                  $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject))

          Only one argument is allowed per line in a multi-line function call
          Open

                                  $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject))

          Only one argument is allowed per line in a multi-line function call
          Open

                                  $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject))

          Only one argument is allowed per line in a multi-line function call
          Open

                                  $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject))

          Only one argument is allowed per line in a multi-line function call
          Open

                                  $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject))

          Multi-line function call not indented correctly; expected 12 spaces but found 24
          Open

                                  $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject))

          Opening parenthesis of a multi-line function call must be the last content on the line
          Open

                      "body" => nl2br(sprintf("Hi %s,\n\n<a href='http://www.railpage.com.au%s?utm_medium&email&utm_source=private-messages&utm_campain=user-%d'>%s</a> has sent you a new <a href='http://www.railpage.com.au/messages/conversation/%d?utm_medium=email&utm_source=private-messages&utm_campaign=user-%d#%d'>private message</a> in the conversation titled <em>%s</em>.",

          Closing parenthesis of a multi-line function call must be on a line by itself
          Open

                                  $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject))

          There are no issues that match your filters.

          Category
          Status