railpage/railpagecore

View on GitHub
lib/BanControl/BanControl.php

Summary

Maintainability
F
1 wk
Test Coverage

File BanControl.php has 404 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Ban controller
 * @since Version 3.2
Severity: Minor
Found in lib/BanControl/BanControl.php - About 5 hrs to fix

    The class BanControl has 12 public methods. Consider refactoring BanControl to keep number of public methods under 10.
    Open

    class BanControl extends AppCore {
        
        /**
         * Cache key for all banned objects
         * @since Version 3.9.1
    Severity: Minor
    Found in lib/BanControl/BanControl.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

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

    The class BanControl has an overall complexity of 94 which is very high. The configured complexity threshold is 50.
    Open

    class BanControl extends AppCore {
        
        /**
         * Cache key for all banned objects
         * @since Version 3.9.1
    Severity: Minor
    Found in lib/BanControl/BanControl.php by phpmd

    Method banUser has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function banUser($userId = null, $reason = null, $expiry = "0", $adminUserId = null) {
            
            if (!filter_var($userId, FILTER_VALIDATE_INT)) {
                throw new InvalidArgumentException("No user ID supplied"); 
            }
    Severity: Major
    Found in lib/BanControl/BanControl.php - About 2 hrs to fix

      Method unBanUser has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function unBanUser($banId, $userId = null) {
              $success = false;
              
              /**
               * Empty the cache
      Severity: Major
      Found in lib/BanControl/BanControl.php - About 2 hrs to fix

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

            public static function isClientBanned($userId, $remoteAddr, $force = null) {
                
                if ($remoteAddr == "58.96.64.238" || $userId == 71317) {
                    $force = true;
                }
        Severity: Minor
        Found in lib/BanControl/BanControl.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 isClientBanned has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function isClientBanned($userId, $remoteAddr, $force = null) {
                
                if ($remoteAddr == "58.96.64.238" || $userId == 71317) {
                    $force = true;
                }
        Severity: Major
        Found in lib/BanControl/BanControl.php - About 2 hrs to fix

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

              public function banIP($ipAddress = null, $reason = null, $expiry = "0", $adminUserId = null) {
                  
                  if (is_null($ipAddress)) {
                      throw new InvalidArgumentException("No IP address supplied"); 
                  }
          Severity: Minor
          Found in lib/BanControl/BanControl.php - About 1 hr to fix

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

                public function unBanUser($banId, $userId = null) {
                    $success = false;
                    
                    /**
                     * Empty the cache
            Severity: Minor
            Found in lib/BanControl/BanControl.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 unBanIp has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function unBanIp($banId, $ipAddress = null) {
                    
                    /**
                     * Empty the cache
                     */
            Severity: Minor
            Found in lib/BanControl/BanControl.php - About 1 hr to fix

              Function banUser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function banUser($userId = null, $reason = null, $expiry = "0", $adminUserId = null) {
                      
                      if (!filter_var($userId, FILTER_VALIDATE_INT)) {
                          throw new InvalidArgumentException("No user ID supplied"); 
                      }
              Severity: Minor
              Found in lib/BanControl/BanControl.php - About 55 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

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

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

                  The method banUser() has an NPath complexity of 640. The configured NPath complexity threshold is 200.
                  Open

                      public function banUser($userId = null, $reason = null, $expiry = "0", $adminUserId = null) {
                          
                          if (!filter_var($userId, FILTER_VALIDATE_INT)) {
                              throw new InvalidArgumentException("No user ID supplied"); 
                          }
                  Severity: Minor
                  Found in lib/BanControl/BanControl.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 banUser() has 103 lines of code. Current threshold is set to 100. Avoid really long methods.
                  Open

                      public function banUser($userId = null, $reason = null, $expiry = "0", $adminUserId = null) {
                          
                          if (!filter_var($userId, FILTER_VALIDATE_INT)) {
                              throw new InvalidArgumentException("No user ID supplied"); 
                          }
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php by phpmd

                  The method isClientBanned() has an NPath complexity of 18432. The configured NPath complexity threshold is 200.
                  Open

                      public static function isClientBanned($userId, $remoteAddr, $force = null) {
                          
                          if ($remoteAddr == "58.96.64.238" || $userId == 71317) {
                              $force = true;
                          }
                  Severity: Minor
                  Found in lib/BanControl/BanControl.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 isClientBanned() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10.
                  Open

                      public static function isClientBanned($userId, $remoteAddr, $force = null) {
                          
                          if ($remoteAddr == "58.96.64.238" || $userId == 71317) {
                              $force = true;
                          }
                  Severity: Minor
                  Found in lib/BanControl/BanControl.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 banUser() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                  Open

                      public function banUser($userId = null, $reason = null, $expiry = "0", $adminUserId = null) {
                          
                          if (!filter_var($userId, FILTER_VALIDATE_INT)) {
                              throw new InvalidArgumentException("No user ID supplied"); 
                          }
                  Severity: Minor
                  Found in lib/BanControl/BanControl.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 assigning values to variables in if clauses and the like (line '215', column '13').
                  Open

                      public function loadDomains() {
                          $query = "SELECT * FROM ban_domains ORDER BY domain_name";
                          
                          if ($result = $this->db->fetchAll($query)) {
                              foreach ($result as $row) {
                  Severity: Minor
                  Found in lib/BanControl/BanControl.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 '67').
                  Open

                      public function loadUsers($skipCache = null) {
                          $mckey = "railpage:bancontrol.users;v5"; 
                          
                          if ($skipCache || !$this->Memcached->contains($mckey) || !$this->users = json_decode(gzuncompress($this->Memcached->Fetch($mckey)), true)) {
                              $query = "SELECT b.id, b.user_id, b.ban_time, b.ban_expire, b.ban_reason, b.banned_by AS admin_user_id, bu.username, bu.reported_to_sfs, au.username AS admin_username
                  Severity: Minor
                  Found in lib/BanControl/BanControl.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 '91', column '68').
                  Open

                      public function loadAll() {
                          // Attempt to load combined users & IPs first
                          if (empty($this->users) || empty($this->ip_addresses)) {
                              if ($this->Memcached->contains(self::CACHE_KEY_ALL) && $array = json_decode(gzuncompress($this->Memcached->Fetch(self::CACHE_KEY_ALL)), true)) {
                                  $this->users = $array['users'];
                  Severity: Minor
                  Found in lib/BanControl/BanControl.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 '184', column '67').
                  Open

                      public function loadIPs($skipCache = null) {
                          $mckey = "railpage:bancontrol.ips;v4"; 
                          
                          if ($skipCache || !$this->Memcached->contains($mckey) || !$this->ip_addresses = json_decode(gzuncompress($this->Memcached->Fetch($mckey)), true)) {
                              $query = "SELECT b.id, b.ip, b.ban_time, b.ban_expire, b.ban_reason, b.banned_by AS admin_user_id, au.username AS admin_username
                  Severity: Minor
                  Found in lib/BanControl/BanControl.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 using empty try-catch blocks in isClientBanned.
                  Open

                          } catch (Exception $e) {
                              
                          }
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php by phpmd

                  EmptyCatchBlock

                  Since: 2.7.0

                  Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

                  Example

                  class Foo {
                  
                    public function bar()
                    {
                        try {
                            // ...
                        } catch (Exception $e) {} // empty catch block
                    }
                  }

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

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

                      public function loadIPs($skipCache = null) {
                          $mckey = "railpage:bancontrol.ips;v4"; 
                          
                          if ($skipCache || !$this->Memcached->contains($mckey) || !$this->ip_addresses = json_decode(gzuncompress($this->Memcached->Fetch($mckey)), true)) {
                              $query = "SELECT b.id, b.ip, b.ban_time, b.ban_expire, b.ban_reason, b.banned_by AS admin_user_id, au.username AS admin_username
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 1 other location - About 1 day to fix
                  lib/BanControl/BanControl.php on lines 148..171

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 183.

                  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 loadUsers($skipCache = null) {
                          $mckey = "railpage:bancontrol.users;v5"; 
                          
                          if ($skipCache || !$this->Memcached->contains($mckey) || !$this->users = json_decode(gzuncompress($this->Memcached->Fetch($mckey)), true)) {
                              $query = "SELECT b.id, b.user_id, b.ban_time, b.ban_expire, b.ban_reason, b.banned_by AS admin_user_id, bu.username, bu.reported_to_sfs, au.username AS admin_username
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 1 other location - About 1 day to fix
                  lib/BanControl/BanControl.php on lines 181..203

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

                  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

                          $data = array(
                              "ip"            => $ipAddress,
                              "ban_active"    => 1,
                              "ban_time"      => time(),
                              "ban_reason"    => $reason,
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 1 other location - About 1 hr to fix
                  lib/BanControl/BanControl.php on lines 275..282

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

                          $data = array(
                              "user_id"       => $userId,
                              "ban_active"    => 1,
                              "ban_time"      => time(),
                              "ban_reason"    => $reason,
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 1 other location - About 1 hr to fix
                  lib/BanControl/BanControl.php on lines 383..390

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

                          if (!filter_var($ipAddress, FILTER_VALIDATE_IP)) {
                              throw new Exception("Cannot peform IP ban lookup - no IP address given"); 
                              return false;
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 1 hr to fix
                  lib/Locos/Locomotive.php on lines 1064..1067
                  lib/Locos/Locomotive.php on lines 1069..1072
                  lib/Locos/Locomotive.php on lines 1098..1101

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

                  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

                          try {
                              $this->Memcached->delete("railpage:bancontrol.ips"); 
                              $this->Memcached->delete(self::CACHE_KEY_ALL);
                          } catch (Exception $e) {
                              // throw it away
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 1 hr to fix
                  lib/BanControl/BanControl.php on lines 370..375
                  lib/BanControl/BanControl.php on lines 424..429
                  lib/BanControl/BanControl.php on lines 582..587

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

                  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

                          try {
                              $this->Memcached->delete("railpage:bancontrol.users"); 
                              $this->Memcached->delete(self::CACHE_KEY_ALL);
                          } catch (Exception $e) {
                              // throw it away
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 1 hr to fix
                  lib/BanControl/BanControl.php on lines 370..375
                  lib/BanControl/BanControl.php on lines 424..429
                  lib/BanControl/BanControl.php on lines 520..525

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

                  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

                          try {
                              $this->Memcached->delete("railpage:bancontrol.ips"); 
                              $this->Memcached->delete(self::CACHE_KEY_ALL);
                          } catch (Exception $e) {
                              // throw it away
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 1 hr to fix
                  lib/BanControl/BanControl.php on lines 424..429
                  lib/BanControl/BanControl.php on lines 520..525
                  lib/BanControl/BanControl.php on lines 582..587

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

                  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

                          try {
                              $this->Memcached->delete("railpage:bancontrol.users"); 
                              $this->Memcached->delete(self::CACHE_KEY_ALL);
                          } catch (Exception $e) {
                              // throw it away
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 1 hr to fix
                  lib/BanControl/BanControl.php on lines 370..375
                  lib/BanControl/BanControl.php on lines 520..525
                  lib/BanControl/BanControl.php on lines 582..587

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

                  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 banUser($userId = null, $reason = null, $expiry = "0", $adminUserId = null) {
                          
                          if (!filter_var($userId, FILTER_VALIDATE_INT)) {
                              throw new InvalidArgumentException("No user ID supplied"); 
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 1 other location - About 1 hr to fix
                  lib/BanControl/BanControl.php on lines 352..406

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

                  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 banIP($ipAddress = null, $reason = null, $expiry = "0", $adminUserId = null) {
                          
                          if (is_null($ipAddress)) {
                              throw new InvalidArgumentException("No IP address supplied"); 
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 1 other location - About 1 hr to fix
                  lib/BanControl/BanControl.php on lines 237..339

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

                  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

                          $this->Memcached->save($cachekey_ip, false, strtotime("+5 weeks")); 
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php and 1 other location - About 50 mins to fix
                  lib/BanControl/BanControl.php on lines 460..460

                  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

                              $this->Memcached->save($cachekey_user, false, strtotime("+5 weeks")); 
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php and 1 other location - About 50 mins to fix
                  lib/BanControl/BanControl.php on lines 557..557

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

                          if ($userId == null) {
                              $query = "SELECT user_id FROM bancontrol WHERE id = ?"; 
                          
                              $userId = $this->db->fetchOne($query, $banId);
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 45 mins to fix
                  lib/Forums/Forum.php on lines 191..204
                  lib/Locos/Manufacturer.php on lines 86..92
                  lib/Locos/Manufacturer.php on lines 89..92

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

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

                          if (is_null($ipAddress)) {
                              throw new InvalidArgumentException("No IP address supplied"); 
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 20 other locations - About 35 mins to fix
                  lib/Events/EventDate.php on lines 372..374
                  lib/Images/Image.php on lines 963..965
                  lib/Images/Image.php on lines 1095..1097
                  lib/Images/Images.php on lines 96..98
                  lib/Images/Images.php on lines 137..139
                  lib/Locations/Region.php on lines 93..95
                  lib/Locos/Locos.php on lines 590..592
                  lib/Locos/Locos.php on lines 901..903
                  lib/Locos/Locos.php on lines 925..927
                  lib/Railcams/Storage/LocalFS.php on lines 127..129
                  lib/Users/User.php on lines 2572..2574
                  lib/Users/User.php on lines 2576..2578
                  lib/Users/User.php on lines 2584..2586
                  lib/Users/Utility/PasswordUtility.php on lines 70..72
                  lib/Users/Utility/PasswordUtility.php on lines 74..76
                  lib/Users/Utility/PasswordUtility.php on lines 78..80
                  lib/API.php on lines 124..126
                  lib/API.php on lines 194..196
                  lib/BanControl/BanControl.php on lines 243..245
                  lib/BanControl/BanControl.php on lines 358..360

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

                          if (is_null($reason)) {
                              throw new InvalidArgumentException("No reason was supplied"); 
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 20 other locations - About 35 mins to fix
                  lib/Events/EventDate.php on lines 372..374
                  lib/Images/Image.php on lines 963..965
                  lib/Images/Image.php on lines 1095..1097
                  lib/Images/Images.php on lines 96..98
                  lib/Images/Images.php on lines 137..139
                  lib/Locations/Region.php on lines 93..95
                  lib/Locos/Locos.php on lines 590..592
                  lib/Locos/Locos.php on lines 901..903
                  lib/Locos/Locos.php on lines 925..927
                  lib/Railcams/Storage/LocalFS.php on lines 127..129
                  lib/Users/User.php on lines 2572..2574
                  lib/Users/User.php on lines 2576..2578
                  lib/Users/User.php on lines 2584..2586
                  lib/Users/Utility/PasswordUtility.php on lines 70..72
                  lib/Users/Utility/PasswordUtility.php on lines 74..76
                  lib/Users/Utility/PasswordUtility.php on lines 78..80
                  lib/API.php on lines 124..126
                  lib/API.php on lines 194..196
                  lib/BanControl/BanControl.php on lines 354..356
                  lib/BanControl/BanControl.php on lines 358..360

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

                          if (is_null($reason)) {
                              throw new InvalidArgumentException("No reason was supplied"); 
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 20 other locations - About 35 mins to fix
                  lib/Events/EventDate.php on lines 372..374
                  lib/Images/Image.php on lines 963..965
                  lib/Images/Image.php on lines 1095..1097
                  lib/Images/Images.php on lines 96..98
                  lib/Images/Images.php on lines 137..139
                  lib/Locations/Region.php on lines 93..95
                  lib/Locos/Locos.php on lines 590..592
                  lib/Locos/Locos.php on lines 901..903
                  lib/Locos/Locos.php on lines 925..927
                  lib/Railcams/Storage/LocalFS.php on lines 127..129
                  lib/Users/User.php on lines 2572..2574
                  lib/Users/User.php on lines 2576..2578
                  lib/Users/User.php on lines 2584..2586
                  lib/Users/Utility/PasswordUtility.php on lines 70..72
                  lib/Users/Utility/PasswordUtility.php on lines 74..76
                  lib/Users/Utility/PasswordUtility.php on lines 78..80
                  lib/API.php on lines 124..126
                  lib/API.php on lines 194..196
                  lib/BanControl/BanControl.php on lines 243..245
                  lib/BanControl/BanControl.php on lines 354..356

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

                          try {
                              $this->Redis->delete("railpage:bancontrol");
                          } catch (Exception $e) {
                              // throw it away
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 4 other locations - About 35 mins to fix
                  lib/BanControl/BanControl.php on lines 269..273
                  lib/BanControl/BanControl.php on lines 377..381
                  lib/BanControl/BanControl.php on lines 431..435
                  lib/BanControl/BanControl.php on lines 589..593

                  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

                              $Memcached->save($cachekey_user, 0, strtotime("+5 weeks")); 
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 35 mins to fix
                  lib/BanControl/BanControl.php on lines 775..775
                  lib/BanControl/BanControl.php on lines 784..784
                  lib/BanControl/BanControl.php on lines 791..791

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

                          try {
                              $this->Redis->delete("railpage:bancontrol");
                          } catch (Exception $e) {
                              // throw it away
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 4 other locations - About 35 mins to fix
                  lib/BanControl/BanControl.php on lines 377..381
                  lib/BanControl/BanControl.php on lines 431..435
                  lib/BanControl/BanControl.php on lines 527..531
                  lib/BanControl/BanControl.php on lines 589..593

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

                          try {
                              $this->Redis->delete("railpage:bancontrol");
                          } catch (Exception $e) {
                              // throw it away
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 4 other locations - About 35 mins to fix
                  lib/BanControl/BanControl.php on lines 269..273
                  lib/BanControl/BanControl.php on lines 377..381
                  lib/BanControl/BanControl.php on lines 431..435
                  lib/BanControl/BanControl.php on lines 527..531

                  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

                              $Memcached->save($cachekey_addr, 1, strtotime("+5 weeks")); 
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 35 mins to fix
                  lib/BanControl/BanControl.php on lines 775..775
                  lib/BanControl/BanControl.php on lines 783..783
                  lib/BanControl/BanControl.php on lines 791..791

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

                          try {
                              $this->Redis->delete("railpage:bancontrol");
                          } catch (Exception $e) {
                              // throw it away
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 4 other locations - About 35 mins to fix
                  lib/BanControl/BanControl.php on lines 269..273
                  lib/BanControl/BanControl.php on lines 431..435
                  lib/BanControl/BanControl.php on lines 527..531
                  lib/BanControl/BanControl.php on lines 589..593

                  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

                          if ($force == null) {
                              $force = false;
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 35 mins to fix
                  lib/Downloads/Base.php on lines 81..83
                  lib/Images/Screener.php on lines 91..93
                  lib/Locos/LocoClass.php on lines 285..287

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

                          try {
                              $this->Redis->delete("railpage:bancontrol");
                          } catch (Exception $e) {
                              // throw it away
                          }
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 4 other locations - About 35 mins to fix
                  lib/BanControl/BanControl.php on lines 269..273
                  lib/BanControl/BanControl.php on lines 377..381
                  lib/BanControl/BanControl.php on lines 527..531
                  lib/BanControl/BanControl.php on lines 589..593

                  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

                          $Memcached->save($cachekey_addr, 0, strtotime("+5 weeks")); 
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 35 mins to fix
                  lib/BanControl/BanControl.php on lines 775..775
                  lib/BanControl/BanControl.php on lines 783..783
                  lib/BanControl/BanControl.php on lines 784..784

                  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

                              $Memcached->save($cachekey_user, 1, strtotime("+5 weeks"));
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 35 mins to fix
                  lib/BanControl/BanControl.php on lines 783..783
                  lib/BanControl/BanControl.php on lines 784..784
                  lib/BanControl/BanControl.php on lines 791..791

                  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

                                  $Notification->body = $Smarty->Fetch($Smarty->ResolveTemplate("email_unban"));
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 30 mins to fix
                  lib/Images/Utility/CompNotify.php on lines 115..115
                  lib/Images/Utility/CompetitionUtility.php on lines 469..469
                  lib/BanControl/BanControl.php on lines 332..332

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 21.

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

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

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

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

                  Refactorings

                  Further Reading

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

                          $Notification->body = $Smarty->Fetch($Smarty->ResolveTemplate("email.ban"));
                  Severity: Major
                  Found in lib/BanControl/BanControl.php and 3 other locations - About 30 mins to fix
                  lib/Images/Utility/CompNotify.php on lines 115..115
                  lib/Images/Utility/CompetitionUtility.php on lines 469..469
                  lib/BanControl/BanControl.php on lines 485..485

                  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

                          $Notification->addRecipient($ThisUser->id, $ThisUser->username, $ThisUser->contact_email);
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php and 2 other locations - About 30 mins to fix
                  lib/Images/Utility/CompetitionUtility.php on lines 582..582
                  lib/BanControl/BanControl.php on lines 484..484

                  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

                                  $Notification->addRecipient($ThisUser->id, $ThisUser->username, $ThisUser->contact_email);
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php and 2 other locations - About 30 mins to fix
                  lib/Images/Utility/CompetitionUtility.php on lines 582..582
                  lib/BanControl/BanControl.php on lines 331..331

                  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

                          $this->Memcached->save($cachekey_user, false, $expire); 
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php and 2 other locations - About 30 mins to fix
                  lib/BanControl/BanControl.php on lines 289..289
                  lib/BanControl/BanControl.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 20.

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

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

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

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

                  Refactorings

                  Further Reading

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

                          $this->Memcached->save($cachekey_ip, true, $expire); 
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php and 2 other locations - About 30 mins to fix
                  lib/BanControl/BanControl.php on lines 289..289
                  lib/BanControl/BanControl.php on lines 608..608

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 20.

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

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

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

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

                  Refactorings

                  Further Reading

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

                          $this->Memcached->save($cachekey_user, true, $expire); 
                  Severity: Minor
                  Found in lib/BanControl/BanControl.php and 2 other locations - About 30 mins to fix
                  lib/BanControl/BanControl.php on lines 396..396
                  lib/BanControl/BanControl.php on lines 608..608

                  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

                      }

                  Blank line found at end of control structure
                  Open

                                  

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

                      }

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

                      }

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

                      }

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

                      }

                  Blank line found at end of control structure
                  Open

                              

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

                      }

                  Blank line found at start of control structure
                  Open

                          } catch (Exception $e) {

                  There are no issues that match your filters.

                  Category
                  Status