detain/cisco_parser

View on GitHub

Showing 18 of 18 total issues

File CiscoLoader.php has 599 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Detain\CiscoParser;

/**
Severity: Major
Found in src/CiscoLoader.php - About 1 day to fix

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

                } elseif (mb_strpos($entry, 'packets input') !== false) {
                    $entry = explode(',', $entry);
                    $entry[0] = trim($entry[0]);
                    $entry[0] = explode(' ', $entry[0]);
                    $result['in_packet'] = $entry[0][0];
    Severity: Major
    Found in src/CiscoLoader.php and 2 other locations - About 1 day to fix
    src/CiscoLoader.php on lines 461..474
    src/CiscoLoader.php on lines 517..530

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

    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 3 locations. Consider refactoring.
    Open

                } elseif (mb_strpos($entry, 'watchdog') !== false) {
                    $entry = explode(',', $entry);
                    $entry[0] = trim($entry[0]);
                    $entry[0] = explode(' ', $entry[0]);
                    $result['watchdog'] = $entry[0][0];
    Severity: Major
    Found in src/CiscoLoader.php and 2 other locations - About 1 day to fix
    src/CiscoLoader.php on lines 415..428
    src/CiscoLoader.php on lines 517..530

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

    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 3 locations. Consider refactoring.
    Open

                } elseif (mb_strpos($entry, 'lost carrier') !== false) {
                    $entry = explode(',', $entry);
                    $entry[0] = trim($entry[0]);
                    $entry[0] = explode(' ', $entry[0]);
                    $result['lost_carrier'] = $entry[0][0];
    Severity: Major
    Found in src/CiscoLoader.php and 2 other locations - About 1 day to fix
    src/CiscoLoader.php on lines 415..428
    src/CiscoLoader.php on lines 461..474

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

    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 3 locations. Consider refactoring.
    Open

                } elseif (mb_strpos($entry, 'MTU') !== false) {
                    $entry = explode(',', $entry);
                    $entry[0] = trim($entry[0]);
                    $entry[0] = explode(' ', $entry[0]);
                    $result['mtu'] = $entry[0][1];
    Severity: Major
    Found in src/CiscoLoader.php and 2 other locations - About 7 hrs to fix
    src/CiscoLoader.php on lines 478..489
    src/CiscoLoader.php on lines 506..517

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

    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 3 locations. Consider refactoring.
    Open

                } elseif (mb_strpos($entry, 'packets output') !== false) {
                    $entry = explode(',', $entry);
                    $entry[0] = trim($entry[0]);
                    $entry[0] = explode(' ', $entry[0]);
                    $result['out_packet'] = $entry[0][0];
    Severity: Major
    Found in src/CiscoLoader.php and 2 other locations - About 7 hrs to fix
    src/CiscoLoader.php on lines 378..389
    src/CiscoLoader.php on lines 506..517

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

    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 3 locations. Consider refactoring.
    Open

                } elseif (mb_strpos($entry, 'babbles') !== false) {
                    $entry = explode(',', $entry);
                    $entry[0] = trim($entry[0]);
                    $entry[0] = explode(' ', $entry[0]);
                    $result['babble'] = $entry[0][0];
    Severity: Major
    Found in src/CiscoLoader.php and 2 other locations - About 7 hrs to fix
    src/CiscoLoader.php on lines 378..389
    src/CiscoLoader.php on lines 478..489

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

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

        public function show_int($int)
        {
            $result = [];
            $this->exec('show int '.$int);
            $this->_data = explode("\r\n", $this->_data);
    Severity: Major
    Found in src/CiscoLoader.php - About 7 hrs to fix

      Function show_int has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          public function show_int($int)
          {
              $result = [];
              $this->exec('show int '.$int);
              $this->_data = explode("\r\n", $this->_data);
      Severity: Minor
      Found in src/CiscoLoader.php - About 6 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

                  } elseif (mb_strpos($entry, 'output rate') !== false) {
                      $entry = explode(',', $entry);
                      $result['out_rate'] = mb_substr($entry[0], mb_strpos($entry[0], 'rate') + 5, mb_strrpos($entry[0], ' ') - (mb_strpos($entry[0], 'rate') + 5));
                      $entry = trim($entry[1]);
                      $entry = explode(' ', $entry);
      Severity: Major
      Found in src/CiscoLoader.php and 1 other location - About 4 hrs to fix
      src/CiscoLoader.php on lines 403..409

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

      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

                  } elseif (mb_strpos($entry, 'input rate') !== false) {
                      $entry = explode(',', $entry);
                      $result['in_rate'] = mb_substr($entry[0], mb_strpos($entry[0], 'rate') + 5, mb_strrpos($entry[0], ' ') - (mb_strpos($entry[0], 'rate') + 5));
                      $entry = trim($entry[1]);
                      $entry = explode(' ', $entry);
      Severity: Major
      Found in src/CiscoLoader.php and 1 other location - About 4 hrs to fix
      src/CiscoLoader.php on lines 409..415

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

      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 parse_cisco_children has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parse_cisco_children($lines, $x = 0, $depth = 0)
          {
              //global $x;
              $data = [];
              $last_command = false;
      Severity: Minor
      Found in src/CiscoParser.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

      CiscoLoader has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class CiscoLoader
      {
          /**
           * @var bool
           */
      Severity: Minor
      Found in src/CiscoLoader.php - About 2 hrs to fix

        Method parse_cisco_children has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function parse_cisco_children($lines, $x = 0, $depth = 0)
            {
                //global $x;
                $data = [];
                $last_command = false;
        Severity: Minor
        Found in src/CiscoParser.php - About 1 hr to fix

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

              public function show_int_status()
              {
                  $result = [];
                  $this->exec('show int status');
                  $this->_data = explode("\r\n", $this->_data);
          Severity: Minor
          Found in src/CiscoLoader.php - About 1 hr to fix

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

                public function read($pattern = '', $regex = false)
                {
                    //usleep(1000);
                    $this->_response = '';
                    $match = $pattern;
            Severity: Minor
            Found in src/CiscoLoader.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 arp_table has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function arp_table()
                {
                    $result = [];
                    $this->exec('show arp | exc Incomplete');
                    $this->_data = explode("\r\n", $this->_data);
            Severity: Minor
            Found in src/CiscoLoader.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 configure has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function configure($config)
                {
                    // USE AT OWN RISK: This function will apply configuration statements to a device.
                    // Enabled Only
                    if (mb_strpos($this->_prompt, '#') === false) {
            Severity: Minor
            Found in src/CiscoLoader.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