gomoob/php-websocket-server

View on GitHub

Showing 21 of 128 total issues

Method testCreateFromArray has 109 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testCreateFromArray()
    {
        $messageParser = new MessageParser();
        
        // Test with bad keys
Severity: Major
Found in src/test/php/Gomoob/WebSocket/Request/WebSocketRequestTest.php - About 4 hrs to fix

    Method testSend has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testSend()
        {
            $webSocketClient = new WebSocketClient('ws://localhost:8080');
            
            // Backup the Textalk WebSocket client
    Severity: Major
    Found in src/test/php/Gomoob/WebSocket/Client/WebSocketClientTest.php - About 4 hrs to fix

      Method testAuthorizeSend has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function testAuthorizeSend()
          {
              // Test without metadata parameters on request
              $this->assertFalse(
                  ApplicationsAuthManager::factory()->authorizeSend(
      Severity: Major
      Found in src/test/php/Gomoob/WebSocket/Auth/ApplicationsAuthManagerTest.php - About 2 hrs to fix

        Method testAuthorizeOpen has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testAuthorizeOpen()
            {
                // Test without specifying `authorizeOpen` explicitly
                $this->assertTrue(ApplicationsAuthManager::factory()->authorizeOpen($this->createIoConnection()));
                
        Severity: Major
        Found in src/test/php/Gomoob/WebSocket/Auth/ApplicationsAuthManagerTest.php - About 2 hrs to fix

          Function findByTags has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              public function findByTags(array $tags = [])
              {
                  $objects = [];
                  
                  // If no tags are provided we return all the objects
          Severity: Minor
          Found in src/main/php/Gomoob/WebSocket/Util/TagsTree.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 testConstruct has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function testConstruct()
              {
                  $ioConnection = $this->createIoConnection();
                  $webSocketRequest = WebSocketRequest::factory('Hello World !');
          
          
          Severity: Minor
          Found in src/test/php/Gomoob/WebSocket/Auth/ApplicationsAuthManagerTest.php - About 1 hr to fix

            Method testFindByTags has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function testFindByTags()
                {
                    $object0 = new \DateTime();
                    $object1 = new \DateTime();
                    $object2 = new \DateTime();
            Severity: Minor
            Found in src/test/php/Gomoob/WebSocket/Util/TagsTreeTest.php - About 1 hr to fix

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

                  public static function createFromArray(array $jsonArray, IMessageParser $messageParser = null)
                  {
                      // Ensure the array contains only valid key names
                      foreach (array_keys($jsonArray) as $key) {
                          if (!is_string($key) || !in_array($key, ['message', 'tags', 'metadata'])) {
              Severity: Minor
              Found in src/main/php/Gomoob/WebSocket/Request/WebSocketRequest.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 testCreateFromJSON has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function testCreateFromJSON()
                  {
                      $messageParser = new MessageParser();
                      
                      // Test with an invalid JSON string
              Severity: Minor
              Found in src/test/php/Gomoob/WebSocket/Request/WebSocketRequestTest.php - About 1 hr to fix

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

                    public static function createFromArray(array $jsonArray, IMessageParser $messageParser = null)
                    {
                        // Ensure the array contains only valid key names
                        foreach (array_keys($jsonArray) as $key) {
                            if (!is_string($key) || !in_array($key, ['message', 'tags', 'metadata'])) {
                Severity: Minor
                Found in src/main/php/Gomoob/WebSocket/Request/WebSocketRequest.php - About 1 hr to fix

                  Method testDelete has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function testDelete()
                      {
                          $object0 = new \DateTime();
                          $object1 = new \DateTime();
                          $object2 = new \DateTime();
                  Severity: Minor
                  Found in src/test/php/Gomoob/WebSocket/Util/TagsTreeTest.php - About 1 hr to fix

                    Method parseYamlString has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function parseYamlString($yamlString)
                        {
                            // Parse the YAML file
                            $yamlParser = new Parser();
                    
                    
                    Severity: Minor
                    Found in src/main/php/Gomoob/WebSocket/Auth/ApplicationsAuthManager.php - About 1 hr to fix

                      Method onMessage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function onMessage(ConnectionInterface $connection, $strMessage)
                          {
                              // In development mode we log a message
                              $this->logger->debug(
                                  'Receiving message on WebSocket connection with resource id \'{resourceId}\'.',
                      Severity: Minor
                      Found in src/main/php/Gomoob/WebSocket/Server/Ratchet/RatchetApplication.php - About 1 hr to fix

                        Method testAdd has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function testAdd()
                            {
                                $tagsTree = new TagsTree();
                                
                                // Test with an invalid tag key (i.e not a string)
                        Severity: Minor
                        Found in src/test/php/Gomoob/WebSocket/Util/TagsTreeTest.php - About 1 hr to fix

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

                              public static function parse(QueryString $queryString)
                              {
                                  $tags = [];
                                  $queryStringArray = $queryString->toArray();
                                  
                          Severity: Minor
                          Found in src/main/php/Gomoob/WebSocket/Server/QueryStringTagsParser.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 delete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function delete($object)
                              {
                                  if ($this->contains($object)) {
                                      // Computes the object hash
                                      $hash = $this->objects->getHash($object);
                          Severity: Minor
                          Found in src/main/php/Gomoob/WebSocket/Util/TagsTree.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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function parse(array $arrayMessage)
                              {
                                  
                                  // Ensure the array contains only valid key names
                                  foreach (array_keys($arrayMessage) as $key) {
                          Severity: Minor
                          Found in src/main/php/Gomoob/WebSocket/Message/MessageParser.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 parseYamlString has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function parseYamlString($yamlString)
                              {
                                  // Parse the YAML file
                                  $yamlParser = new Parser();
                          
                          
                          Severity: Minor
                          Found in src/main/php/Gomoob/WebSocket/Auth/ApplicationsAuthManager.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 authorizeOpen has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function authorizeOpen(ConnectionInterface $connection)
                              {
                                  $authorized = $this->authorizeOpen;
                                  
                                  // If the default connection opening authorization mode is false then try to get specific 'key' and 'secret'
                          Severity: Minor
                          Found in src/main/php/Gomoob/WebSocket/Auth/ApplicationsAuthManager.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

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

                              protected function validateTags(array $tags)
                              {
                                  foreach ($tags as $tagName => $tagValue) {
                                      // Tag names must only be strings
                                      if (!is_string($tagName)) {
                          Severity: Minor
                          Found in src/main/php/Gomoob/WebSocket/Request/WebSocketRequest.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