sfcod/socketio

View on GitHub

Showing 15 of 19 total issues

Function emit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    emit(channel, data) {
        let event = this.parseEvent(data),
            room = event.data.room,
            nsp = '';

Severity: Minor
Found in Server/bundles/redis-io.js - 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

Function parseDsn has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function parseDsn($dsn)
    {
        $dsn = str_replace('redis://', '', $dsn); // remove "redis://"
        if (false !== $pos = strrpos($dsn, '@')) {
            // parse password
Severity: Minor
Found in Service/RedisDriver.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

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

    public function predis(SymfonyStyle $io)
    {
        $pubSubLoop = function () use ($io) {
            /** @var \Predis\Client $client */
            $client = $this->redisDriver->getClient(true);
Severity: Minor
Found in Service/Worker.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

Function on has 39 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

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

        public function predis(SymfonyStyle $io)
        {
            $pubSubLoop = function () use ($io) {
                /** @var \Predis\Client $client */
                $client = $this->redisDriver->getClient(true);
    Severity: Minor
    Found in Service/Worker.php - About 1 hr to fix

      Function emit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          emit(channel, data) {
              let event = this.parseEvent(data),
                  room = event.data.room,
                  nsp = '';
      
      
      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
            {
                //@todo remove this, move to extension using tags
                if (empty(self::$list)) {
                    foreach ($this->namespaces as $key => $namespace) {
        Severity: Minor
        Found in Service/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 parseDsn has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function parseDsn($dsn)
            {
                $dsn = str_replace('redis://', '', $dsn); // remove "redis://"
                if (false !== $pos = strrpos($dsn, '@')) {
                    // parse password
        Severity: Minor
        Found in Service/RedisDriver.php - About 1 hr to fix

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

              public function emit(string $event, array $data)
              {
                  $this->logger->info(json_encode(['type' => 'emit', 'name' => $event, 'data' => $data]));
          
                  try {
          Severity: Minor
          Found in Service/Broadcast.php - About 1 hr to fix

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

                public function process(string $handler, array $data)
                {
                    try {
                        /** @var EventInterface|EventSubscriberInterface|EventPolicyInterface $eventHandler */
                        $eventHandler = $this->manager->resolve($handler); //container->get(sprintf('socketio.%s', $handler));
            Severity: Minor
            Found in Service/Broadcast.php - About 1 hr to fix

              Function process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function process(string $handler, array $data)
                  {
                      try {
                          /** @var EventInterface|EventSubscriberInterface|EventPolicyInterface $eventHandler */
                          $eventHandler = $this->manager->resolve($handler); //container->get(sprintf('socketio.%s', $handler));
              Severity: Minor
              Found in Service/Broadcast.php - About 55 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 createBroadcast has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function createBroadcast(array $config, ContainerBuilder $container)
                  {
                      $broadcast = new Definition(Broadcast::class);
                      $broadcast->setArguments([
                          new Reference(RedisDriver::class),
              Severity: Minor
              Found in DependencyInjection/SocketIoExtension.php - About 35 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 exports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = (socket, next) => {
                  const token = socket.handshake.query[`${process.env.SOCKET_IO_AUTH_TOKEN_NAME || 'token'}`];
                  const callback = (err, decoded) => {
                      if (err) {
                          logger.info("auth", err);
              Severity: Minor
              Found in Server/bundles/auth.js - About 35 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 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

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

                  public function emit(string $event, array $data)
                  {
                      $this->logger->info(json_encode(['type' => 'emit', 'name' => $event, 'data' => $data]));
              
                      try {
              Severity: Minor
              Found in Service/Broadcast.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