core/DeploymentManaged.php

Summary

Maintainability
D
2 days
Test Coverage

File DeploymentManaged.php has 381 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/DeploymentManaged.php - About 5 hrs to fix

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

        public function __construct($idpObject, $deploymentIdRaw, $consortium = 'eduroam')
        {
            parent::__construct($idpObject, $deploymentIdRaw); // we now have access to our INST database handle and logging
            $this->entityOptionTable = "deployment_option";
            $this->entityIdColumn = "deployment_id";
    Severity: Major
    Found in core/DeploymentManaged.php - About 2 hrs to fix

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

          public function setRADIUSconfig($onlyone = 0, $notify = 0)
          {
              $remove = ($this->status == \core\AbstractDeployment::INACTIVE) ? 0 : 1;
              $toPost = ($onlyone ? array($onlyone => '') : array(1 => '', 2 => ''));
              $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . '&secret=' . $this->secret . '&country=' . $this->getAttributes("internal:country")[0]['value'] . '&';
      Severity: Minor
      Found in core/DeploymentManaged.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 findGoodServerLocation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          private function findGoodServerLocation($adminLocation, $federation, $blacklistedServers)
          {
              // find a server near him (list of all servers with capacity, ordered by distance)
              // first, if there is a pool of servers specifically for this federation, prefer it
              // only check the consortium pool group we want to attach to
      Severity: Minor
      Found in core/DeploymentManaged.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 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct($idpObject, $deploymentIdRaw, $consortium = 'eduroam')
          {
              parent::__construct($idpObject, $deploymentIdRaw); // we now have access to our INST database handle and logging
              $this->entityOptionTable = "deployment_option";
              $this->entityIdColumn = "deployment_id";
      Severity: Minor
      Found in core/DeploymentManaged.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 setRADIUSconfig has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function setRADIUSconfig($onlyone = 0, $notify = 0)
          {
              $remove = ($this->status == \core\AbstractDeployment::INACTIVE) ? 0 : 1;
              $toPost = ($onlyone ? array($onlyone => '') : array(1 => '', 2 => ''));
              $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . '&secret=' . $this->secret . '&country=' . $this->getAttributes("internal:country")[0]['value'] . '&';
      Severity: Minor
      Found in core/DeploymentManaged.php - About 1 hr to fix

        Method findGoodServerLocation has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function findGoodServerLocation($adminLocation, $federation, $blacklistedServers)
            {
                // find a server near him (list of all servers with capacity, ordered by distance)
                // first, if there is a pool of servers specifically for this federation, prefer it
                // only check the consortium pool group we want to attach to
        Severity: Minor
        Found in core/DeploymentManaged.php - About 1 hr to fix

          Method sendMailtoAdmin has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function sendMailtoAdmin($remove, $response, $status)
              {
                  $txt = '';
                  if ($status == 'OK') {
                      $txt = $remove ? _('Profile deactivation succeeded') : _('Profile activation/modification succeeded');
          Severity: Minor
          Found in core/DeploymentManaged.php - About 1 hr to fix

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

                private function sendMailtoAdmin($remove, $response, $status)
                {
                    $txt = '';
                    if ($status == 'OK') {
                        $txt = $remove ? _('Profile deactivation succeeded') : _('Profile activation/modification succeeded');
            Severity: Minor
            Found in core/DeploymentManaged.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 initialise has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function initialise()
                {
                    // find out where the admin is located approximately
                    $ourLocation = ['lon' => 0, 'lat' => 0];
                    $geoip = DeviceLocation::locateDevice();
            Severity: Minor
            Found in core/DeploymentManaged.php - About 1 hr to fix

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

                  private function sendToRADIUS(int $idx, $post)
                  {
              
                      $hostname = "radius_hostname_$idx";
                      $ch = curl_init("http://" . $this->$hostname);
              Severity: Minor
              Found in core/DeploymentManaged.php - About 1 hr to fix

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

                    private function initialise()
                    {
                        // find out where the admin is located approximately
                        $ourLocation = ['lon' => 0, 'lat' => 0];
                        $geoip = DeviceLocation::locateDevice();
                Severity: Minor
                Found in core/DeploymentManaged.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 getAllRealms has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function getAllRealms()
                    {
                        $idp = new IdP($this->institution);
                        $allProfiles = $idp->listProfiles(TRUE);
                        $allRealms = [];
                Severity: Minor
                Found in core/DeploymentManaged.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 checkRADIUSHostandConfigDaemon has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function checkRADIUSHostandConfigDaemon()
                    {
                        $res = array();
                        if ($this->radius_status_1 == \core\AbstractDeployment::RADIUS_FAILURE) {
                            $res[1] = $this->checkURL(1);
                Severity: Minor
                Found in core/DeploymentManaged.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

                There are no issues that match your filters.

                Category
                Status