LibreNMS/Alert/Transport/Alertmanager.php
Method contactAlertmanager
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function contactAlertmanager($obj, $api)
{
if ($obj['state'] == AlertState::RECOVERED) {
$alertmanager_status = 'endsAt';
} else {
Avoid unused parameters such as '$opts'. Open
Open
public function deliverAlert($obj, $opts)
- Read upRead up
- Exclude checks
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
}
}
Avoid unused local variables such as '$ret'. Open
Open
$ret = curl_exec($curl);
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example:
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
The method contactAlertmanager uses an else expression. Else is never necessary and you can simplify the code to work without else. Open
Open
} else {
$alertmanager_status = 'startsAt';
}
- Read upRead up
- Exclude checks
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
}
}
}