librenms/librenms

View on GitHub
LibreNMS/IRCBot.php

Summary

Maintainability
F
1 wk
Test Coverage

The method proceedCommand() contains an eval expression.
Open

            return eval($this->external[$command]);
Severity: Minor
Found in LibreNMS/IRCBot.php by phpmd

EvalExpression

Since: 0.2

An eval-expression is untestable, a security risk and bad practice. Therefore it should be avoided. Consider to replace the eval-expression with regular code.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            eval('$param = 23;');
        }
    }
}

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

File IRCBot.php has 824 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
 * Copyright (C) 2014  <singh@devilcode.org>
 * Modified and Relicensed by <f0o@devilcode.org> under the expressed
 * permission by the Copyright-Holder <singh@devilcode.org>.
Severity: Major
Found in LibreNMS/IRCBot.php - About 1 day to fix

    Function getData has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getData()
        {
            if (($data = $this->read('irc')) !== false) {
                $this->last_activity = time();
                $this->data = $data;
    Severity: Minor
    Found in LibreNMS/IRCBot.php - About 7 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

    IRCBot has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class IRCBot
    {
        private $config;
    
        private $user;
    Severity: Minor
    Found in LibreNMS/IRCBot.php - About 5 hrs to fix

      Function alertData has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          private function alertData()
          {
              if (($alert = $this->read('alert')) !== false) {
                  $alert = json_decode($alert, true);
                  if (! is_array($alert)) {
      Severity: Minor
      Found in LibreNMS/IRCBot.php - About 3 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function init has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          private function init()
          {
              if ($this->config['irc_alert']) {
                  if (! $this->connectAlert()) {
                      sleep(5);
      Severity: Minor
      Found in LibreNMS/IRCBot.php - About 3 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

      The class IRCBot has 32 non-getter- and setter-methods. Consider refactoring IRCBot to keep number of methods under 25.
      Open

      class IRCBot
      {
          private $config;
      
          private $user;
      Severity: Minor
      Found in LibreNMS/IRCBot.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many 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'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

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

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

      class IRCBot
      {
          private $config;
      
          private $user;
      Severity: Minor
      Found in LibreNMS/IRCBot.php by phpmd

      Function _log has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          private function _log($params)
          {
              $num = 1;
              $hostname = '';
              $params = explode(' ', $params);
      Severity: Minor
      Found in LibreNMS/IRCBot.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 _status has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function _status($params)
          {
              $params = explode(' ', $params);
              $statustype = $params[0];
      
      
      Severity: Major
      Found in LibreNMS/IRCBot.php - About 2 hrs to fix

        Method getData has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getData()
            {
                if (($data = $this->read('irc')) !== false) {
                    $this->last_activity = time();
                    $this->data = $data;
        Severity: Major
        Found in LibreNMS/IRCBot.php - About 2 hrs to fix

          Function _auth has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              private function _auth($params)
              {
                  global $authorizer;
                  $params = explode(' ', $params, 2);
                  if (strlen($params[0]) == 64) {
          Severity: Minor
          Found in LibreNMS/IRCBot.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

          Function sendAlert has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              private function sendAlert($sendto, $severity, $alert)
              {
                  $sendto = explode(' ', $sendto)[0];
                  $this->ircRaw('PRIVMSG ' . $sendto . ' :' . $severity . trim($alert['title']));
                  if ($this->config['irc_alert_short']) {
          Severity: Minor
          Found in LibreNMS/IRCBot.php - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

          Function _status has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              private function _status($params)
              {
                  $params = explode(' ', $params);
                  $statustype = $params[0];
          
          
          Severity: Minor
          Found in LibreNMS/IRCBot.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 _log has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function _log($params)
              {
                  $num = 1;
                  $hostname = '';
                  $params = explode(' ', $params);
          Severity: Minor
          Found in LibreNMS/IRCBot.php - About 1 hr to fix

            Method init has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function init()
                {
                    if ($this->config['irc_alert']) {
                        if (! $this->connectAlert()) {
                            sleep(5);
            Severity: Minor
            Found in LibreNMS/IRCBot.php - About 1 hr to fix

              Method alertData has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function alertData()
                  {
                      if (($alert = $this->read('alert')) !== false) {
                          $alert = json_decode($alert, true);
                          if (! is_array($alert)) {
              Severity: Minor
              Found in LibreNMS/IRCBot.php - About 1 hr to fix

                Method _color has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function _color($text, $fg_color, $bg_color = null, $other = null)
                    {
                        $colors = [
                            'white' => '00',
                            'black' => '01',
                Severity: Minor
                Found in LibreNMS/IRCBot.php - About 1 hr to fix

                  Function connect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function connect($try = 0)
                      {
                          if ($try > $this->max_retry) {
                              $this->log('Failed too many connection attempts, aborting');
                  
                  
                  Severity: Minor
                  Found in LibreNMS/IRCBot.php - About 1 hr to fix

                  Cognitive Complexity

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

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

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

                  Further reading

                  Function hostAuth has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function hostAuth()
                      {
                          $this->log('HostAuth');
                          global $authorizer;
                          foreach ($this->config['irc_auth'] as $nms_user => $hosts) {
                  Severity: Minor
                  Found in LibreNMS/IRCBot.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

                  The class IRCBot has 24 fields. Consider redesigning IRCBot to keep the number of fields under 15.
                  Open

                  class IRCBot
                  {
                      private $config;
                  
                      private $user;
                  Severity: Minor
                  Found in LibreNMS/IRCBot.php by phpmd

                  TooManyFields

                  Since: 0.1

                  Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

                  Example

                  class Person {
                     protected $one;
                     private $two;
                     private $three;
                     [... many more fields ...]
                  }

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

                  Method connect has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function connect($try = 0)
                      {
                          if ($try > $this->max_retry) {
                              $this->log('Failed too many connection attempts, aborting');
                  
                  
                  Severity: Minor
                  Found in LibreNMS/IRCBot.php - About 1 hr to fix

                    Method _html2irc has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function _html2irc($string)
                        {
                            $string = urldecode($string);
                            $string = preg_replace('#<b>#i', chr(2), $string);
                            $string = preg_replace('#</b>#i', chr(2), $string);
                    Severity: Minor
                    Found in LibreNMS/IRCBot.php - About 1 hr to fix

                      Method __construct has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function __construct()
                          {
                              $this->log('Setting up IRC-Bot..');
                      
                              $this->config = Config::getAll();
                      Severity: Minor
                      Found in LibreNMS/IRCBot.php - About 1 hr to fix

                        Method sendAlert has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function sendAlert($sendto, $severity, $alert)
                            {
                                $sendto = explode(' ', $sendto)[0];
                                $this->ircRaw('PRIVMSG ' . $sendto . ' :' . $severity . trim($alert['title']));
                                if ($this->config['irc_alert_short']) {
                        Severity: Minor
                        Found in LibreNMS/IRCBot.php - About 1 hr to fix

                          Method _auth has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function _auth($params)
                              {
                                  global $authorizer;
                                  $params = explode(' ', $params, 2);
                                  if (strlen($params[0]) == 64) {
                          Severity: Minor
                          Found in LibreNMS/IRCBot.php - About 1 hr to fix

                            Function __construct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function __construct()
                                {
                                    $this->log('Setting up IRC-Bot..');
                            
                                    $this->config = Config::getAll();
                            Severity: Minor
                            Found in LibreNMS/IRCBot.php - About 45 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

                            Function connectAlert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function connectAlert()
                                {
                                    $container_dir = '/data';
                                    if (file_exists($container_dir) and posix_getpwuid(fileowner($container_dir))['name'] == 'librenms') {
                                        $f = $container_dir . '/.ircbot.alert';
                            Severity: Minor
                            Found in LibreNMS/IRCBot.php - About 35 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

                            Function _color has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function _color($text, $fg_color, $bg_color = null, $other = null)
                                {
                                    $colors = [
                                        'white' => '00',
                                        'black' => '01',
                            Severity: Minor
                            Found in LibreNMS/IRCBot.php - About 35 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 $this->respond('Who are you again?');
                            Severity: Major
                            Found in LibreNMS/IRCBot.php - About 30 mins to fix

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

                                  private function _reload($params)
                                  {
                                      if ($this->user['user']->can('irc.reload')) {
                                          if ($params == 'external') {
                                              $this->respond('Reloading external scripts.');
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php - About 25 mins to fix

                              Cognitive Complexity

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

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

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

                              Further reading

                              The method alertData() has an NPath complexity of 361. The configured NPath complexity threshold is 200.
                              Open

                                  private function alertData()
                                  {
                                      if (($alert = $this->read('alert')) !== false) {
                                          $alert = json_decode($alert, true);
                                          if (! is_array($alert)) {
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 _log() has an NPath complexity of 728. The configured NPath complexity threshold is 200.
                              Open

                                  private function _log($params)
                                  {
                                      $num = 1;
                                      $hostname = '';
                                      $params = explode(' ', $params);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 class IRCBot has 1054 lines of code. Current threshold is 1000. Avoid really long classes.
                              Open

                              class IRCBot
                              {
                                  private $config;
                              
                                  private $user;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              The method init() has an NPath complexity of 438. The configured NPath complexity threshold is 200.
                              Open

                                  private function init()
                                  {
                                      if ($this->config['irc_alert']) {
                                          if (! $this->connectAlert()) {
                                              sleep(5);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 getData() has an NPath complexity of 41473. The configured NPath complexity threshold is 200.
                              Open

                                  private function getData()
                                  {
                                      if (($data = $this->read('irc')) !== false) {
                                          $this->last_activity = time();
                                          $this->data = $data;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 getData() has a Cyclomatic Complexity of 26. The configured cyclomatic complexity threshold is 10.
                              Open

                                  private function getData()
                                  {
                                      if (($data = $this->read('irc')) !== false) {
                                          $this->last_activity = time();
                                          $this->data = $data;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 init() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                              Open

                                  private function init()
                                  {
                                      if ($this->config['irc_alert']) {
                                          if (! $this->connectAlert()) {
                                              sleep(5);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 alertData() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                              Open

                                  private function alertData()
                                  {
                                      if (($alert = $this->read('alert')) !== false) {
                                          $alert = json_decode($alert, true);
                                          if (! is_array($alert)) {
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 connect() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                              Open

                                  private function connect($try = 0)
                                  {
                                      if ($try > $this->max_retry) {
                                          $this->log('Failed too many connection attempts, aborting');
                              
                              
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 _log() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                              Open

                                  private function _log($params)
                                  {
                                      $num = 1;
                                      $hostname = '';
                                      $params = explode(' ', $params);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 _status() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10.
                              Open

                                  private function _status($params)
                                  {
                                      $params = explode(' ', $params);
                                      $statustype = $params[0];
                              
                              
                              Severity: Minor
                              Found in LibreNMS/IRCBot.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 class IRCBot has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
                              Open

                              class IRCBot
                              {
                                  private $config;
                              
                                  private $user;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CouplingBetweenObjects

                              Since: 1.1.0

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

                              Example

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

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

                              The method joinChan has a boolean flag argument $chan, which is a certain sign of a Single Responsibility Principle violation.
                              Open

                                  private function joinChan($chan = false)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              BooleanArgumentFlag

                              Since: 1.4.0

                              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                              Example

                              class Foo {
                                  public function bar($flag = true) {
                                  }
                              }

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

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

                                  private function alertData()
                                  {
                                      if (($alert = $this->read('alert')) !== false) {
                                          $alert = json_decode($alert, true);
                                          if (! is_array($alert)) {
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              IfStatementAssignment

                              Since: 2.7.0

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

                              Example

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

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

                              The method _auth uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                              } else {
                                                  return $this->respond('Sorry, seems like mail doesnt like us.');
                                              }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          $this->port = $this->config['irc_port'];
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

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

                                  private function connectAlert()
                                  {
                                      $container_dir = '/data';
                                      if (file_exists($container_dir) and posix_getpwuid(fileowner($container_dir))['name'] == 'librenms') {
                                          $f = $container_dir . '/.ircbot.alert';
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              IfStatementAssignment

                              Since: 2.7.0

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

                              Example

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

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

                              The method connect uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                          } else {
                                              sleep(300);
                                          }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method _quit uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          return $this->respond('Permission denied.');
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method _join uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          return $this->respond('Permission denied.');
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method alertData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                          } else {
                                              foreach ($this->authd as $nick => $data) {
                                                  if ($data['expire'] >= time()) {
                                                      $this->sendAlert($nick, $severity, $alert);
                                                  }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method connect uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          $server = $this->server;
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method isAuthd uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          return false;
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method connect uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          $this->socket['irc'] = fsockopen($server, $this->port);
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method connect uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          stream_set_blocking($this->socket['irc'], false);
                              
                                          return true;
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method _status uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                              } else {
                                                  $prtcount = $this->_color($prtcount, 'green', null, 'bold');
                                              }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method connectAlert uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          $f = $this->config['install_dir'] . '/.ircbot.alert';
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method _auth uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                          } else {
                                              return $this->respond('Nope.');
                                          }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method _auth uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          $user = User::firstWhere('username', $params[0]);
                                          if ($user->email && $user->username == $params[0]) {
                                              $token = hash('gost', openssl_random_pseudo_bytes(1024));
                                              $this->tokens[$this->getUser($this->data)] = $token;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method _status uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                                  } else {
                                                      $status_counts[$status] = 0;
                                                  }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method _log uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                              } else {
                                                  $response .= $logline->message . ' ';
                                              }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

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

                                  private function loadExternal()
                                  {
                                      if (! $this->config['irc_external']) {
                                          return true;
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              IfStatementAssignment

                              Since: 2.7.0

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

                              Example

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

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

                              The method _auth uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                          } else {
                                              return $this->respond('Who are you again?');
                                          }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method _reload uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                      } else {
                                          return $this->respond('Permission denied.');
                                      }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              The method _log uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                          } else {
                                              $response .= $logline->message . ' ';
                                          }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

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

                                  private function getData()
                                  {
                                      if (($data = $this->read('irc')) !== false) {
                                          $this->last_activity = time();
                                          $this->data = $data;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              IfStatementAssignment

                              Since: 2.7.0

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

                              Example

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

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

                              The method _status uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                              Open

                                              } else {
                                                  $devcount = $this->_color($devcount, 'green', null, 'bold');
                                              }
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ElseExpression

                              Since: 1.4.0

                              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                              Example

                              class Foo
                              {
                                  public function bar($flag)
                                  {
                                      if ($flag) {
                                          // one branch
                                      } else {
                                          // another branch
                                      }
                                  }
                              }

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

                              Avoid unused private methods such as '_auth'.
                              Open

                                  private function _auth($params)
                                  {
                                      global $authorizer;
                                      $params = explode(' ', $params, 2);
                                      if (strlen($params[0]) == 64) {
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

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

                                          $this->socket['irc'] = stream_socket_client($server . ':' . $this->port, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ssl_context);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedLocalVariable

                              Since: 0.2

                              Detects when a local variable is declared and/or assigned, but not used.

                              Example

                              class Foo {
                                  public function doSomething()
                                  {
                                      $i = 5; // Unused
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                              Avoid unused parameters such as '$params'.
                              Open

                                  private function _quit($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedFormalParameter

                              Since: 0.2

                              Avoid passing parameters to methods or constructors and then not using those parameters.

                              Example

                              class Foo
                              {
                                  private function bar($howdy)
                                  {
                                      // $howdy is not used
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                              The method _quit() contains an exit expression.
                              Open

                                          return exit;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ExitExpression

                              Since: 0.2

                              An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                              Example

                              class Foo {
                                  public function bar($param)  {
                                      if ($param === 42) {
                                          exit(23);
                                      }
                                  }
                              }

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

                              Avoid unused private methods such as '_device'.
                              Open

                                  private function _device($params)
                                  {
                                      $params = explode(' ', $params);
                                      $hostname = $params[0];
                                      $device = Device::hasAccess($this->user['user'])->firstWhere('hostname', $hostname);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              The method connect() contains an exit expression.
                              Open

                                          return exit;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ExitExpression

                              Since: 0.2

                              An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                              Example

                              class Foo {
                                  public function bar($param)  {
                                      if ($param === 42) {
                                          exit(23);
                                      }
                                  }
                              }

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

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

                                          $this->socket['irc'] = stream_socket_client($server . ':' . $this->port, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ssl_context);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedLocalVariable

                              Since: 0.2

                              Detects when a local variable is declared and/or assigned, but not used.

                              Example

                              class Foo {
                                  public function doSomething()
                                  {
                                      $i = 5; // Unused
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                              Avoid unused private methods such as '_reload'.
                              Open

                                  private function _reload($params)
                                  {
                                      if ($this->user['user']->can('irc.reload')) {
                                          if ($params == 'external') {
                                              $this->respond('Reloading external scripts.');
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              Avoid unused private methods such as '_quit'.
                              Open

                                  private function _quit($params)
                                  {
                                      if ($this->user['user']->can('irc.quit')) {
                                          $this->ircRaw('QUIT :Requested');
                              
                              
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              Avoid unused private methods such as '_log'.
                              Open

                                  private function _log($params)
                                  {
                                      $num = 1;
                                      $hostname = '';
                                      $params = explode(' ', $params);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              Avoid unused parameters such as '$params'.
                              Open

                                  private function _down($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedFormalParameter

                              Since: 0.2

                              Avoid passing parameters to methods or constructors and then not using those parameters.

                              Example

                              class Foo
                              {
                                  private function bar($howdy)
                                  {
                                      // $howdy is not used
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                              The method chkdb() contains an exit expression.
                              Open

                                              return exit;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ExitExpression

                              Since: 0.2

                              An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                              Example

                              class Foo {
                                  public function bar($param)  {
                                      if ($param === 42) {
                                          exit(23);
                                      }
                                  }
                              }

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

                              Avoid unused private methods such as '_join'.
                              Open

                                  private function _join($params)
                                  {
                                      if ($this->user['user']->can('irc.join')) {
                                          return $this->joinChan($params);
                                      } else {
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              Avoid unused parameters such as '$params'.
                              Open

                                  private function _version($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedFormalParameter

                              Since: 0.2

                              Avoid passing parameters to methods or constructors and then not using those parameters.

                              Example

                              class Foo
                              {
                                  private function bar($howdy)
                                  {
                                      // $howdy is not used
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                              Avoid unused private methods such as '_down'.
                              Open

                                  private function _down($params)
                                  {
                                      $devices = Device::hasAccess($this->user['user'])->isDown()
                                          ->select(['device_id', 'hostname', 'sysName', 'display', 'ip'])->get();
                              
                              
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              Avoid unused parameters such as '$params'.
                              Open

                                  private function _listdevices($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedFormalParameter

                              Since: 0.2

                              Avoid passing parameters to methods or constructors and then not using those parameters.

                              Example

                              class Foo
                              {
                                  private function bar($howdy)
                                  {
                                      // $howdy is not used
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                              Avoid unused parameters such as '$params'.
                              Open

                                  private function _help($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedFormalParameter

                              Since: 0.2

                              Avoid passing parameters to methods or constructors and then not using those parameters.

                              Example

                              class Foo
                              {
                                  private function bar($howdy)
                                  {
                                      // $howdy is not used
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                              Avoid unused parameters such as '$param'.
                              Open

                                  private function getChan($param)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedFormalParameter

                              Since: 0.2

                              Avoid passing parameters to methods or constructors and then not using those parameters.

                              Example

                              class Foo
                              {
                                  private function bar($howdy)
                                  {
                                      // $howdy is not used
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                              Avoid unused private methods such as '_help'.
                              Open

                                  private function _help($params)
                                  {
                                      $msg = implode(', ', $this->commands);
                                      if (count($this->external) > 0) {
                                          $msg .= ', ' . implode(', ', array_keys($this->external));
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              Avoid unused private methods such as '_version'.
                              Open

                                  private function _version($params)
                                  {
                                      $version = Version::get();
                              
                                      $msg = $this->config['project_name'] . ', Version: ' . $version->name() . ', DB schema: ' . $version->databaseMigrationCount() . ', PHP: ' . PHP_VERSION;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              Avoid unused private methods such as '_listdevices'.
                              Open

                                  private function _listdevices($params)
                                  {
                                      $devices = Device::hasAccess($this->user['user'])->pluck('hostname');
                              
                                      $msg = $devices->implode(', ');
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

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

                                      global $authorizer;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedLocalVariable

                              Since: 0.2

                              Detects when a local variable is declared and/or assigned, but not used.

                              Example

                              class Foo {
                                  public function doSomething()
                                  {
                                      $i = 5; // Unused
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

                                      global $authorizer;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedLocalVariable

                              Since: 0.2

                              Detects when a local variable is declared and/or assigned, but not used.

                              Example

                              class Foo {
                                  public function doSomething()
                                  {
                                      $i = 5; // Unused
                                  }
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                              Avoid unused private methods such as '_port'.
                              Open

                                  private function _port($params)
                                  {
                                      $params = explode(' ', $params);
                                      $hostname = $params[0];
                                      $ifname = $params[1];
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              Avoid unused private methods such as '_status'.
                              Open

                                  private function _status($params)
                                  {
                                      $params = explode(' ', $params);
                                      $statustype = $params[0];
                              
                              
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              UnusedPrivateMethod

                              Since: 0.2

                              Unused Private Method detects when a private method is declared but is unused.

                              Example

                              class Something
                              {
                                  private function foo() {} // unused
                              }

                              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

                              Avoid variables with short names like $j. Configured minimum length is 3.
                              Open

                                  private $j = 0;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ShortVariable

                              Since: 0.2

                              Detects when a field, local, or parameter has a very short name.

                              Example

                              class Something {
                                  private $q = 15; // VIOLATION - Field
                                  public static function main( array $as ) { // VIOLATION - Formal
                                      $r = 20 + $this->q; // VIOLATION - Local
                                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                          $r += $this->q;
                                      }
                                  }
                              }

                              Source https://phpmd.org/rules/naming.html#shortvariable

                              The property $max_retry is not named in camelCase.
                              Open

                              class IRCBot
                              {
                                  private $config;
                              
                                  private $user;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCasePropertyName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name attributes.

                              Example

                              class ClassName {
                                  protected $property_name;
                              }

                              Source

                              Avoid variables with short names like $r. Configured minimum length is 3.
                              Open

                                      $r = fread($this->socket[$buff], 8192);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ShortVariable

                              Since: 0.2

                              Detects when a field, local, or parameter has a very short name.

                              Example

                              class Something {
                                  private $q = 15; // VIOLATION - Field
                                  public static function main( array $as ) { // VIOLATION - Formal
                                      $r = 20 + $this->q; // VIOLATION - Local
                                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                          $r += $this->q;
                                      }
                                  }
                              }

                              Source https://phpmd.org/rules/naming.html#shortvariable

                              The property $last_activity is not named in camelCase.
                              Open

                              class IRCBot
                              {
                                  private $config;
                              
                                  private $user;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCasePropertyName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name attributes.

                              Example

                              class ClassName {
                                  protected $property_name;
                              }

                              Source

                              Avoid variables with short names like $f. Configured minimum length is 3.
                              Open

                                          $f = $container_dir . '/.ircbot.alert';
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ShortVariable

                              Since: 0.2

                              Detects when a field, local, or parameter has a very short name.

                              Example

                              class Something {
                                  private $q = 15; // VIOLATION - Field
                                  public static function main( array $as ) { // VIOLATION - Formal
                                      $r = 20 + $this->q; // VIOLATION - Local
                                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                          $r += $this->q;
                                      }
                                  }
                              }

                              Source https://phpmd.org/rules/naming.html#shortvariable

                              Avoid variables with short names like $ex. Configured minimum length is 3.
                              Open

                                          $ex = explode(' ', $this->data);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              ShortVariable

                              Since: 0.2

                              Detects when a field, local, or parameter has a very short name.

                              Example

                              class Something {
                                  private $q = 15; // VIOLATION - Field
                                  public static function main( array $as ) { // VIOLATION - Formal
                                      $r = 20 + $this->q; // VIOLATION - Local
                                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                          $r += $this->q;
                                      }
                                  }
                              }

                              Source https://phpmd.org/rules/naming.html#shortvariable

                              Method name "_down" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _down($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_html2irc" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _html2irc($string)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_quit" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _quit($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_color" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _color($text, $fg_color, $bg_color = null, $other = null)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_help" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _help($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_device" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _device($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_auth" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _auth($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_join" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _join($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_reload" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _reload($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_log" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _log($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_version" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _version($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_listdevices" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _listdevices($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_port" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _port($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Method name "_status" should not be prefixed with an underscore to indicate visibility
                              Open

                                  private function _status($params)
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Space before opening parenthesis of function call prohibited
                              Open

                                              $prtdown = Port::hasAccess($this->user['user'])->isDown()->whereHas('device', fn ($q) => $q->where('ignore', 0))->count();
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Space before opening parenthesis of function call prohibited
                              Open

                                              $prtsht = Port::hasAccess($this->user['user'])->isShutdown()->whereHas('device', fn ($q) => $q->where('ignore', 0))->count();
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              Space before opening parenthesis of function call prohibited
                              Open

                                                  $query->isIgnored()->orWhereHas('device', fn ($q) => $q->where('ignore', 1));
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpcodesniffer

                              The method _help is not named in camelCase.
                              Open

                                  private function _help($params)
                                  {
                                      $msg = implode(', ', $this->commands);
                                      if (count($this->external) > 0) {
                                          $msg .= ', ' . implode(', ', array_keys($this->external));
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _status is not named in camelCase.
                              Open

                                  private function _status($params)
                                  {
                                      $params = explode(' ', $params);
                                      $statustype = $params[0];
                              
                              
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _join is not named in camelCase.
                              Open

                                  private function _join($params)
                                  {
                                      if ($this->user['user']->can('irc.join')) {
                                          return $this->joinChan($params);
                                      } else {
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _version is not named in camelCase.
                              Open

                                  private function _version($params)
                                  {
                                      $version = Version::get();
                              
                                      $msg = $this->config['project_name'] . ', Version: ' . $version->name() . ', DB schema: ' . $version->databaseMigrationCount() . ', PHP: ' . PHP_VERSION;
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _down is not named in camelCase.
                              Open

                                  private function _down($params)
                                  {
                                      $devices = Device::hasAccess($this->user['user'])->isDown()
                                          ->select(['device_id', 'hostname', 'sysName', 'display', 'ip'])->get();
                              
                              
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _device is not named in camelCase.
                              Open

                                  private function _device($params)
                                  {
                                      $params = explode(' ', $params);
                                      $hostname = $params[0];
                                      $device = Device::hasAccess($this->user['user'])->firstWhere('hostname', $hostname);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _quit is not named in camelCase.
                              Open

                                  private function _quit($params)
                                  {
                                      if ($this->user['user']->can('irc.quit')) {
                                          $this->ircRaw('QUIT :Requested');
                              
                              
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _reload is not named in camelCase.
                              Open

                                  private function _reload($params)
                                  {
                                      if ($this->user['user']->can('irc.reload')) {
                                          if ($params == 'external') {
                                              $this->respond('Reloading external scripts.');
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _log is not named in camelCase.
                              Open

                                  private function _log($params)
                                  {
                                      $num = 1;
                                      $hostname = '';
                                      $params = explode(' ', $params);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _listdevices is not named in camelCase.
                              Open

                                  private function _listdevices($params)
                                  {
                                      $devices = Device::hasAccess($this->user['user'])->pluck('hostname');
                              
                                      $msg = $devices->implode(', ');
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _auth is not named in camelCase.
                              Open

                                  private function _auth($params)
                                  {
                                      global $authorizer;
                                      $params = explode(' ', $params, 2);
                                      if (strlen($params[0]) == 64) {
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _html2irc is not named in camelCase.
                              Open

                                  private function _html2irc($string)
                                  {
                                      $string = urldecode($string);
                                      $string = preg_replace('#<b>#i', chr(2), $string);
                                      $string = preg_replace('#</b>#i', chr(2), $string);
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _port is not named in camelCase.
                              Open

                                  private function _port($params)
                                  {
                                      $params = explode(' ', $params);
                                      $hostname = $params[0];
                                      $ifname = $params[1];
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              The method _color is not named in camelCase.
                              Open

                                  private function _color($text, $fg_color, $bg_color = null, $other = null)
                                  {
                                      $colors = [
                                          'white' => '00',
                                          'black' => '01',
                              Severity: Minor
                              Found in LibreNMS/IRCBot.php by phpmd

                              CamelCaseMethodName

                              Since: 0.2

                              It is considered best practice to use the camelCase notation to name methods.

                              Example

                              class ClassName {
                                  public function get_name() {
                                  }
                              }

                              Source

                              There are no issues that match your filters.

                              Category
                              Status