PSchwisow/phergie-irc-plugin-react-karma

View on GitHub

Showing 8 of 8 total issues

File Plugin.php has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Phergie plugin for handling requests to increment or decrement counters on specified terms (https://github.com/PSchwisow/phergie-irc-plugin-react-karma)
 *
 * @link https://github.com/PSchwisow/phergie-irc-plugin-react-karma for the canonical source repository
Severity: Minor
Found in src/Plugin.php - About 3 hrs to fix

    Method compareKarma has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function compareKarma($term0, $term1, $method, UserEvent $event, Queue $queue)
        {
            $nick = $event->getNick();
            $canonicalTerm0 = $this->getCanonicalTerm($term0, $nick);
            $canonicalTerm1 = $this->getCanonicalTerm($term1, $nick);
    Severity: Minor
    Found in src/Plugin.php - About 1 hr to fix

      Method handleKarmaCommand has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function handleKarmaCommand(CommandEvent $event, Queue $queue)
          {
              $params = $event->getCustomParams();
              if (count($params) < 1) {
                  $this->handleKarmaHelp($event, $queue);
      Severity: Minor
      Found in src/Plugin.php - About 1 hr to fix

        Method handleIrcReceived has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function handleIrcReceived(UserEvent $event, Queue $queue)
            {
                $params = $event->getParams();
                $message = $params['text'];
                $termPattern = '\S+?|\([^<>]+?\)+';
        Severity: Minor
        Found in src/Plugin.php - About 1 hr to fix

          Method modifyKarma has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function modifyKarma($term, $action, UserEvent $event, Queue $queue)
              {
                  $nick = $event->getNick();
                  $canonicalTerm = $this->getCanonicalTerm($term, $nick);
                  if ($canonicalTerm == strtolower($nick)) {
          Severity: Minor
          Found in src/Plugin.php - About 1 hr to fix

            Method setLoop has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function setLoop(LoopInterface $loop)
                {
                    parent::setLoop($loop);
            
                    \React\Promise\Timer\timeout(
            Severity: Minor
            Found in src/Plugin.php - About 1 hr to fix

              Method compareKarma has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  protected function compareKarma($term0, $term1, $method, UserEvent $event, Queue $queue)
              Severity: Minor
              Found in src/Plugin.php - About 35 mins to fix

                Function setAdapter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function setAdapter($adapter)
                    {
                        if (is_string($adapter)) {
                            if (class_exists($adapter)) {
                                $class = $adapter;
                Severity: Minor
                Found in src/ChildProcess.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

                Severity
                Category
                Status
                Source
                Language