railpage/railpagecore

View on GitHub

Showing 9,214 of 9,214 total issues

File User.php has 1132 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Base user class
 * @since   Version 3.0.1
Severity: Major
Found in lib/Users/User.php - About 2 days to fix

    File Image.php has 823 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * Store and fetch image data from our local database
     *
    Severity: Major
    Found in lib/Images/Image.php - About 1 day to fix

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

          public function populate($force = false, $option = null) {
      
              if ($force === false && !$this->isStale()) {
                  return $this;
              }
      Severity: Minor
      Found in lib/Images/Image.php - About 1 day 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 findObjects has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
      Open

          public function findObjects($namespace = null, $force = false) {
      
              if (is_null($namespace)) {
                  throw new Exception("Parameter 1 (namespace) cannot be empty");
              }
      Severity: Minor
      Found in lib/Images/Image.php - About 1 day 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 2 locations. Consider refactoring.
      Open

          public function getEventsForDates($dateFrom = null, $dateTo = null) {
              
              $events = array(); 
              
              $Railcams = new Module_Railcams;
      Severity: Major
      Found in lib/Chronicle/Provider/Railcams.php and 1 other location - About 1 day to fix
      lib/Users/User.php on lines 1296..1332

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

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

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

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

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

      Refactorings

      Further Reading

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

          public function guest() {
      
              $this->lang = "english";
              $this->date_format = "d M Y H:i";
              $this->avatar_filename = "blank.png";
      Severity: Major
      Found in lib/Users/User.php and 1 other location - About 1 day to fix
      lib/Chronicle/Provider/Railcams.php on lines 43..78

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

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

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

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

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

      Refactorings

      Further Reading

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

          public function activeThreads($num_threads = 1, $age) {
              if (empty($age)) {
                  $age = strtotime("30 days ago"); 
              }
              
      Severity: Major
      Found in lib/Forums/Stats.php and 1 other location - About 1 day to fix
      lib/Forums/Stats.php on lines 110..158

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

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

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

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

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

      Refactorings

      Further Reading

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

          public function activeForums($num_forums = 1, $age) {
              if (empty($age)) {
                  $age = strtotime("30 days ago"); 
              }
              
      Severity: Major
      Found in lib/Forums/Stats.php and 1 other location - About 1 day to fix
      lib/Forums/Stats.php on lines 168..218

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

      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

      File Competition.php has 654 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      /**
       * Photo competition!
       * @since Version 3.9.1
      Severity: Major
      Found in lib/Images/Competition.php - About 1 day to fix

        File Locomotive.php has 649 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        /** 
         * Loco database
         * @since Version 3.2
        Severity: Major
        Found in lib/Locos/Locomotive.php - About 1 day to fix

          File Forums.php has 648 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          /**
           * Forums API
           * @since Version 3.0.1
          Severity: Major
          Found in lib/Forums/Forums.php - About 1 day to fix

            File LocoClass.php has 590 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            /** 
             * Loco database
             * @since Version 3.2
            Severity: Major
            Found in lib/Locos/LocoClass.php - About 1 day to fix

              Function suggestLocos has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function suggestLocos(Image $imageObject, $skipTagged = null) {
                      
                      $locolookup = array();
                      $locos = array();
              
              Severity: Minor
              Found in lib/Images/Utility/Tagger.php - About 1 day 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 populate has 239 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function populate($force = false, $option = null) {
              
                      if ($force === false && !$this->isStale()) {
                          return $this;
                      }
              Severity: Major
              Found in lib/Images/Image.php - About 1 day to fix

                Function getPhotoLegacy has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getPhotoLegacy($photo_id = false) {
                        if (!$photo_id) {
                            throw new Exception("Cannot fetch photo info and sizes - no photo ID given"); 
                            return false;
                        }
                Severity: Minor
                Found in lib/Railcams/Camera.php - About 1 day 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 __construct has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function __construct($user = false) {
                        if (!$user || !($user instanceof \Railpage\Users\User)) {
                            throw new \Exception("Cannot instantiate " . __CLASS__ . "::" . __FUNCTION__ . " - no \$user object given"); 
                            return false;
                        }
                Severity: Minor
                Found in lib/Forums/Permissions.php - About 1 day 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 2 locations. Consider refactoring.
                Open

                        public function setPhoto(Photo $photoObject) {
                            
                            /** 
                             * Flush Memcache
                             */
                Severity: Major
                Found in lib/Railcams/Provider/Flickr.php and 1 other location - About 1 day to fix
                lib/Images/Provider/Flickr.php on lines 304..330

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

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

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

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

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

                Refactorings

                Further Reading

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

                    public function setImage(Image $imageObject) {
                        
                        /** 
                         * Flush Memcache
                         */
                Severity: Major
                Found in lib/Images/Provider/Flickr.php and 1 other location - About 1 day to fix
                lib/Railcams/Provider/Flickr.php on lines 163..189

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

                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 ($id = filter_var($id, FILTER_VALIDATE_INT)) {
                                $regkey = sprintf(Location::REGISTRY_KEY, $id); 
                                
                                try {
                                    $Location = $Registry->get($regkey); 
                Severity: Major
                Found in lib/Locations/Factory.php and 1 other location - About 1 day to fix
                lib/Locos/Factory.php on lines 49..73

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

                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 ($id = filter_var($id, FILTER_VALIDATE_INT)) {
                            $regkey = sprintf(LocoClass::REGISTRY_KEY, $id);
                
                            try {
                                $LocoClass = $Registry->get($regkey);
                Severity: Major
                Found in lib/Locos/Factory.php and 1 other location - About 1 day to fix
                lib/Locations/Factory.php on lines 44..68

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

                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

                Severity
                Category
                Status
                Source
                Language