yiicod/yii2-socketio

View on GitHub

Showing 6 of 6 total issues

Function predis has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function predis()
    {
        $pubSubLoop = function () {
            $client = Broadcast::getDriver()->getConnection(true);

Severity: Minor
Found in commands/CommandTrait.php - About 1 hr 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

Method predis has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function predis()
    {
        $pubSubLoop = function () {
            $client = Broadcast::getDriver()->getConnection(true);

Severity: Minor
Found in commands/CommandTrait.php - About 1 hr to fix

    Function on has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        on(channel, data) {
            let nsp = this.getIoNsp(channel);
            let nspio = this.io.of('/' + nsp);
    
            nspio.on('connection', (socket) => {
    Severity: Minor
    Found in server/bundles/redis-io.js - About 1 hr to fix

      Function getList has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getList(): array
          {
              if (empty(static::$list)) {
                  foreach ($this->namespaces as $key => $namespace) {
                      $alias = Yii::getAlias('@' . str_replace('\\', '/', trim($namespace, '\\')));
      Severity: Minor
      Found in EventManager.php - About 1 hr 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

      Method emit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function emit(string $event, array $data)
          {
              $eventClassName = self::getManager()->getList()[$event] ?? null;
              try {
                  if (null === $eventClassName) {
      Severity: Minor
      Found in Broadcast.php - About 1 hr to fix

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

            isDdos(name) {
                let data = (this.socket.accessIo || {})[name] || {};
                
                if (this.getRequestLimit() <= 0) {
                    return false;
        Severity: Minor
        Found in server/bundles/access-io.js - 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