core/diag/RADIUSTests.php

Summary

Maintainability
F
1 wk
Test Coverage

File RADIUSTests.php has 813 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: Major
Found in core/diag/RADIUSTests.php - About 1 day to fix

    RADIUSTests has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class RADIUSTests extends AbstractTest {
    
        /**
         * Was the reachability check executed already?
         * 
    Severity: Minor
    Found in core/diag/RADIUSTests.php - About 3 hrs to fix

      Function extractIncomingCertsfromEAP has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          private function extractIncomingCertsfromEAP(&$testresults, $tmpDir) {
              /*
               *  EAP's house rules:
               * 1) it is unnecessary to include the root CA itself (adding it has
               *    detrimental effects on performance)
      Severity: Minor
      Found in core/diag/RADIUSTests.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

      Function propertyCheckServercert has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          private function propertyCheckServercert(&$servercert) {
      // we share the same checks as for CAs when it comes to signature algorithm and basicconstraints
      // so call that function and memorise the outcome
              $returnarray = $this->propertyCheckIntermediate($servercert, TRUE);
              $sANdns = [];
      Severity: Minor
      Found in core/diag/RADIUSTests.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

      Method autodetectCAWithProbe has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function autodetectCAWithProbe($outerId) {
              // for EAP-TLS to be a viable option, we need to pass a random client cert to make eapol_test happy
              // the following PEM data is one of the SENSE EAPLab client certs (not secret at all)
              $clientcert = file_get_contents(dirname(__FILE__) . "/clientcert.p12");
              if ($clientcert === FALSE) {
      Severity: Major
      Found in core/diag/RADIUSTests.php - About 2 hrs to fix

        Function checkLineparse has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            private function checkLineparse($inputarray, $desiredCheck) {
                foreach ($inputarray as $lineid => $line) {
                    switch ($desiredCheck) {
                        case self::LINEPARSE_CHECK_REJECTIGNORE:
                            if (preg_match("/Attribute 18 (Reply-Message)/", $line) && preg_match("/Reject instead of Ignore at eduroam.org/", $inputarray[$lineid + 1])) {
        Severity: Minor
        Found in core/diag/RADIUSTests.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

        Function consolidateUdpResult has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public function consolidateUdpResult($host) {
                \core\common\Entity::intoThePotatoes();
                $ret = [];
                $serverCert = [];
                $udpResult = $this->UDP_reachability_result[$host];
        Severity: Minor
        Found in core/diag/RADIUSTests.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

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

            private function createCArepository($tmpDir, &$intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
                if (!mkdir($tmpDir . "/root-ca-allcerts/", 0700, true)) {
                    throw new Exception("unable to create root CA directory (RADIUS Tests): $tmpDir/root-ca-allcerts/\n");
                }
                if (!mkdir($tmpDir . "/root-ca-eaponly/", 0700, true)) {
        Severity: Minor
        Found in core/diag/RADIUSTests.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

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

            public function udpLogin($probeindex, $eaptype, $innerUser, $password, $opnameCheck = TRUE, $frag = TRUE, $clientcertdata = NULL) {
                $preliminaries = $this->udpLoginPreliminaries($probeindex, $eaptype, $clientcertdata);
                if ($preliminaries !== TRUE) {
                    return $preliminaries;
                }
        Severity: Minor
        Found in core/diag/RADIUSTests.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 extractIncomingCertsfromEAP has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function extractIncomingCertsfromEAP(&$testresults, $tmpDir) {
                /*
                 *  EAP's house rules:
                 * 1) it is unnecessary to include the root CA itself (adding it has
                 *    detrimental effects on performance)
        Severity: Major
        Found in core/diag/RADIUSTests.php - About 2 hrs to fix

          Function autodetectCAWithProbe has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              public function autodetectCAWithProbe($outerId) {
                  // for EAP-TLS to be a viable option, we need to pass a random client cert to make eapol_test happy
                  // the following PEM data is one of the SENSE EAPLab client certs (not secret at all)
                  $clientcert = file_get_contents(dirname(__FILE__) . "/clientcert.p12");
                  if ($clientcert === FALSE) {
          Severity: Minor
          Found in core/diag/RADIUSTests.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

          Function packetCountEvaluation has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              private function packetCountEvaluation(&$testresults, $packetcount) {
                  $reqs = $packetcount[1] ?? 0;
                  $accepts = $packetcount[2] ?? 0;
                  $rejects = $packetcount[3] ?? 0;
                  $challenges = $packetcount[11] ?? 0;
          Severity: Minor
          Found in core/diag/RADIUSTests.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 udpLogin has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function udpLogin($probeindex, $eaptype, $innerUser, $password, $opnameCheck = TRUE, $frag = TRUE, $clientcertdata = NULL) {
                  $preliminaries = $this->udpLoginPreliminaries($probeindex, $eaptype, $clientcertdata);
                  if ($preliminaries !== TRUE) {
                      return $preliminaries;
                  }
          Severity: Major
          Found in core/diag/RADIUSTests.php - About 2 hrs to fix

            Method consolidateUdpResult has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function consolidateUdpResult($host) {
                    \core\common\Entity::intoThePotatoes();
                    $ret = [];
                    $serverCert = [];
                    $udpResult = $this->UDP_reachability_result[$host];
            Severity: Major
            Found in core/diag/RADIUSTests.php - About 2 hrs to fix

              Method checkLineparse has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function checkLineparse($inputarray, $desiredCheck) {
                      foreach ($inputarray as $lineid => $line) {
                          switch ($desiredCheck) {
                              case self::LINEPARSE_CHECK_REJECTIGNORE:
                                  if (preg_match("/Attribute 18 (Reply-Message)/", $line) && preg_match("/Reject instead of Ignore at eduroam.org/", $inputarray[$lineid + 1])) {
              Severity: Major
              Found in core/diag/RADIUSTests.php - About 2 hrs to fix

                Method createCArepository has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function createCArepository($tmpDir, &$intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
                        if (!mkdir($tmpDir . "/root-ca-allcerts/", 0700, true)) {
                            throw new Exception("unable to create root CA directory (RADIUS Tests): $tmpDir/root-ca-allcerts/\n");
                        }
                        if (!mkdir($tmpDir . "/root-ca-eaponly/", 0700, true)) {
                Severity: Minor
                Found in core/diag/RADIUSTests.php - About 1 hr to fix

                  Function thoroughChainChecks has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function thoroughChainChecks(&$testresults, &$intermOdditiesCAT, $tmpDir, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
                  
                          $crlCheckString = $this->createCArepository($tmpDir, $intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs);
                  // ... and run the verification test
                          $verifyResultEaponly = [];
                  Severity: Minor
                  Found in core/diag/RADIUSTests.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 __construct has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function __construct($realm, $outerUsernameForChecks, $supportedEapTypes = [], $expectedServerNames = [], $expectedCABundle = []) {
                          parent::__construct();
                  
                          $this->realm = $realm;
                          $this->outerUsernameForChecks = $outerUsernameForChecks;
                  Severity: Minor
                  Found in core/diag/RADIUSTests.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 thoroughChainChecks has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function thoroughChainChecks(&$testresults, &$intermOdditiesCAT, $tmpDir, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
                  
                          $crlCheckString = $this->createCArepository($tmpDir, $intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs);
                  // ... and run the verification test
                          $verifyResultEaponly = [];
                  Severity: Minor
                  Found in core/diag/RADIUSTests.php - About 1 hr to fix

                    Method propertyCheckServercert has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function propertyCheckServercert(&$servercert) {
                    // we share the same checks as for CAs when it comes to signature algorithm and basicconstraints
                    // so call that function and memorise the outcome
                            $returnarray = $this->propertyCheckIntermediate($servercert, TRUE);
                            $sANdns = [];
                    Severity: Minor
                    Found in core/diag/RADIUSTests.php - About 1 hr to fix

                      Method addCrltoCert has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function addCrltoCert(&$cert) {
                              $crlUrl = [];
                              $returnresult = 0;
                              if (!isset($cert['full_details']['extensions']['crlDistributionPoints'])) {
                                  return RADIUSTests::CERTPROB_NO_CDP;
                      Severity: Minor
                      Found in core/diag/RADIUSTests.php - About 1 hr to fix

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

                            public function __construct($realm, $outerUsernameForChecks, $supportedEapTypes = [], $expectedServerNames = [], $expectedCABundle = []) {
                                parent::__construct();
                        
                                $this->realm = $realm;
                                $this->outerUsernameForChecks = $outerUsernameForChecks;
                        Severity: Minor
                        Found in core/diag/RADIUSTests.php - About 1 hr to fix

                          Method wpaSupplicantConfig has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function wpaSupplicantConfig(array $eaptype, string $inner, string $outer, string $password) {
                                  $eapText = \core\common\EAP::eapDisplayName($eaptype);
                                  $config = '
                          network={
                            ssid="' . \config\Master::APPEARANCE['productname'] . ' testing"
                          Severity: Minor
                          Found in core/diag/RADIUSTests.php - About 1 hr to fix

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

                                private function thoroughNameChecks($servercert, &$testresults) {
                                    // Strategy for checks: we are TOTALLY happy if any one of the
                                    // configured names shows up in both the CN and a sAN
                                    // This is the primary check.
                                    // If that was not the case, we are PARTIALLY happy if any one of
                            Severity: Minor
                            Found in core/diag/RADIUSTests.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 propertyCheckIntermediate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function propertyCheckIntermediate(&$intermediateCa, $serverCert = FALSE) {
                                    $returnarray = [];
                                    if (preg_match("/md5/i", $intermediateCa['full_details']['signatureTypeSN'])) {
                                        $returnarray[] = RADIUSTests::CERTPROB_MD5_SIGNATURE;
                                    }
                            Severity: Minor
                            Found in core/diag/RADIUSTests.php - About 1 hr to fix

                              Function propertyCheckIntermediate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function propertyCheckIntermediate(&$intermediateCa, $serverCert = FALSE) {
                                      $returnarray = [];
                                      if (preg_match("/md5/i", $intermediateCa['full_details']['signatureTypeSN'])) {
                                          $returnarray[] = RADIUSTests::CERTPROB_MD5_SIGNATURE;
                                      }
                              Severity: Minor
                              Found in core/diag/RADIUSTests.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 packetCountEvaluation has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function packetCountEvaluation(&$testresults, $packetcount) {
                                      $reqs = $packetcount[1] ?? 0;
                                      $accepts = $packetcount[2] ?? 0;
                                      $rejects = $packetcount[3] ?? 0;
                                      $challenges = $packetcount[11] ?? 0;
                              Severity: Minor
                              Found in core/diag/RADIUSTests.php - About 1 hr to fix

                                Method executeEapolTest has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    private function executeEapolTest($tmpDir, $probeindex, $eaptype, $outerUser, $innerUser, $password, $opnameCheck, $frag) {
                                Severity: Major
                                Found in core/diag/RADIUSTests.php - About 1 hr to fix

                                  Method udpLogin has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      public function udpLogin($probeindex, $eaptype, $innerUser, $password, $opnameCheck = TRUE, $frag = TRUE, $clientcertdata = NULL) {
                                  Severity: Major
                                  Found in core/diag/RADIUSTests.php - About 50 mins to fix

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

                                        private function printDN($distinguishedName) {
                                            $out = '';
                                            foreach (array_reverse($distinguishedName) as $nameType => $nameValue) { // to give an example: "CN" => "some.host.example" 
                                                if (!is_array($nameValue)) { // single-valued: just a string
                                                    $nameValue = ["$nameValue"]; // convert it to a multi-value attrib with just one value :-) for unified processing later on
                                    Severity: Minor
                                    Found in core/diag/RADIUSTests.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 thoroughChainChecks has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        private function thoroughChainChecks(&$testresults, &$intermOdditiesCAT, $tmpDir, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
                                    Severity: Minor
                                    Found in core/diag/RADIUSTests.php - About 45 mins to fix

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

                                          private function createCArepository($tmpDir, &$intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
                                      Severity: Minor
                                      Found in core/diag/RADIUSTests.php - About 35 mins to fix

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

                                            public function __construct($realm, $outerUsernameForChecks, $supportedEapTypes = [], $expectedServerNames = [], $expectedCABundle = []) {
                                        Severity: Minor
                                        Found in core/diag/RADIUSTests.php - About 35 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

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

                                            Avoid too many return statements within this method.
                                            Open

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

                                              Avoid too many return statements within this method.
                                              Open

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

                                                Avoid too many return statements within this method.
                                                Open

                                                        return [
                                                            "NAME" => $serverName,
                                                            "INTERMEDIATE_CA" => $bundle['INTERMEDIATE_CA'],
                                                            "HIGHEST_ISSUER" => $currentHighestKnownIssuer,
                                                            "ROOT_CA" => NULL,
                                                Severity: Major
                                                Found in core/diag/RADIUSTests.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

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

                                                    Avoid too many return statements within this method.
                                                    Open

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

                                                      Avoid too many return statements within this method.
                                                      Open

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

                                                        Function addCrltoCert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            private function addCrltoCert(&$cert) {
                                                                $crlUrl = [];
                                                                $returnresult = 0;
                                                                if (!isset($cert['full_details']['extensions']['crlDistributionPoints'])) {
                                                                    return RADIUSTests::CERTPROB_NO_CDP;
                                                        Severity: Minor
                                                        Found in core/diag/RADIUSTests.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

                                                        Function determineCertificateType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            private function determineCertificateType(&$cert, $totalCertCount) {
                                                                if ($cert['ca'] == 0 && $cert['root'] == 0) {
                                                                    return RADIUSTests::SERVER_NO_CA_EXTENSION;
                                                                }
                                                                if ($cert['ca'] == 1 && $cert['root'] == 1) {
                                                        Severity: Minor
                                                        Found in core/diag/RADIUSTests.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

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

                                                                if (!preg_match("/OK$/", $verifyResultAllcerts[0])) { // case 1
                                                                    if (preg_match("/certificate revoked$/", $verifyResultAllcerts[1])) {
                                                                        $testresults['cert_oddities'][] = RADIUSTests::CERTPROB_SERVER_CERT_REVOKED;
                                                                    } elseif (preg_match("/unable to get certificate CRL/", $verifyResultAllcerts[1])) {
                                                                        $testresults['cert_oddities'][] = RADIUSTests::CERTPROB_UNABLE_TO_GET_CRL;
                                                        Severity: Major
                                                        Found in core/diag/RADIUSTests.php and 1 other location - About 1 hr to fix
                                                        core/diag/RADIUSTests.php on lines 789..798

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

                                                        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

                                                                if (!preg_match("/OK$/", $verifyResultEaponly[0])) { // case 2
                                                                    if (preg_match("/certificate revoked$/", $verifyResultEaponly[1])) {
                                                                        $testresults['cert_oddities'][] = RADIUSTests::CERTPROB_SERVER_CERT_REVOKED;
                                                                    } elseif (preg_match("/unable to get certificate CRL/", $verifyResultEaponly[1])) {
                                                                        $testresults['cert_oddities'][] = RADIUSTests::CERTPROB_UNABLE_TO_GET_CRL;
                                                        Severity: Major
                                                        Found in core/diag/RADIUSTests.php and 1 other location - About 1 hr to fix
                                                        core/diag/RADIUSTests.php on lines 779..788

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

                                                        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

                                                        There are no issues that match your filters.

                                                        Category
                                                        Status