TianLiangZhou/surf

View on GitHub

Showing 27 of 27 total issues

Connection has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Connection
{

    /**
     * @var null|PDO
Severity: Minor
Found in src/Surf/Database/Connection.php - About 2 hrs to fix

    Function booted has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function booted()
        {
            $config = $this->getConfig();
    
            $globalConfig = $this->container->get('server.config');
    Severity: Minor
    Found in src/Surf/Pool/PoolManager.php - About 2 hrs 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 getControllerResponse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getControllerResponse(array $attributes, Request $request, Cookies $cookies)
        {
            if (is_callable($attributes['_controller'])) {
                $callback = $attributes['_controller'];
            } else {
    Severity: Minor
    Found in src/Surf/Server/Http/HttpKernel.php - About 2 hrs 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

    Server has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class Server
    {
        /**
         * @var null|SwooleServer
         */
    Severity: Minor
    Found in src/Surf/Server/Server.php - About 2 hrs to fix

      Method onKernelRequest has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function onKernelRequest(GetResponseEvent $event)
          {
              $request = $event->getRequest();
              $pathInfo = $request->server['path_info'];
              if (false !== $pos = strpos($pathInfo, '?')) {
      Severity: Minor
      Found in src/Surf/Listeners/RouterListener.php - About 2 hrs to fix

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

            public function message(SwooleWebSocketServer $server, Frame $frame)
            {
                if (empty($frame->data)) {
                    return $server->push($frame->fd, json_encode([
                        'code' => 500, 'message' => 'data parse failed', 'body' => []
        Severity: Minor
        Found in src/Surf/Server/WebSocket/WebSocketServer.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 handle has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function handle(int $fd, string $data, int $workerId = 0)
            {
                $this->protocol->unpack($fd, $data);
                if ($this->protocol->finish($fd)) {
                    $protocol = $this->protocol->protocol($fd);
        Severity: Minor
        Found in src/Surf/Server/Tcp/TcpServer.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 pop has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function pop(string $name)
            {
                if (!isset($this->pool[$name])) {
                    throw new NotFoundPoolException("Pool not found name to '$name'");
                }
        Severity: Minor
        Found in src/Surf/Pool/PoolManager.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 makeUnpack has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function makeUnpack(int $fd, string $package)
            {
                if (!$this->isUnpack($fd)) {
                    $this->package['is_unpack'][$fd] = true;
                    $unPackage = unpack($this->unpackFormat, $package);
        Severity: Minor
        Found in src/Surf/Server/Tcp/Protocol.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 getControllerResponse has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getControllerResponse(array $attributes, Request $request, Cookies $cookies)
            {
                if (is_callable($attributes['_controller'])) {
                    $callback = $attributes['_controller'];
                } else {
        Severity: Minor
        Found in src/Surf/Server/Http/HttpKernel.php - About 1 hr to fix

          Method message has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function message(SwooleWebSocketServer $server, Frame $frame)
              {
                  if (empty($frame->data)) {
                      return $server->push($frame->fd, json_encode([
                          'code' => 500, 'message' => 'data parse failed', 'body' => []
          Severity: Minor
          Found in src/Surf/Server/WebSocket/WebSocketServer.php - About 1 hr to fix

            Function onWorkerStart has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public function onWorkerStart(\Swoole\Server $server, int $workerId)
                {
                    if ($workerId === 0) {
                        /**
                         * @var $pool PoolManager|null
            Severity: Minor
            Found in src/Surf/Server/Server.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 handle has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function handle(int $fd, string $data, int $workerId = 0)
                {
                    $this->protocol->unpack($fd, $data);
                    if ($this->protocol->finish($fd)) {
                        $protocol = $this->protocol->protocol($fd);
            Severity: Minor
            Found in src/Surf/Server/Tcp/TcpServer.php - About 1 hr to fix

              Method factory has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function factory($poolName)
                  {
                      list($namespace, $name) = explode('.', $poolName);
                      $connection = null;
                      if (in_array($namespace, ['database', 'cache'])) {
              Severity: Minor
              Found in src/Surf/Pool/PoolManager.php - About 1 hr to fix

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

                    public function onKernelRequest(GetResponseEvent $event)
                    {
                        $request = $event->getRequest();
                        $pathInfo = $request->server['path_info'];
                        if (false !== $pos = strpos($pathInfo, '?')) {
                Severity: Minor
                Found in src/Surf/Listeners/RouterListener.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 register has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function register(Container $pimple)
                    {
                        // TODO: Implement register() method.
                        $pimple['session'] = $pimple->protect(function ($pimple, $sessionId = null) {
                
                
                Severity: Minor
                Found in src/Surf/Provider/SessionServiceProvider.php - About 1 hr to fix

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

                      public function execute(): bool
                      {
                          $content = $this->content;
                          if (is_array($this->content)) {
                              $from = $this->content['from'] ?? [];
                  Severity: Minor
                  Found in src/Surf/Task/PushTaskHandle.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 tickCallback has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function tickCallback()
                      {
                          $count = count($this->pool);
                          if ($count < 1) {
                              return ;
                  Severity: Minor
                  Found in src/Surf/Pool/PoolManager.php - About 45 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

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

                          string $driver,
                          callable $pdo,
                          string $database,
                          array $config,
                          string $prefix = '',
                  Severity: Minor
                  Found in src/Surf/Database/ConnectionFactory.php - About 45 mins to fix

                    Function onFinish has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function onFinish(SwooleServer $server, int $taskId, $data)
                        {
                            if (is_bool($data) && $data == true) {
                                if ($this->container->has('redis')) {
                                    /**
                    Severity: Minor
                    Found in src/Surf/Server/Server.php - About 45 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