koraktor/steam-condenser-php

View on GitHub
lib/SteamCondenser/Servers/GameServer.php

Summary

Maintainability
C
1 day
Test Coverage

Function __toString has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function __toString() {
        $returnString = '';

        $returnString .= "Ping: {$this->ping}\n";
        $returnString .= "Challenge number: {$this->challengeNumber}\n";
Severity: Minor
Found in lib/SteamCondenser/Servers/GameServer.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 handleResponseForRequest has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handleResponseForRequest($requestType, $repeatOnFailure = true) {
        switch($requestType) {
            case self::REQUEST_CHALLENGE:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2CCHALLENGEPacket';
                $requestPacket    = new A2SPLAYERPacket();
Severity: Minor
Found in lib/SteamCondenser/Servers/GameServer.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 handleResponseForRequest has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function handleResponseForRequest($requestType, $repeatOnFailure = true) {
        switch($requestType) {
            case self::REQUEST_CHALLENGE:
                $expectedResponse = '\SteamCondenser\Servers\Packets\S2CCHALLENGEPacket';
                $requestPacket    = new A2SPLAYERPacket();
Severity: Minor
Found in lib/SteamCondenser/Servers/GameServer.php - About 1 hr to fix

    Method __toString has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __toString() {
            $returnString = '';
    
            $returnString .= "Ping: {$this->ping}\n";
            $returnString .= "Challenge number: {$this->challengeNumber}\n";
    Severity: Minor
    Found in lib/SteamCondenser/Servers/GameServer.php - About 1 hr to fix

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

          protected function splitPlayerStatus($attributes, $playerStatus) {
              if($attributes[0] != 'userid') {
                  $playerStatus = preg_replace('/^\d+ +/', '', $playerStatus);
              }
      
      
      Severity: Minor
      Found in lib/SteamCondenser/Servers/GameServer.php - About 1 hr to fix

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

            public function updatePlayers($rconPassword = null) {
                $this->handleResponseForRequest(self::REQUEST_PLAYER);
        
                if(!$this->rconAuthenticated) {
                    if($rconPassword == null) {
        Severity: Minor
        Found in lib/SteamCondenser/Servers/GameServer.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 getPlayerStatusAttributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function getPlayerStatusAttributes($statusHeader) {
                $statusAttributes = [];
                foreach(preg_split("/\s+/", $statusHeader) as $attribute) {
                    if($attribute == 'connected') {
                        $statusAttributes[] = 'time';
        Severity: Minor
        Found in lib/SteamCondenser/Servers/GameServer.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

        There are no issues that match your filters.

        Category
        Status