src/Plugin/PluginTrait.php
Function methodMatch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function methodMatch(Message $message)
{
foreach ($this->getMethodMatchers() as $methodMatcher) {
/** @var MethodMatcher $methodMatcher */
if ($matches = $methodMatcher->matches($message)) {
- Read upRead up
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 assigning values to variables in if clauses and the like (line '89', column '17'). Open
Open
protected function methodMatch(Message $message)
{
foreach ($this->getMethodMatchers() as $methodMatcher) {
/** @var MethodMatcher $methodMatcher */
if ($matches = $methodMatcher->matches($message)) {
- Read upRead up
- Exclude checks
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
Possibly zero references to use statement for classlike/namespace Exception
(\Exception)
Open
Open
use Exception;
- Exclude checks
Argument #1 of this call to \preg_match
is typically a literal or constant but isn't, but argument #2 (which is typically a variable) is a literal or constant. The arguments may be in the wrong order. Open
Open
preg_match($pattern, '');
- Exclude checks
Blank line found at end of control structure Open
Open
- Exclude checks
Blank line found at start of control structure Open
Open
try {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
$params['patterns'] = array_map(function($pattern) use ($search, $replace) {
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
Open
$this->pluginMatcher = new PluginMatcher($pluginId, $this->getIsBot(), $this->getChannels(), $this->getUsers(), $this->getLog());
- Exclude checks
Expected 1 newline at end of file; 0 found Open
Open
}
- Exclude checks