giansalex/peru-consult

View on GitHub

Showing 5 of 5 total issues

Function getResponsePostAndSaveCookies has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function getResponsePostAndSaveCookies(string $url, $ctx)
    {
        $fp = @fopen($url, 'r', false, $ctx);
        $length = 0;
        if (isset($http_response_header)) {
Severity: Minor
Found in src/Peru/Http/ContextClient.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 get has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get(string $ruc): PromiseInterface
    {
        return $this->client
            ->getAsync(Endpoints::CONSULT)
            ->then(function () {
Severity: Minor
Found in src/Peru/Sunat/Async/Ruc.php - About 1 hr to fix

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

        private function getResponsePostAndSaveCookies(string $url, $ctx)
        {
            $fp = @fopen($url, 'r', false, $ctx);
            $length = 0;
            if (isset($http_response_header)) {
    Severity: Minor
    Found in src/Peru/Http/ContextClient.php - About 1 hr to fix

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

          private function setValuesFromNode(DOMXPath $xp, DOMNode $item, &$dic): void
          {
              $isTitle = true;
              $title = '';
              foreach ($item->childNodes as $item2) {
      Severity: Minor
      Found in src/Peru/Sunat/HtmlParser.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 setKeyValuesFromNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private function setKeyValuesFromNode(DOMXPath $xp, DOMNode $item, &$dic)
          {
              $keys = $xp->query(".//*[contains(concat(' ', normalize-space(@class), ' '), ' list-group-item-heading ')]", $item);
              $values = $xp->query(".//*[contains(concat(' ', normalize-space(@class), ' '), ' list-group-item-text ')]", $item);
      
      
      Severity: Minor
      Found in src/Peru/Sunat/Parser/HtmlRecaptchaParser.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