railpage/railpagecore

View on GitHub
lib/Images/Competitions.php

Summary

Maintainability
C
1 day
Test Coverage

Function autoPopulateNextComp has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function autoPopulateNextComp() {
        $month = new DateTime("first day of next month"); 
        
        $title = $month->format("F Y");
        
Severity: Minor
Found in lib/Images/Competitions.php - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

    public function autoPopulateNextComp() {
        $month = new DateTime("first day of next month"); 
        
        $title = $month->format("F Y");
        
Severity: Minor
Found in lib/Images/Competitions.php - About 1 hr to fix

    Method getLeagueTable has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getLeagueTable() {
            /**
             SELECT 
                s.user_id, u.username, c.title AS comp_title, c.id AS comp_id, c.slug AS comp_slug, 
                s.image_id, i.meta AS image_meta,
    Severity: Minor
    Found in lib/Images/Competitions.php - About 1 hr to fix

      Function getCompetitions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getCompetitions($status = NULL) {
              $query = "SELECT id FROM image_competition";
              $where = array(); 
              
              if (!is_null($status)) {
      Severity: Minor
      Found in lib/Images/Competitions.php - About 25 mins 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

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

              foreach ($this->db->fetchAll($query, $where) as $row) {
                  $Competition = new Competition($row['id']);
                  $comps[] = $Competition->getArray(); 
              }
      Severity: Major
      Found in lib/Images/Competitions.php and 4 other locations - About 1 hr to fix
      lib/Locos/Manufacturer.php on lines 192..196
      lib/Locos/Type.php on lines 191..195
      lib/Newsletters/Newsletters.php on lines 85..88
      lib/Sightings/Sightings.php on lines 119..122

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

          public function __construct() {
              parent::__construct(); 
              $this->Module = new Module("images.competitions"); 
          }
      Severity: Major
      Found in lib/Images/Competitions.php and 5 other locations - About 50 mins to fix
      lib/Gallery/Gallery.php on lines 30..36
      lib/Help/Help.php on lines 27..33
      lib/Ideas/Ideas.php on lines 78..84
      lib/Jobs/Jobs.php on lines 35..41
      lib/Reminders/Reminders.php on lines 28..34

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

                  "user" => [
                      "id" => $this->Author->id,
                      "username" => $this->Author->username
                  ],
      Severity: Major
      Found in lib/Images/Competitions.php and 5 other locations - About 40 mins to fix
      lib/Jobs/Job.php on lines 339..342
      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 2 locations. Consider refactoring.
      Open

                          if (function_exists("format_topictitle")) {
                              $theme['theme'] = format_topictitle($theme['theme']);
                          }
      Severity: Minor
      Found in lib/Images/Competitions.php and 1 other location - About 40 mins to fix
      lib/Users/User.php on lines 1732..1734

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

          public function getPreviousContestants() {
              
              $query = "SELECT s.user_id, u.username, u.user_email AS contact_email, concat('/user/', s.user_id) AS url 
                  FROM image_competition_submissions AS s 
                      LEFT JOIN nuke_users AS u ON s.user_id = u.user_id 
      Severity: Major
      Found in lib/Images/Competitions.php and 14 other locations - About 35 mins to fix
      lib/Images/Screener.php on lines 258..269
      lib/Images/Statistics.php on lines 93..104
      lib/Images/Statistics.php on lines 112..133
      lib/Images/Statistics.php on lines 141..147
      lib/Images/Statistics.php on lines 155..170
      lib/Images/Statistics.php on lines 250..256
      lib/Images/Statistics.php on lines 264..270
      lib/Links/Links.php on lines 227..231
      lib/Locations/Locations.php on lines 204..213
      lib/Locations/Locations.php on lines 531..535
      lib/Locos/Liveries/Liveries.php on lines 86..96
      lib/Users/Admin.php on lines 34..39
      lib/Users/Base.php on lines 234..238
      lib/Users/Base.php on lines 271..283

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

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

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

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

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

      Refactorings

      Further Reading

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

              $Config->set("image.competition.suggestedthemes", json_encode($themes), "Photo competition themes"); 
      Severity: Minor
      Found in lib/Images/Competitions.php and 1 other location - About 35 mins to fix
      lib/Images/Competition.php on lines 359..359

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

      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

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

          }
      Severity: Minor
      Found in lib/Images/Competitions.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in lib/Images/Competitions.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in lib/Images/Competitions.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status