nopolabs/yabot

View on GitHub
src/Yabot.php

Summary

Maintainability
A
45 mins
Test Coverage

Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        LoggerInterface $logger,
        LoopInterface $eventLoop,
        Client $slackClient,
        MessageFactory $messageFactory,
        PluginManager $pluginManager,
Severity: Minor
Found in src/Yabot.php - About 45 mins to fix

    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

    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

    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

    Property \Nopolabs\Yabot\Yabot->monitor has undeclared type \React\EventLoop\Timer\TimerInterface
    Open

        private $monitor;
    Severity: Minor
    Found in src/Yabot.php by phan

    Possibly zero references to use statement for classlike/namespace PluginInterface (\Nopolabs\Yabot\Plugin\PluginInterface)
    Open

    use Nopolabs\Yabot\Plugin\PluginInterface;
    Severity: Minor
    Found in src/Yabot.php by phan

    Parameter $eventLoop has undeclared type \React\EventLoop\LoopInterface
    Open

        public function __construct(
    Severity: Minor
    Found in src/Yabot.php by phan

    Parameter $logger has undeclared type \Psr\Log\LoggerInterface
    Open

        public function __construct(
    Severity: Minor
    Found in src/Yabot.php by phan

    Assigning null to property but \Nopolabs\Yabot\Yabot->messageLog is string
    Open

            $this->messageLog = null;
    Severity: Minor
    Found in src/Yabot.php by phan

    Call to method error from undeclared class \Psr\Log\LoggerInterface
    Open

            $this->getLog()->error('Reconnecting...');
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method cancelTimer from undeclared class \React\EventLoop\LoopInterface
    Open

                $this->loop->cancelTimer($this->monitor);
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method then from undeclared class \React\Promise\PromiseInterface
    Open

            $this->getSlack()->reconnect()->then(
    Severity: Critical
    Found in src/Yabot.php by phan

    Parameter $payload has undeclared type \Slack\Payload
    Open

        public function onTeamJoin(Payload $payload)
    Severity: Minor
    Found in src/Yabot.php by phan

    Assigning ?string|null to property but \Nopolabs\Yabot\Yabot->messageLog is string
    Open

            $this->messageLog = $messageLog ?? null;
    Severity: Minor
    Found in src/Yabot.php by phan

    Call to method error from undeclared class \Psr\Log\LoggerInterface
    Open

                    $this->getLog()->error('Connection failed, shutting down.');
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method error from undeclared class \Psr\Log\LoggerInterface
    Open

                $this->getLog()->error('No pong.');
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method getMessage from undeclared class \React\Promise\Timer\timeoutexception
    Open

                    $this->getLog()->error($error->getMessage());
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method error from undeclared class \Psr\Log\LoggerInterface
    Open

                    $this->getLog()->error('Connection failed, shutting down.');
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method getData from undeclared class \Slack\Payload
    Open

            $data = $payload->getData();
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method info from undeclared class \Psr\Log\LoggerInterface
    Open

                $this->getLog()->info("Monitoring websocket connection every $interval seconds.");
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method then from undeclared class \React\Promise\PromiseInterface
    Open

            $this->getSlack()->ping()
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method stop from undeclared class \React\EventLoop\LoopInterface
    Open

            $this->getLoop()->stop();
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method addPeriodicTimer from undeclared class \React\EventLoop\LoopInterface
    Open

                return $this->loop->addPeriodicTimer($interval, function () {
    Severity: Critical
    Found in src/Yabot.php by phan

    Parameter $payload has undeclared type \Slack\Payload
    Open

                    function (Payload $payload) {
    Severity: Minor
    Found in src/Yabot.php by phan

    Call to undeclared function \React\Promise\Timer\timeout()
    Open

            Timer\timeout($this->getSlack()->connect(), 30, $this->getLoop())
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method info from undeclared class \Psr\Log\LoggerInterface
    Open

            $this->getLog()->info('Connecting...');
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method error from undeclared class \Psr\Log\LoggerInterface
    Open

            $this->getLog()->error('Shutting down...');
    Severity: Critical
    Found in src/Yabot.php by phan

    Return type of startConnectionMonitor() is undeclared type \React\EventLoop\Timer\TimerInterface
    Open

        protected function startConnectionMonitor()
    Severity: Minor
    Found in src/Yabot.php by phan

    Call to method error from undeclared class \Psr\Log\LoggerInterface
    Open

                    $this->getLog()->error($error->getMessage());
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method info from undeclared class \Psr\Log\LoggerInterface
    Open

                    $this->getLog()->info('Reconnected');
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method info from undeclared class \Psr\Log\LoggerInterface
    Open

                    $this->getLog()->info('Connected.');
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method error from undeclared class \Psr\Log\LoggerInterface
    Open

                    $this->getLog()->error('Reconnect failed, shutting down.');
    Severity: Critical
    Found in src/Yabot.php by phan

    Parameter $error has undeclared type \React\Promise\Timer\timeoutexception
    Open

                ->otherwise(function (Timer\TimeoutException $error) {
    Severity: Minor
    Found in src/Yabot.php by phan

    Parameter $authedUser has undeclared type \Slack\User
    Open

            $slack->update(function(User $authedUser) {
    Severity: Minor
    Found in src/Yabot.php by phan

    Argument 1 (hour) is string but \DateTime::setTime() takes int
    Open

            $then->setTime($then->format('H'), 0, 0);
    Severity: Minor
    Found in src/Yabot.php by phan

    Call to method error from undeclared class \Psr\Log\LoggerInterface
    Open

                    $this->getLog()->error("Unknown connection_monitor.failure_strategy '$failureStrategy'");
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method run from undeclared class \React\EventLoop\LoopInterface
    Open

            $this->getLoop()->run();
    Severity: Critical
    Found in src/Yabot.php by phan

    Call to method toJson from undeclared class \Slack\Payload
    Open

                        $this->getLog()->info($payload->toJson());
    Severity: Critical
    Found in src/Yabot.php by phan

    Parameter $payload has undeclared type \Slack\Payload
    Open

        public function onMessage(Payload $payload)
    Severity: Minor
    Found in src/Yabot.php by phan

    Call to method info from undeclared class \Psr\Log\LoggerInterface
    Open

                        $this->getLog()->info($payload->toJson());
    Severity: Critical
    Found in src/Yabot.php by phan

    Expected 1 space after FUNCTION keyword; 0 found
    Open

            $slack->update(function(User $authedUser) {
    Severity: Minor
    Found in src/Yabot.php by phpcodesniffer

    Expected 1 space after FUNCTION keyword; 0 found
    Open

            $this->addTimer($delay, function() {
    Severity: Minor
    Found in src/Yabot.php by phpcodesniffer

    Expected 1 space after FUNCTION keyword; 0 found
    Open

                $this->addPeriodicTimer(3600, function() {
    Severity: Minor
    Found in src/Yabot.php by phpcodesniffer

    Blank line found at start of control structure
    Open

            if ($interval = $this->get('connection_monitor.interval')) {
    Severity: Minor
    Found in src/Yabot.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status