nopolabs/yabot

View on GitHub

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)
Severity: Minor
Found in src/Plugin/PluginMatcher.php by phpcodesniffer

The closing parenthesis of a multi-line function declaration must be on a new line
Open

        Channel $channel)
Severity: Minor
Found in src/Message/Message.php by phpcodesniffer

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {
Severity: Minor
Found in src/Plugin/PluginMatcher.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

            $params['patterns'] = array_map(function($pattern) use ($search, $replace) {
Severity: Minor
Found in src/Plugin/PluginTrait.php by phpcodesniffer

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

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

There must be one blank line after the namespace declaration
Open

namespace Nopolabs\Yabot\Slack;
Severity: Minor
Found in src/Slack/Channels.php by phpcodesniffer

The closing parenthesis of a multi-line function declaration must be on a new line
Open

        LoggerInterface $log = null)
Severity: Minor
Found in src/Slack/Client.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

            function(array $plugins, string $pluginId) {
Severity: Minor
Found in src/YabotContainer.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

        $this->realTimeClient->on($event, function(Payload $payload) use ($onEvent) {
Severity: Minor
Found in src/Slack/Client.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

            function(string $pluginId, PluginInterface $plugin) {
Severity: Minor
Found in src/YabotContainer.php by phpcodesniffer

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

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

Avoid too many return statements within this method.
Open

        return $this->matchPatterns($message);
Severity: Major
Found in src/Helpers/MatcherTrait.php - About 30 mins to fix

    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'");
    Severity: Minor
    Found in src/Plugin/PluginManager.php - About 25 mins to fix

    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 = [];
    Severity: Minor
    Found in src/Plugin/PluginManager.php - About 25 mins to fix

    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)) {
    Severity: Minor
    Found in src/Plugin/PluginTrait.php - About 25 mins to fix

    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');
    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 '136', column '13').
    Open

        public function formatUser(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 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)) {
    Severity: Minor
    Found in src/Plugin/PluginTrait.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 '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'");
    Severity: Minor
    Found in src/Plugin/PluginManager.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 '220', column '13').
    Open

        protected function startConnectionMonitor()
        {
            if ($interval = $this->get('connection_monitor.interval')) {
    
                $this->getLog()->info("Monitoring websocket connection every $interval seconds.");
    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

    Severity
    Category
    Status
    Source
    Language