nopolabs/yabot

View on GitHub

Showing 285 of 286 total issues

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

    public function getUser(array $data)
    {
        if ($userId = $this->getUserId($data)) {
            return $this->getUserById($userId);
        }
Severity: Minor
Found in src/Message/MessageFactory.php by phpmd

IfStatementAssignment

Since: 2.7.0

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

Example

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

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

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

    public function status(): string
    {
        if ($file = $this->yabot->getMessageLog()) {
            return "logging messages in $file";
        }
Severity: Minor
Found in src/Plugin/MessageLogPlugin.php by phpmd

IfStatementAssignment

Since: 2.7.0

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

Example

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

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

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

    public function formatChannel(string $entity, $readable = null) : string
    {
        if ($readable) {
            return "#$readable";
        }
Severity: Minor
Found in src/Message/MessageFactory.php by phpmd

IfStatementAssignment

Since: 2.7.0

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

Example

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

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

Avoid using static access to class '\GuzzleHttp\Middleware' in method 'createHandlerStack'.
Open

        $stack->push(Middleware::redirect(), 'allow_redirects');
Severity: Minor
Found in src/Guzzle/GuzzleFactory.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

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

    protected function notify(string $message)
    {
        if ($user = $this->get('notify.user')) {
            $this->getSlack()->directMessage($message, $user);
        }
Severity: Minor
Found in src/Yabot.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 logRejection uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $message = $reason;
        }
Severity: Minor
Found in src/Guzzle/Guzzle.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 using static access to class '\GuzzleHttp\Middleware' in method 'createHandlerStack'.
Open

        $stack->push(Middleware::cookies(), 'cookies');
Severity: Minor
Found in src/Guzzle/GuzzleFactory.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid unused parameters such as '$payload'.
Open

    public function onTeamJoin(Payload $payload)
Severity: Minor
Found in src/Yabot.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

Only one argument is allowed per line in a multi-line function call
Open

            array_keys($plugins), $plugins
Severity: Minor
Found in src/YabotContainer.php by phpcodesniffer

Line exceeds 120 characters; contains 137 characters
Open

        $this->pluginMatcher = new PluginMatcher($pluginId, $this->getIsBot(), $this->getChannels(), $this->getUsers(), $this->getLog());
Severity: Minor
Found in src/Plugin/PluginTrait.php by phpcodesniffer

Opening brace must be the last content on the line
Open

        $onRejected = $onRejected ?? function($reason) { $this->logRejection($reason); };
Severity: Minor
Found in src/Guzzle/Guzzle.php by phpcodesniffer

Expected 1 newline at end of file; 0 found
Open

}
Severity: Minor
Found in src/Helpers/SlackTrait.php by phpcodesniffer

Expected 1 newline at end of file; 0 found
Open

}
Severity: Minor
Found in src/Plugin/StatusPlugin.php by phpcodesniffer

Expected 1 newline at end of file; 0 found
Open

}
Severity: Minor
Found in src/Helpers/MatcherTrait.php by phpcodesniffer

Expected 1 newline at end of file; 0 found
Open

}
Severity: Minor
Found in src/Plugin/MethodMatcher.php by phpcodesniffer

Expected 1 newline at end of file; 0 found
Open

}

Expected 1 newline at end of file; 0 found
Open

}
Severity: Minor
Found in src/Guzzle/Guzzle.php by phpcodesniffer

Expected 1 newline at end of file; 0 found
Open

}
Severity: Minor
Found in src/Message/Message.php by phpcodesniffer

Closing brace must be on a line by itself
Open

        $onRejected = $onRejected ?? function($reason) { $this->logRejection($reason); };
Severity: Minor
Found in src/Guzzle/Guzzle.php by phpcodesniffer

Opening brace should be on a new line
Open

    public static function handler($severity, $message, $file, $line) {
Severity
Category
Status
Source
Language