Showing 285 of 286 total issues
The closing parenthesis of a multi-line function declaration must be on a new line Open
LoggerInterface $logger = null)
- Exclude checks
The closing parenthesis of a multi-line function declaration must be on a new line Open
Channel $channel)
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
$params['patterns'] = array_map(function($pattern) use ($search, $replace) {
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
There must be one blank line after the namespace declaration Open
namespace Nopolabs\Yabot\Slack;
- Exclude checks
The closing parenthesis of a multi-line function declaration must be on a new line Open
LoggerInterface $log = null)
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
function(array $plugins, string $pluginId) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
$this->realTimeClient->on($event, function(Payload $payload) use ($onEvent) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
function(string $pluginId, PluginInterface $plugin) {
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Avoid too many return
statements within this method. Open
return $this->matchPatterns($message);
Function dispatchToPrefixes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function dispatchToPrefixes(array $prefixMap, Message $message, string $text)
{
foreach ($prefixMap as $prefix => $plugins) {
if ($matches = $this->matchesPrefix($prefix, $text)) {
$this->debug("Dispatching prefix '$prefix'");
- 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
Function updatePrefixes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function updatePrefixes($authedUsername)
{
$updatedPriorityMap = [];
foreach ($this->getPriorityMap() as $priority => $prefixMap) {
$updatedPrefixMap = [];
- 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
Function methodMatch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. 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 using static access to class '\GuzzleHttp\Middleware' in method 'createHandlerStack'. Open
$stack->push(Middleware::prepareBody(), 'prepare_body');
- Read upRead up
- Exclude checks
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 '136', column '13'). Open
public function formatUser(string $entity, $readable = null) : string
{
if ($readable) {
return "@$readable";
}
- 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
Avoid assigning values to variables in if clauses and the like (line '89', column '17'). 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
Avoid assigning values to variables in if clauses and the like (line '124', column '17'). Open
protected function dispatchToPrefixes(array $prefixMap, Message $message, string $text)
{
foreach ($prefixMap as $prefix => $plugins) {
if ($matches = $this->matchesPrefix($prefix, $text)) {
$this->debug("Dispatching prefix '$prefix'");
- 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
Avoid assigning values to variables in if clauses and the like (line '220', column '13'). Open
protected function startConnectionMonitor()
{
if ($interval = $this->get('connection_monitor.interval')) {
$this->getLog()->info("Monitoring websocket connection every $interval seconds.");
- 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
// ...
}
}
}