EvilFreelancer/routeros-api-php

View on GitHub

Showing 21 of 21 total issues

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

<?php

namespace RouterOS;

use DivineOmega\SSHConnection\SSHConnection;
Severity: Minor
Found in src/Client.php - About 2 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

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

    <?php
    require_once __DIR__ . '/../vendor/autoload.php';
    
    error_reporting(E_ALL);
    
    
    Severity: Major
    Found in examples/interface_print.php and 1 other location - About 2 hrs to fix
    examples/system_package_print.php on lines 1..28

    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 122.

    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
    require_once __DIR__ . '/../vendor/autoload.php';
    
    error_reporting(E_ALL);
    
    
    Severity: Major
    Found in examples/system_package_print.php and 1 other location - About 2 hrs to fix
    examples/interface_print.php on lines 1..28

    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 122.

    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

    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

          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

          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 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

            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

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

              $vlans = [
                  100 => [3, 4, 5, 6, 7, 8],
                  200 => [9, 10, 11, 12, 13, 14, 15, 16],
                  300 => [17, 18, 19, 20, 21, 22, 23, 24],
              ];
              Severity: Minor
              Found in examples/vlans_bridge_v2.php and 2 other locations - About 35 mins to fix
              examples/vlans_bridge.php on lines 26..30
              examples/vlans_bridge_v3.php on lines 21..25

              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 92.

              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

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

              $vlans = [
                  100 => [3, 4, 5, 6, 7, 8],
                  200 => [9, 10, 11, 12, 13, 14, 15, 16],
                  300 => [17, 18, 19, 20, 21, 22, 23, 24],
              ];
              Severity: Minor
              Found in examples/vlans_bridge_v3.php and 2 other locations - About 35 mins to fix
              examples/vlans_bridge.php on lines 26..30
              examples/vlans_bridge_v2.php on lines 22..26

              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 92.

              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

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

              $vlans = [
                  100 => [3, 4, 5, 6, 7, 8],
                  200 => [9, 10, 11, 12, 13, 14, 15, 16],
                  300 => [17, 18, 19, 20, 21, 22, 23, 24],
              ];
              Severity: Minor
              Found in examples/vlans_bridge.php and 2 other locations - About 35 mins to fix
              examples/vlans_bridge_v2.php on lines 22..26
              examples/vlans_bridge_v3.php on lines 21..25

              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 92.

              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 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

              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 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

              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
                Severity
                Category
                Status
                Source
                Language