railpage/railpagecore

View on GitHub
lib/Newsletters/Weekly.php

Summary

Maintainability
D
2 days
Test Coverage

Method personaliseContent has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private function personaliseContent() {
            
            $replacements = array(); 
            
            Debug::LogCLI("Looping through " . count($this->recipients) . " users and preparing email decoration"); 
Severity: Major
Found in lib/Newsletters/Weekly.php - About 3 hrs to fix

    Function personaliseContent has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

            private function personaliseContent() {
                
                $replacements = array(); 
                
                Debug::LogCLI("Looping through " . count($this->recipients) . " users and preparing email decoration"); 
    Severity: Minor
    Found in lib/Newsletters/Weekly.php - About 3 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

    File Weekly.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
        /**
         * Curate a weekly newsletter
         * @since Version 3.10.0
         * @package Railpage
    Severity: Minor
    Found in lib/Newsletters/Weekly.php - About 2 hrs to fix

      The method personaliseContent() has an NPath complexity of 1921. The configured NPath complexity threshold is 200.
      Open

              private function personaliseContent() {
                  
                  $replacements = array(); 
                  
                  Debug::LogCLI("Looping through " . count($this->recipients) . " users and preparing email decoration"); 
      Severity: Minor
      Found in lib/Newsletters/Weekly.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 personaliseContent() has 153 lines of code. Current threshold is set to 100. Avoid really long methods.
      Open

              private function personaliseContent() {
                  
                  $replacements = array(); 
                  
                  Debug::LogCLI("Looping through " . count($this->recipients) . " users and preparing email decoration"); 
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpmd

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

              private function personaliseContent() {
                  
                  $replacements = array(); 
                  
                  Debug::LogCLI("Looping through " . count($this->recipients) . " users and preparing email decoration"); 
      Severity: Minor
      Found in lib/Newsletters/Weekly.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

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

                      $user_ids[] = $row['user_id']; 
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpmd

      UndefinedVariable

      Since: 2.8.0

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

      Example

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

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

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

                      $ZendDB->query($query); 
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpmd

      UndefinedVariable

      Since: 2.8.0

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

      Example

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

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

      The class Weekly has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13.
      Open

          class Weekly extends AppCore {
              
              /**
               * Maximum number of elements to post in this article
               * @since Version 3.10.0
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpmd

      CouplingBetweenObjects

      Since: 1.1.0

      A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

      Example

      class Foo {
          /**
           * @var \foo\bar\X
           */
          private $x = null;
      
          /**
           * @var \foo\bar\Y
           */
          private $y = null;
      
          /**
           * @var \foo\bar\Z
           */
          private $z = null;
      
          public function setFoo(\Foo $foo) {}
          public function setBar(\Bar $bar) {}
          public function setBaz(\Baz $baz) {}
      
          /**
           * @return \SplObjectStorage
           * @throws \OutOfRangeException
           * @throws \InvalidArgumentException
           * @throws \ErrorException
           */
          public function process(\Iterator $it) {}
      
          // ...
      }

      Source https://phpmd.org/rules/design.html#couplingbetweenobjects

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

                      $ZendDB->query($query); 
      Severity: Minor
      Found in lib/Newsletters/Weekly.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

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

                      $user_ids[] = $row['user_id']; 
      Severity: Minor
      Found in lib/Newsletters/Weekly.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

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

                  $start = 0; $num = 10;
      Severity: Minor
      Found in lib/Newsletters/Weekly.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

                          Debug::LogCLI("Found " . count($articles) . " articles for user ID " . $User->id . " - dropping keyword and topic filter from feed"); 
      Severity: Major
      Found in lib/Newsletters/Weekly.php and 1 other location - About 1 hr to fix
      lib/Newsletters/Weekly.php on lines 396..396

      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

                          Debug::LogCLI("Found " . count($articles) . " articles for user ID " . $User->id . " - skipping"); 
      Severity: Major
      Found in lib/Newsletters/Weekly.php and 1 other location - About 1 hr to fix
      lib/Newsletters/Weekly.php on lines 386..386

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 35.

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

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

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

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

      Refactorings

      Further Reading

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

                          $replacements[$row['user_email']] = array_merge($replacements[$row['user_email']], $tmp);
      Severity: Major
      Found in lib/Newsletters/Weekly.php and 1 other location - About 1 hr to fix
      lib/Newsletters/Weekly.php on lines 439..439

      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

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

                          $replacements[$row['user_email']] = array_merge($replacements[$row['user_email']], $tmp);
      Severity: Major
      Found in lib/Newsletters/Weekly.php and 1 other location - About 1 hr to fix
      lib/Newsletters/Weekly.php on lines 457..457

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

                          $article['hometext'] = preg_replace("@(\[b\]|\[\/b\])@", "", $article['story_blurb']);
      Severity: Major
      Found in lib/Newsletters/Weekly.php and 6 other locations - About 55 mins to fix
      lib/Prerender/Home.php on lines 153..153
      lib/PrivateMessages/Folder.php on lines 126..126
      lib/RSS/Consume.php on lines 279..279
      lib/RSS/Consume.php on lines 280..280
      lib/RSS/Consume.php on lines 364..364
      lib/Template.php on lines 292..292

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 28.

      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

                          Debug::LogCLI("Skipping user ID " . $row['user_id'] . " - \"" . $row['user_email'] . "\" is not a valid email address");
      Severity: Minor
      Found in lib/Newsletters/Weekly.php and 1 other location - About 55 mins to fix
      lib/Formatting/MultimediaUtility.php on lines 115..115

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

      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

                          $article['url'] = NewsletterUtility::CreateUTMParametersForLink($this->Newsletter, $article['url']);
      Severity: Minor
      Found in lib/Newsletters/Weekly.php and 1 other location - About 50 mins to fix
      lib/Newsletters/Weekly.php on lines 293..293

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 27.

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

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

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

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

      Refactorings

      Further Reading

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

                          $row['url'] = NewsletterUtility::CreateUTMParametersForLink($this->Newsletter, $row['url']);
      Severity: Minor
      Found in lib/Newsletters/Weekly.php and 1 other location - About 50 mins to fix
      lib/Newsletters/Weekly.php on lines 416..416

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

                          $article['featured_image'] = ImageCache::cache($article['story_image']);
      Severity: Major
      Found in lib/Newsletters/Weekly.php and 14 other locations - About 35 mins to fix
      lib/Formatting/MultimediaUtility.php on lines 263..263
      lib/Images/Competition.php on lines 351..351
      lib/Images/Exif.php on lines 145..145
      lib/Images/Exif.php on lines 146..146
      lib/Images/Exif.php on lines 147..147
      lib/Images/ImageFactory.php on lines 229..229
      lib/Images/Utility/Finder.php on lines 706..706
      lib/Images/Utility/Finder.php on lines 735..735
      lib/Locos/Utility/LocosUtility.php on lines 56..56
      lib/News/Topic.php on lines 233..233
      lib/News/Topic.php on lines 290..290
      lib/News/Topic.php on lines 292..292
      lib/Newsletters/Weekly.php on lines 412..412
      lib/Users/Timeline.php on lines 177..177

      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

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

                          $article['topictext'] = ContentUtility::FormatTitle($article['topic_title']);
      Severity: Major
      Found in lib/Newsletters/Weekly.php and 14 other locations - About 35 mins to fix
      lib/Formatting/MultimediaUtility.php on lines 263..263
      lib/Images/Competition.php on lines 351..351
      lib/Images/Exif.php on lines 145..145
      lib/Images/Exif.php on lines 146..146
      lib/Images/Exif.php on lines 147..147
      lib/Images/ImageFactory.php on lines 229..229
      lib/Images/Utility/Finder.php on lines 706..706
      lib/Images/Utility/Finder.php on lines 735..735
      lib/Locos/Utility/LocosUtility.php on lines 56..56
      lib/News/Topic.php on lines 233..233
      lib/News/Topic.php on lines 290..290
      lib/News/Topic.php on lines 292..292
      lib/Newsletters/Weekly.php on lines 414..414
      lib/Users/Timeline.php on lines 177..177

      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

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

                          "featuredimage" => $photo['meta']['sizes']['small']['source'],
      Severity: Major
      Found in lib/Newsletters/Weekly.php and 3 other locations - About 30 mins to fix
      lib/GTFS/AU/VIC/PTV/Stop.php on lines 101..101
      lib/GTFS/AU/VIC/PTV/Stop.php on lines 102..102
      lib/GTFS/AU/VIC/PTV/Stop.php on lines 103..103

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

                              "##block" . $i . ".featuredimage##" => $articles[$i]['story_image'],
      Severity: Minor
      Found in lib/Newsletters/Weekly.php and 1 other location - About 30 mins to fix
      lib/Newsletters/Weekly.php on lines 449..449

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

                  Debug::LogCLI("Looping through " . count($this->recipients) . " users and preparing email decoration"); 
      Severity: Minor
      Found in lib/Newsletters/Weekly.php and 1 other location - About 30 mins to fix
      lib/Formatting/MultimediaUtility.php on lines 100..100

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

                              "##block" . $i . ".subtitle##" => $articles[$i]['story_title'],
      Severity: Minor
      Found in lib/Newsletters/Weekly.php and 1 other location - About 30 mins to fix
      lib/Newsletters/Weekly.php on lines 450..450

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

                              "##block" . $i . ".link_text##" => isset($block['link_text']) && !empty($block['link_text']) ? $block['link_text'] : "Continue reading",
      Severity: Minor
      Found in lib/Newsletters/Weekly.php and 2 other locations - About 30 mins to fix
      lib/Locos/Gauge.php on lines 116..116
      lib/News/Scraper.php on lines 169..175

      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

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

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.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/Newsletters/Weekly.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/Newsletters/Weekly.php by phpcodesniffer

      Blank line found at start of control structure
      Open

                      for ($i = count($this->prependedContent) + $start; $i < $start + $this->num_items; $i++) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.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/Newsletters/Weekly.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/Newsletters/Weekly.php by phpcodesniffer

      Blank line found at start of control structure
      Open

                      if (count($articles) < 10) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.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/Newsletters/Weekly.php by phpcodesniffer

      Blank line found at start of control structure
      Open

                      if (count($articles) < 6) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Blank line found at end of control structure
      Open

                          
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Blank line found at start of control structure
      Open

                      foreach ($articles as $id => $article) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Blank line found at start of control structure
      Open

                  foreach ($this->recipients as $row) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Each PHP statement must be on a line by itself
      Open

                  $start = 0; $num = 10;
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Blank line found at start of control structure
      Open

                      foreach ($this->prependedContent as $i => $block) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.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/Newsletters/Weekly.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/Newsletters/Weekly.php by phpcodesniffer

      Blank line found at end of control structure
      Open

                      
      Severity: Minor
      Found in lib/Newsletters/Weekly.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/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private $prependedContent;
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private $HeroImage;
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 12 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  foreach ($this->recipients as $row) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private function createNewsletter() {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private function getRecipients() {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private function getOtherContent() {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private function prepareTemplate() {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              public static function curate() {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 12 spaces, found 16
      Open

                      if (!filter_var($row['user_email'], FILTER_VALIDATE_EMAIL)) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 12 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      if ($counter == 150) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              public $Notification;
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 12 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  if (filter_var($image_id, FILTER_VALIDATE_INT)) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      try {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      } catch (Exception $e) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  if (!empty($photo)) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      if (count($articles) < 10) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      if (count($articles) < 6) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 0 spaces, found 4
      Open

          class Weekly extends AppCore {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private $user_ids = [];
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private function createNotification() {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  foreach ($this->db->fetchAll($query) as $row) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      if (!isset($start)) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private $num_items = 10;
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      foreach ($articles as $id => $article) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 12 spaces, found 16
      Open

                      if (!empty($row['lat']) && !empty($row['lon'])) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private function queue() {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private function getHeroImage() {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private $replacements;
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              public $Newsletter;
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  for ($i = $start; $i < $start + $this->num_items; $i++) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  foreach ($result as $key => $row) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private function personaliseContent() {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      for ($i = count($this->prependedContent) + $start; $i < $start + $this->num_items; $i++) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private $recipients;
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              private $html;
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 12 spaces, found 16
      Open

                      if ($sizes['medium']['height'] > $sizes['medium']['width']) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  foreach ($this->user_ids as $user_id) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 8 spaces, found 16
      Open

                      foreach ($this->prependedContent as $i => $block) {
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      Line indented incorrectly; expected 0 spaces, found 4
      Open

          }
      Severity: Minor
      Found in lib/Newsletters/Weekly.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status