core/diag/RFC6614Tests.php

Summary

Maintainability
D
2 days
Test Coverage

Function tlsClientSideCheck has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    public function tlsClientSideCheck(string $host, string $ename, string $realm)
    {
        $res = RADIUSTests::RETVAL_OK;
        if (!is_array(\config\Diagnostics::RADIUSTESTS['TLS-clientcerts']) || count(\config\Diagnostics::RADIUSTESTS['TLS-clientcerts']) == 0) {
            return RADIUSTests::RETVAL_SKIPPED;
Severity: Minor
Found in core/diag/RFC6614Tests.php - About 5 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

File RFC6614Tests.php has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * *****************************************************************************
 * Contributions to this work were made on behalf of the GÉANT project, a 
Severity: Minor
Found in core/diag/RFC6614Tests.php - About 2 hrs to fix

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

        private function opensslCAResult($host, $opensslbabble)
        {
            if (preg_match('/connect: Connection refused/', implode($opensslbabble))) {
                $this->TLS_CA_checks_result[$host]['status'] = RADIUSTests::RETVAL_CONNECTION_REFUSED;
                return RADIUSTests::RETVAL_INVALID;
    Severity: Minor
    Found in core/diag/RFC6614Tests.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 tlsClientSideCheck has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function tlsClientSideCheck(string $host, string $ename, string $realm)
        {
            $res = RADIUSTests::RETVAL_OK;
            if (!is_array(\config\Diagnostics::RADIUSTESTS['TLS-clientcerts']) || count(\config\Diagnostics::RADIUSTESTS['TLS-clientcerts']) == 0) {
                return RADIUSTests::RETVAL_SKIPPED;
    Severity: Minor
    Found in core/diag/RFC6614Tests.php - About 1 hr to fix

      Method opensslCAResult has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function opensslCAResult($host, $opensslbabble)
          {
              if (preg_match('/connect: Connection refused/', implode($opensslbabble))) {
                  $this->TLS_CA_checks_result[$host]['status'] = RADIUSTests::RETVAL_CONNECTION_REFUSED;
                  return RADIUSTests::RETVAL_INVALID;
      Severity: Minor
      Found in core/diag/RFC6614Tests.php - About 1 hr to fix

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

            private function opensslClientsResult($host, $opensslbabble, &$testresults, $type = '', $resultArrayKey = 0)
            {
                \core\common\Entity::intoThePotatoes();
                $res = RADIUSTests::RETVAL_OK;
                $ret = $testresults[$host]['ca'][$type]['certificate'][$resultArrayKey]['returncode'];
        Severity: Minor
        Found in core/diag/RFC6614Tests.php - About 1 hr to fix

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

              private function opensslClientsResult($host, $opensslbabble, &$testresults, $type = '', $resultArrayKey = 0)
              {
                  \core\common\Entity::intoThePotatoes();
                  $res = RADIUSTests::RETVAL_OK;
                  $ret = $testresults[$host]['ca'][$type]['certificate'][$resultArrayKey]['returncode'];
          Severity: Minor
          Found in core/diag/RFC6614Tests.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 checkServerName has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function checkServerName($host)
              {
                  // it could match CN or sAN:DNS, we don't care which
                  if (isset($this->TLS_CA_checks_result[$host]['certdata']['subject'])) {
                      $this->loggerInstance->debug(4, "Checking expected server name " . $this->expectedName . 
          Severity: Minor
          Found in core/diag/RFC6614Tests.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 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct($listOfIPs, $expectedName, $consortium = "eduroam")
              {
                  parent::__construct();
                  \core\common\Entity::intoThePotatoes();
                  $this->TLS_certkeys = [
          Severity: Minor
          Found in core/diag/RFC6614Tests.php - About 1 hr to fix

            Method opensslClientsResult has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private function opensslClientsResult($host, $opensslbabble, &$testresults, $type = '', $resultArrayKey = 0)
            Severity: Minor
            Found in core/diag/RFC6614Tests.php - About 35 mins to fix

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

                  private function getCertificateIssuer($cert)
                  {
                      $issuer = '';
                      foreach ($cert['issuer'] as $key => $val) {
                          if (is_array($val)) {
              Severity: Minor
              Found in core/diag/RFC6614Tests.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 propertyCheckPolicy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function propertyCheckPolicy($cert)
                  {
                      $oids = [];
                      if (isset($cert['extensions']['certificatePolicies']) &&  $cert['extensions']['certificatePolicies']) {
                          foreach (\config\Diagnostics::RADIUSTESTS['TLS-acceptableOIDs'] as $key => $oid) {
              Severity: Minor
              Found in core/diag/RFC6614Tests.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 RADIUSTests::RETVAL_OK;
              Severity: Major
              Found in core/diag/RFC6614Tests.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return RADIUSTests::RETVAL_INVALID;
                Severity: Major
                Found in core/diag/RFC6614Tests.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status