railpage/railpagecore

View on GitHub
lib/Jobs/Job.php

Summary

Maintainability
F
3 days
Test Coverage

The class Job has 16 fields. Consider redesigning Job to keep the number of fields under 15.
Open

class Job extends Jobs {
    
    /**
     * Job ID
     * @var int $id
Severity: Minor
Found in lib/Jobs/Job.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

Method validate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function validate() {
        if (!is_object($this->Organisation) || empty($this->Organisation->id)) {
            throw new Exception("Cannot save job - organisation is empty or invalid"); 
            return false;
        }
Severity: Minor
Found in lib/Jobs/Job.php - About 1 hr to fix

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

        public function commit() {
            $this->validate(); 
            
            /**
             * Firstly, check if this reference ID exists anywhere in the database. If it does, update, not create.
    Severity: Minor
    Found in lib/Jobs/Job.php - About 1 hr to fix

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

          private function populate() {
              $query = "SELECT organisation_id, conversions, job_added, reference_id, job_urls, job_location_id, job_classification_id, job_thread_id, job_title, job_description, job_expiry, DATEDIFF(job_expiry, NOW()) AS job_expiry_until, job_salary, job_special_cond, job_duration FROM jn_jobs WHERE job_id = ?";
              
              if (!$result = $this->Memcached->fetch($this->mckey)) {         
                  $result = $this->db->fetchRow($query, $this->id);
      Severity: Minor
      Found in lib/Jobs/Job.php - About 1 hr to fix

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

            public function validate() {
                if (!is_object($this->Organisation) || empty($this->Organisation->id)) {
                    throw new Exception("Cannot save job - organisation is empty or invalid"); 
                    return false;
                }
        Severity: Minor
        Found in lib/Jobs/Job.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

        Function populate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private function populate() {
                $query = "SELECT organisation_id, conversions, job_added, reference_id, job_urls, job_location_id, job_classification_id, job_thread_id, job_title, job_description, job_expiry, DATEDIFF(job_expiry, NOW()) AS job_expiry_until, job_salary, job_special_cond, job_duration FROM jn_jobs WHERE job_id = ?";
                
                if (!$result = $this->Memcached->fetch($this->mckey)) {         
                    $result = $this->db->fetchRow($query, $this->id);
        Severity: Minor
        Found in lib/Jobs/Job.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

        Function commit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function commit() {
                $this->validate(); 
                
                /**
                 * Firstly, check if this reference ID exists anywhere in the database. If it does, update, not create.
        Severity: Minor
        Found in lib/Jobs/Job.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 getArray has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getArray() {
                $return = array(
                    "id" => $this->id,
                    "title" => $this->title,
                    "reference_id" => $this->reference_id,
        Severity: Minor
        Found in lib/Jobs/Job.php - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

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

            Avoid too many return statements within this method.
            Open

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

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

                  public function validate() {
                      if (!is_object($this->Organisation) || empty($this->Organisation->id)) {
                          throw new Exception("Cannot save job - organisation is empty or invalid"); 
                          return false;
                      }
              Severity: Minor
              Found in lib/Jobs/Job.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 15. The configured cyclomatic complexity threshold is 10.
              Open

                  public function validate() {
                      if (!is_object($this->Organisation) || empty($this->Organisation->id)) {
                          throw new Exception("Cannot save job - organisation is empty or invalid"); 
                          return false;
                      }
              Severity: Minor
              Found in lib/Jobs/Job.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 __construct has a boolean flag argument $job_id, which is a certain sign of a Single Responsibility Principle violation.
              Open

                  public function __construct($job_id = false) {
              Severity: Minor
              Found in lib/Jobs/Job.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

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

                  private function populate() {
                      $query = "SELECT organisation_id, conversions, job_added, reference_id, job_urls, job_location_id, job_classification_id, job_thread_id, job_title, job_description, job_expiry, DATEDIFF(job_expiry, NOW()) AS job_expiry_until, job_salary, job_special_cond, job_duration FROM jn_jobs WHERE job_id = ?";
                      
                      if (!$result = $this->Memcached->fetch($this->mckey)) {         
                          $result = $this->db->fetchRow($query, $this->id);
              Severity: Minor
              Found in lib/Jobs/Job.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

              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
                          if ($this->db->insert("jn_jobs", $data)) {
                              $this->id = $this->db->lastInsertId();
                              $this->url = new Url(sprintf("%s?mode=view&id=%d", $this->Module->url, $this->id));
              Severity: Minor
              Found in lib/Jobs/Job.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 '281', column '17').
              Open

                  public function commit() {
                      $this->validate(); 
                      
                      /**
                       * Firstly, check if this reference ID exists anywhere in the database. If it does, update, not create.
              Severity: Minor
              Found in lib/Jobs/Job.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 assigning values to variables in if clauses and the like (line '151', column '13').
              Open

                  public function __construct($job_id = false) {
                      
                      parent::__construct();
                      
                      if ($this->id = filter_var($job_id, FILTER_VALIDATE_INT)) {
              Severity: Minor
              Found in lib/Jobs/Job.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

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

              Example

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

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

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

                      if (!is_object($this->Classification) || empty($this->Classification->id)) {
                          throw new Exception("Cannot save job - job classification is empty or invalid"); 
                          return false;
                      }
              Severity: Major
              Found in lib/Jobs/Job.php and 2 other locations - About 1 hr to fix
              lib/Jobs/Job.php on lines 215..218
              lib/Jobs/Job.php on lines 220..223

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

              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

                      if (!is_object($this->Organisation) || empty($this->Organisation->id)) {
                          throw new Exception("Cannot save job - organisation is empty or invalid"); 
                          return false;
                      }
              Severity: Major
              Found in lib/Jobs/Job.php and 2 other locations - About 1 hr to fix
              lib/Jobs/Job.php on lines 220..223
              lib/Jobs/Job.php on lines 225..228

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

              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

                      if (!is_object($this->Location) || empty($this->Location->id)) {
                          throw new Exception("Cannot save job - job location is empty or invalid"); 
                          return false;
                      }
              Severity: Major
              Found in lib/Jobs/Job.php and 2 other locations - About 1 hr to fix
              lib/Jobs/Job.php on lines 215..218
              lib/Jobs/Job.php on lines 225..228

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

              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

                      $this->url = new Url(sprintf("%s/%d", $this->Module->url, $this->id));
              Severity: Major
              Found in lib/Jobs/Job.php and 11 other locations - About 1 hr to fix
              lib/Events/Event.php on lines 475..475
              lib/Events/EventCategory.php on lines 232..232
              lib/Gallery/Image.php on lines 207..207
              lib/Glossary/Entry.php on lines 227..227
              lib/Ideas/Idea.php on lines 186..186
              lib/Jobs/Job.php on lines 315..315
              lib/Locations/Region.php on lines 149..149
              lib/Locos/Type.php on lines 106..106
              lib/Locos/Type.php on lines 133..133
              lib/News/Topic.php on lines 147..147
              lib/Timetables/Point.php on lines 114..114

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

                              $this->url = new Url(sprintf("%s?mode=view&id=%d", $this->Module->url, $this->id));
              Severity: Major
              Found in lib/Jobs/Job.php and 11 other locations - About 1 hr to fix
              lib/Events/Event.php on lines 475..475
              lib/Events/EventCategory.php on lines 232..232
              lib/Gallery/Image.php on lines 207..207
              lib/Glossary/Entry.php on lines 227..227
              lib/Ideas/Idea.php on lines 186..186
              lib/Jobs/Job.php on lines 195..195
              lib/Locations/Region.php on lines 149..149
              lib/Locos/Type.php on lines 106..106
              lib/Locos/Type.php on lines 133..133
              lib/News/Topic.php on lines 147..147
              lib/Timetables/Point.php on lines 114..114

              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

                      if (empty($this->duration) || strtolower($this->duration) == "ongoing") {
                          $this->duration = "";
                      }
              Severity: Major
              Found in lib/Jobs/Job.php and 1 other location - About 1 hr to fix
              lib/Chronicle/Entry.php on lines 220..222

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

                      if ($result['job_added'] != "0000-00-00 00:00:00") {
                          $this->Open = new DateTime($result['job_added']);
                      }
              Severity: Major
              Found in lib/Jobs/Job.php and 2 other locations - About 1 hr to fix
              lib/SiteMessages/SiteMessage.php on lines 111..113
              lib/SiteMessages/SiteMessage.php on lines 115..117

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

              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 ($this->db->update("jn_jobs", $data, "job_id = " . $this->id)) {
                              return true;
                          }
              Severity: Major
              Found in lib/Jobs/Job.php and 1 other location - About 1 hr to fix
              lib/Jobs/Location.php on lines 128..130

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 31.

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

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

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

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

              Refactorings

              Further Reading

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

                      if (filter_var($this->reference_id, FILTER_VALIDATE_INT) && $this->reference_id > 0) {
                          $query = "SELECT job_id FROM jn_jobs WHERE reference_id = ?";
                          
                          if ($id = $this->db->fetchOne($query, $this->reference_id)) {
                              $this->id = $id;
              Severity: Major
              Found in lib/Jobs/Job.php and 4 other locations - About 50 mins to fix
              lib/Chronicle/Entry.php on lines 263..271
              lib/Ideas/Idea.php on lines 574..576
              lib/Locations/Location.php on lines 659..673
              lib/Railcams/Camera.php on lines 282..284

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

                      if (empty($this->desc)) {
                          throw new Exception("Cannot save job - job description is empty or invalid"); 
                          return false;
                      }
              Severity: Major
              Found in lib/Jobs/Job.php and 17 other locations - About 45 mins to fix
              lib/Jobs/Job.php on lines 243..246
              lib/Links/Link.php on lines 136..139
              lib/Links/Link.php on lines 141..144
              lib/Links/Link.php on lines 146..149
              lib/Locations/Location.php on lines 881..884
              lib/Locations/Location.php on lines 899..902
              lib/Locos/Type.php on lines 117..120
              lib/Locos/WheelArrangement.php on lines 161..164
              lib/News/Topic.php on lines 337..340
              lib/News/Topic.php on lines 356..359
              lib/Sightings/Sighting.php on lines 219..222
              lib/Sightings/Sighting.php on lines 224..227
              lib/Sightings/Sighting.php on lines 229..232
              lib/Sightings/Sighting.php on lines 234..237
              lib/SiteEvent.php on lines 148..151
              lib/SiteEvent.php on lines 153..156
              lib/SiteEvent.php on lines 158..161

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

                      if (empty($this->title)) {
                          throw new Exception("Cannot save job - job title is empty or invalid"); 
                          return false;
                      }
              Severity: Major
              Found in lib/Jobs/Job.php and 17 other locations - About 45 mins to fix
              lib/Jobs/Job.php on lines 230..233
              lib/Links/Link.php on lines 136..139
              lib/Links/Link.php on lines 141..144
              lib/Links/Link.php on lines 146..149
              lib/Locations/Location.php on lines 881..884
              lib/Locations/Location.php on lines 899..902
              lib/Locos/Type.php on lines 117..120
              lib/Locos/WheelArrangement.php on lines 161..164
              lib/News/Topic.php on lines 337..340
              lib/News/Topic.php on lines 356..359
              lib/Sightings/Sighting.php on lines 219..222
              lib/Sightings/Sighting.php on lines 224..227
              lib/Sightings/Sighting.php on lines 229..232
              lib/Sightings/Sighting.php on lines 234..237
              lib/SiteEvent.php on lines 148..151
              lib/SiteEvent.php on lines 153..156
              lib/SiteEvent.php on lines 158..161

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

                      $this->url->conversion = sprintf("%s?apply", $this->url->url);
              Severity: Major
              Found in lib/Jobs/Job.php and 22 other locations - About 45 mins to fix
              lib/Chronicle/Chronicle.php on lines 42..42
              lib/Chronicle/Chronicle.php on lines 43..43
              lib/Chronicle/Chronicle.php on lines 44..44
              lib/Chronicle/Chronicle.php on lines 45..45
              lib/Chronicle/Chronicle.php on lines 46..46
              lib/Images/Competition.php on lines 150..150
              lib/Locos/Locomotive.php on lines 432..432
              lib/Locos/Locomotive.php on lines 433..433
              lib/Railcams/Camera.php on lines 258..258
              lib/Railcams/Camera.php on lines 259..259
              lib/Railcams/Camera.php on lines 261..261
              lib/Railcams/Camera.php on lines 262..262
              lib/Railcams/Camera.php on lines 263..263
              lib/Railcams/Camera.php on lines 264..264
              lib/Railcams/Camera.php on lines 266..266
              lib/Timetables/Point.php on lines 115..115
              lib/Timetables/Timetables.php on lines 41..41
              lib/Timetables/Timetables.php on lines 42..42
              lib/Timetables/Timetables.php on lines 43..43
              lib/Timetables/Train.php on lines 183..183
              lib/Users/Group.php on lines 222..222
              lib/Users/Group.php on lines 223..223

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

                      if (is_array(json_decode($result['job_urls'], true))) {
              Severity: Minor
              Found in lib/Jobs/Job.php and 1 other location - About 45 mins to fix
              lib/Users/Utility/UserUtility.php on lines 30..30

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

                          "classification" => array(
                              "id" => $this->Classification->id,
                              "name" => $this->Classification->name
                          ),
              Severity: Major
              Found in lib/Jobs/Job.php and 5 other locations - About 40 mins to fix
              lib/Images/Competitions.php on lines 251..254
              lib/Jobs/Job.php on lines 339..342
              lib/Jobs/Job.php on lines 343..346
              lib/Place.php on lines 358..361
              lib/Place.php on lines 362..365

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

                          "location" => array(
                              "id" => $this->Location->id,
                              "name" => $this->Location->name
                          ),
              Severity: Major
              Found in lib/Jobs/Job.php and 5 other locations - About 40 mins to fix
              lib/Images/Competitions.php on lines 251..254
              lib/Jobs/Job.php on lines 343..346
              lib/Jobs/Job.php on lines 347..350
              lib/Place.php on lines 358..361
              lib/Place.php on lines 362..365

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

                          "organisation" => array(
                              "id" => $this->Organisation->id,
                              "name" => $this->Organisation->name
                          ),
              Severity: Major
              Found in lib/Jobs/Job.php and 5 other locations - About 40 mins to fix
              lib/Images/Competitions.php on lines 251..254
              lib/Jobs/Job.php on lines 339..342
              lib/Jobs/Job.php on lines 347..350
              lib/Place.php on lines 358..361
              lib/Place.php on lines 362..365

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

                      $this->salary = filter_var($this->salary, FILTER_SANITIZE_NUMBER_INT);
              Severity: Major
              Found in lib/Jobs/Job.php and 3 other locations - About 40 mins to fix
              lib/Forums/Category.php on lines 160..160
              lib/Users/User.php on lines 2889..2889
              lib/Users/User.php on lines 2912..2912

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

                      if (is_null($this->thread_id)) {
                          $this->thread_id = 0;
                      }
              Severity: Major
              Found in lib/Jobs/Job.php and 7 other locations - About 40 mins to fix
              lib/Feedback/FeedbackItem.php on lines 172..174
              lib/Feedback/FeedbackItem.php on lines 176..178
              lib/Forums/Post.php on lines 355..357
              lib/Forums/Post.php on lines 359..361
              lib/Forums/Post.php on lines 363..365
              lib/Forums/Post.php on lines 367..369
              lib/Forums/Thread.php on lines 288..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 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 3 locations. Consider refactoring.
              Open

                      if ($this->id = filter_var($job_id, FILTER_VALIDATE_INT)) {
                          $this->mckey = sprintf("railpage:jobs.job=%d", $this->id); 
                          $this->populate(); 
                      }
              Severity: Minor
              Found in lib/Jobs/Job.php and 2 other locations - About 30 mins to fix
              lib/Images/Image.php on lines 259..261
              lib/Locations/Correction.php on lines 105..107

              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

              The parameter $job_id is not named in camelCase.
              Open

                  public function __construct($job_id = false) {
                      
                      parent::__construct();
                      
                      if ($this->id = filter_var($job_id, FILTER_VALIDATE_INT)) {
              Severity: Minor
              Found in lib/Jobs/Job.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

                  }
              Severity: Minor
              Found in lib/Jobs/Job.php by phpcodesniffer

              Blank line found at start of control structure
              Open

                          foreach (json_decode($result['job_urls'], true) as $title => $link) {
              Severity: Minor
              Found in lib/Jobs/Job.php by phpcodesniffer

              Blank line found at start of control structure
              Open

                      if (filter_var($this->id, FILTER_VALIDATE_INT)) {
              Severity: Minor
              Found in lib/Jobs/Job.php by phpcodesniffer

              There are no issues that match your filters.

              Category
              Status