EvilFreelancer/routeros-api-php

View on GitHub

Showing 17 of 22 total issues

File Client.php has 291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace RouterOS;

use DivineOmega\SSHConnection\SSHConnection;
Severity: Minor
Found in src/Client.php - About 3 hrs to fix

    Function readRAW has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        public function readRAW(array $options = [])
        {
            // By default response is empty
            $response = [];
            // We have to wait a !done or !fatal
    Severity: Minor
    Found in src/Client.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 decodeLength has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function decodeLength(StreamInterface $stream): int
        {
            // Read first byte
            $firstByte = ord($stream->read(1));
    
    
    Severity: Minor
    Found in src/APILengthCoDec.php - About 1 hr to fix

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

          public function parseResponse(array $response): array
          {
              $result = [];
              $i      = -1;
              $lines  = count($response);
      Severity: Minor
      Found in src/Client.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 readRAW has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function readRAW(array $options = [])
          {
              // By default response is empty
              $response = [];
              // We have to wait a !done or !fatal
      Severity: Minor
      Found in src/Client.php - About 1 hr to fix

        Method openSocket has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function openSocket(): void
            {
                $options = [];
        
                // Pass SSL options
        Severity: Minor
        Found in src/SocketTrait.php - About 1 hr to fix

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

              public function export(string $arguments = null): string
              {
                  // Set params
                  $sshHost       = $this->config('host');
                  $sshPort       = $this->config('ssh_port');
          Severity: Minor
          Found in src/Client.php - About 1 hr to fix

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

                public function query($endpoint, array $where = null, string $operations = null, string $tag = null): ClientInterface
                {
                    // If endpoint is string then build Query object
                    $query = ($endpoint instanceof Query)
                        ? $endpoint
            Severity: Minor
            Found in src/Client.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

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

                public function qr($endpoint, array $where = null, string $operations = null, string $tag = null, bool $parse = true, array $options = []): array
            Severity: Minor
            Found in src/ShortsTrait.php - About 45 mins to fix

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

                  private function world(string $key, $operator = null, $value = null): QueryInterface
                  {
                      if (null !== $operator && null === $value) {
              
                          // Client may set only two parameters, that mean what $operator is $value
              Severity: Minor
              Found in src/Query.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 qri has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function qri($endpoint, array $where = null, string $operations = null, string $tag = null, array $options = []): ResponseIterator
              Severity: Minor
              Found in src/ShortsTrait.php - About 35 mins to fix

                Function decodeLength has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function decodeLength(StreamInterface $stream): int
                    {
                        // Read first byte
                        $firstByte = ord($stream->read(1));
                
                
                Severity: Minor
                Found in src/APILengthCoDec.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 export has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function export(string $arguments = null): string
                    {
                        // Set params
                        $sshHost       = $this->config('host');
                        $sshPort       = $this->config('ssh_port');
                Severity: Minor
                Found in src/Client.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 connect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function connect(): bool
                    {
                        // By default we not connected
                        $connected = false;
                
                
                Severity: Minor
                Found in src/Client.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 rosario has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function rosario(array $raw): array
                    {
                        // This RAW should't be an error
                        $positions = array_keys($raw, '!re');
                        $count     = count($raw);
                Severity: Minor
                Found in src/Client.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

                Avoid too many return statements within this method.
                Open

                        return BinaryStringHelper::IntegerToNBOBinaryString(0xF000000000 + $length);
                Severity: Major
                Found in src/APILengthCoDec.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $result;
                  Severity: Major
                  Found in src/APILengthCoDec.php - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language