core/AbstractProfile.php

Summary

Maintainability
F
1 wk
Test Coverage

Function listDevices has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
Open

    public function listDevices()
    {
        $returnarray = [];
        $redirect = $this->getAttributes("device-specific:redirect"); // this might return per-device ones or the general one
        // if it was a general one, we are done. Find out if there is one such
Severity: Minor
Found in core/AbstractProfile.php - About 1 day 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 AbstractProfile.php has 629 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/AbstractProfile.php - About 1 day to fix

    Function openroamingRedinessTest has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

        public function openroamingRedinessTest() {
            // do OpenRoaming initial diagnostic checks
            // numbers correspond to RFC7585Tests::OVERALL_LEVEL
            $results = [];
            $resultLevel = $this::OVERALL_OPENROAMING_LEVEL_GOOD; // assume all is well, degrade if we have concrete findings to suggest otherwise
    Severity: Minor
    Found in core/AbstractProfile.php - About 1 day 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 openroamingRedinessTest has 109 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function openroamingRedinessTest() {
            // do OpenRoaming initial diagnostic checks
            // numbers correspond to RFC7585Tests::OVERALL_LEVEL
            $results = [];
            $resultLevel = $this::OVERALL_OPENROAMING_LEVEL_GOOD; // assume all is well, degrade if we have concrete findings to suggest otherwise
    Severity: Major
    Found in core/AbstractProfile.php - About 4 hrs to fix

      Method listDevices has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function listDevices()
          {
              $returnarray = [];
              $redirect = $this->getAttributes("device-specific:redirect"); // this might return per-device ones or the general one
              // if it was a general one, we are done. Find out if there is one such
      Severity: Major
      Found in core/AbstractProfile.php - About 3 hrs to fix

        AbstractProfile has 29 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class AbstractProfile extends EntityWithDBProperties
        {
        
            const HIDDEN = -1;
            const AVAILABLE = 0;
        Severity: Minor
        Found in core/AbstractProfile.php - About 3 hrs to fix

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

              public function isEapTypeDefinitionComplete($eaptype)
              {
                  if ($eaptype->needsServerCACert() && $eaptype->needsServerName()) {
                      $missing = [];
                      // silverbullet needs a support email address configured
          Severity: Minor
          Found in core/AbstractProfile.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 significantChanges has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function significantChanges($old, $new)
              {
                  $retval = [];
                  // check if a CA was added
                  $x509 = new common\X509();
          Severity: Minor
          Found in core/AbstractProfile.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 getCollapsedAttributes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getCollapsedAttributes($eap = [])
              {
                  $collapsedList = [];
                  foreach ($this->getAttributes() as $attribute) {
                      // filter out eap-level attributes not pertaining to EAP type $eap
          Severity: Minor
          Found in core/AbstractProfile.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 significantChanges has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function significantChanges($old, $new)
              {
                  $retval = [];
                  // check if a CA was added
                  $x509 = new common\X509();
          Severity: Minor
          Found in core/AbstractProfile.php - About 1 hr to fix

            Method isEapTypeDefinitionComplete has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function isEapTypeDefinitionComplete($eaptype)
                {
                    if ($eaptype->needsServerCACert() && $eaptype->needsServerName()) {
                        $missing = [];
                        // silverbullet needs a support email address configured
            Severity: Minor
            Found in core/AbstractProfile.php - About 1 hr to fix

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

                  public function __construct($profileIdRaw, $idpObject = NULL)
                  {
                      $this->databaseType = "INST";
                      parent::__construct(); // we now have access to our INST database handle and logging
                      $handle = DBConnection::handle("FRONTEND");
              Severity: Minor
              Found in core/AbstractProfile.php - About 1 hr to fix

                Function readyForShowtime has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function readyForShowtime()
                    {
                        $properConfig = FALSE;
                        $attribs = $this->getCollapsedAttributes();
                        // do we have enough to go live? Check if any of the configured EAP methods is completely configured ...
                Severity: Minor
                Found in core/AbstractProfile.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 incrementDownloadStats has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function incrementDownloadStats($device, $area, $openRoaming)
                    {
                        if ($area == "admin" || $area == "user" || $area == "silverbullet") {
                            $lang = $this->languageInstance->getLang();
                            $this->frontendHandle->exec("INSERT INTO downloads (profile_id, device_id, lang, openroaming, downloads_$area) VALUES (? ,?, ?, ?, 1) ON DUPLICATE KEY UPDATE downloads_$area = downloads_$area + 1", "issi", $this->identifier, $device, $lang, $openRoaming);
                Severity: Minor
                Found in core/AbstractProfile.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

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

                    protected function saveDownloadDetails($idpIdentifier, $profileId, $deviceId, $area, $lang, $eapType, $openRoaming)
                Severity: Major
                Found in core/AbstractProfile.php - About 50 mins to fix

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

                      public function getUserDownloadStats($device = NULL)
                      {
                          $columnName = "downloads_user";
                          if ($this instanceof \core\ProfileSilverbullet) {
                              $columnName = "downloads_silverbullet";
                  Severity: Minor
                  Found in core/AbstractProfile.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 updateCache has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      abstract public function updateCache($device, $path, $mime, $integerEapType, $openRoaming);
                  Severity: Minor
                  Found in core/AbstractProfile.php - About 35 mins to fix

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

                        public function testCache($device, $openRoaming)
                        {
                            $returnValue = ['cache' => NULL, 'mime' => NULL];
                            $lang = $this->languageInstance->getLang();
                            $result = $this->frontendHandle->exec("SELECT download_path, mime, UNIX_TIMESTAMP(installer_time) AS tm FROM downloads WHERE profile_id = ? AND device_id = ? AND lang = ? AND openroaming = ?", "issi", $this->identifier, $device, $lang, $openRoaming);
                    Severity: Minor
                    Found in core/AbstractProfile.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 TRUE;
                    Severity: Major
                    Found in core/AbstractProfile.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status