librenms/librenms

View on GitHub
LibreNMS/Alert/Transport/Irc.php

Summary

Maintainability
A
0 mins
Test Coverage

The method contactIrc uses an else expression. Else is never necessary and you can simplify the code to work without else.
Open

            } else {
                return true;
            }
Severity: Minor
Found in LibreNMS/Alert/Transport/Irc.php by phpmd

Since: PHPMD 1.4.0

An if expression with an else branch is never necessary. You can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to read. To achieve this use early return statements. To achieve this 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: http://phpmd.org/rules/cleancode.txt

Avoid unused parameters such as '$opts'.
Open

    public function contactIrc($obj, $opts)
Severity: Minor
Found in LibreNMS/Alert/Transport/Irc.php by phpmd

Since: PHPMD 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: http://phpmd.org/rules/unusedcode.txt

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

            $r = fwrite($f, json_encode($obj) . "\n");
Severity: Minor
Found in LibreNMS/Alert/Transport/Irc.php by phpmd

Since: PHPMD 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: http://phpmd.org/rules/naming.txt

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

        $f = Config::get('install_dir') . '/.ircbot.alert';
Severity: Minor
Found in LibreNMS/Alert/Transport/Irc.php by phpmd

Since: PHPMD 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: http://phpmd.org/rules/naming.txt

There are no issues that match your filters.

Category
Status