koraktor/steam-condenser-php

View on GitHub

Showing 40 of 40 total issues

SteamId has 31 functions (exceeds 20 allowed). Consider refactoring.
Open

class SteamId extends XMLData {

    use Cacheable;

    /**
Severity: Minor
Found in lib/SteamCondenser/Community/SteamId.php - About 3 hrs to fix

    Function getServers has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getServers($regionCode = MasterServer::REGION_ALL , $filter = '', $force = false) {
            $failCount   = 0;
            $finished    = false;
            $portNumber  = 0;
            $hostName    = '0.0.0.0';
    Severity: Minor
    Found in lib/SteamCondenser/Servers/MasterServer.php - About 3 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    <?php
    /**
     * This code is free software; you can redistribute it and/or modify it under
     * the terms of the new BSD License.
     *
    Severity: Major
    Found in lib/SteamCondenser/Community/GameStatsDatum/Instance.php and 1 other location - About 2 hrs to fix
    lib/SteamCondenser/Community/GameAchievement/Instance.php on lines 1..68

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 132.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    <?php
    /**
     * This code is free software; you can redistribute it and/or modify it under
     * the terms of the new BSD License.
     *
    Severity: Major
    Found in lib/SteamCondenser/Community/GameAchievement/Instance.php and 1 other location - About 2 hrs to fix
    lib/SteamCondenser/Community/GameStatsDatum/Instance.php on lines 1..69

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 132.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        public function getReply() {
            $this->receivePacket(1400);
            $isCompressed = false;
    
            if($this->buffer->getLong() == -2) {
    Severity: Minor
    Found in lib/SteamCondenser/Servers/Sockets/SourceSocket.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 __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 internalFetch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function internalFetch() {
            $params = ['language' => $this->language];
            $data = WebApi::getJSONData("IEconItems_{$this->appId}", 'GetSchema', 1, $params);
    
            $this->attributes = [];
    Severity: Minor
    Found in lib/SteamCondenser/Community/GameItemSchema.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

    Method internalFetch has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function internalFetch() {
            $params = ['language' => $this->language];
            $data = WebApi::getJSONData("IEconItems_{$this->appId}", 'GetSchema', 1, $params);
    
            $this->attributes = [];
    Severity: Minor
    Found in lib/SteamCondenser/Community/GameItemSchema.php - About 1 hr to fix

      Method __construct has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct(GameInventory $inventory, $itemData) {
              $this->inventory = $inventory;
      
              $this->defindex         = $itemData->defindex;
              $this->backpackPosition = $itemData->inventory & 0xffff;
      Severity: Minor
      Found in lib/SteamCondenser/Community/GameItem.php - About 1 hr to fix

        Method getServers has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getServers($regionCode = MasterServer::REGION_ALL , $filter = '', $force = false) {
                $failCount   = 0;
                $finished    = false;
                $portNumber  = 0;
                $hostName    = '0.0.0.0';
        Severity: Minor
        Found in lib/SteamCondenser/Servers/MasterServer.php - About 1 hr to fix

          Method getReply has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getReply() {
                  $this->receivePacket(1400);
                  $isCompressed = false;
          
                  if($this->buffer->getLong() == -2) {
          Severity: Minor
          Found in lib/SteamCondenser/Servers/Sockets/SourceSocket.php - About 1 hr to fix

            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 __construct has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function __construct($data) {
                      parent::__construct(SteamPacket::S2A_INFO2_HEADER, $data);
              
                      $this->info['networkVersion'] = $this->contentData->getByte();
                      $this->info['serverName'] = $this->contentData->getString();
              Severity: Minor
              Found in lib/SteamCondenser/Servers/Packets/S2AINFO2Packet.php - About 1 hr to fix

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

                    public function __construct($data) {
                        parent::__construct(SteamPacket::S2A_INFO2_HEADER, $data);
                
                        $this->info['networkVersion'] = $this->contentData->getByte();
                        $this->info['serverName'] = $this->contentData->getString();
                Severity: Minor
                Found in lib/SteamCondenser/Servers/Packets/S2AINFO2Packet.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 connect has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function connect($ipAddress, $portNumber, $timeout) {
                        $this->ipAddress = $ipAddress;
                        $this->portNumber = $portNumber;
                
                        if($this->socketsEnabled) {
                Severity: Minor
                Found in lib/SteamCondenser/TCPSocket.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 __construct has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __construct($data) {
                        parent::__construct(SteamPacket::S2A_INFO_DETAILED_HEADER, $data);
                
                        $this->info['serverIp'] = $this->contentData->getString();
                        $this->info['serverName'] = $this->contentData->getString();
                Severity: Minor
                Found in lib/SteamCondenser/Servers/Packets/S2AINFODETAILEDPacket.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 recv has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function recv($length = 128) {
                              if($this->socketsEnabled) {
                                  $data = socket_read($this->socket, $length);
                      
                                  if ($data === false) {
                      Severity: Minor
                      Found in lib/SteamCondenser/Socket.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

                      Severity
                      Category
                      Status
                      Source
                      Language