core/Federation.php

Summary

Maintainability
F
3 days
Test Coverage

File Federation.php has 421 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/Federation.php - About 6 hrs to fix

    Function downloadStatsCore has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        private function downloadStatsCore($detail = '')
        {
            if ($detail !== 'ORGANISATIONS' && $detail !== 'PROFILES' && $detail !== 'FEDERATION') {
                $detail = 'NONE';
            }
    Severity: Minor
    Found in core/Federation.php - About 4 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 newIdP has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function newIdP($type, $ownerId, $level, $mail = NULL, $bestnameguess = NULL)
        {
            $this->databaseHandle->exec("INSERT INTO institution (country, type) VALUES('$this->tld', '$type')");
            $identifier = $this->databaseHandle->lastID();
    
    
    Severity: Major
    Found in core/Federation.php - About 2 hrs to fix

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

          private function downloadStatsCore($detail = '')
          {
              if ($detail !== 'ORGANISATIONS' && $detail !== 'PROFILES' && $detail !== 'FEDERATION') {
                  $detail = 'NONE';
              }
      Severity: Major
      Found in core/Federation.php - About 2 hrs to fix

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

            public function newIdP($type, $ownerId, $level, $mail = NULL, $bestnameguess = NULL)
            {
                $this->databaseHandle->exec("INSERT INTO institution (country, type) VALUES('$this->tld', '$type')");
                $identifier = $this->databaseHandle->lastID();
        
        
        Severity: Minor
        Found in core/Federation.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 listIdentityProviders has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function listIdentityProviders($activeOnly = 0)
            {
                // maybe we did this exercise before?
                if ($activeOnly != 0 && count($this->idpListActive) > 0) {
                    return $this->idpListActive;
        Severity: Minor
        Found in core/Federation.php - About 1 hr to fix

          Function getIdentityProvidersCertStatus has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getIdentityProvidersCertStatus() {
                  $query = "SELECT distinct profile.profile_id  FROM profile JOIN profile_option ON profile.profile_id = profile_option.profile_id WHERE option_name='profile:production' AND profile.sufficient_config = 1";
                  $activeProfiles = [];
                  $result = $this->databaseHandle->exec($query);
                  $rows = $result->fetch_all();
          Severity: Minor
          Found in core/Federation.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 listIdentityProviders has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function listIdentityProviders($activeOnly = 0)
              {
                  // maybe we did this exercise before?
                  if ($activeOnly != 0 && count($this->idpListActive) > 0) {
                      return $this->idpListActive;
          Severity: Minor
          Found in core/Federation.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 listExternalEntities has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function listExternalEntities($unmappedOnly, $type = NULL)
              {
                  $allExternals = [];
                  $usedarray = [];
                  $returnarray = [];
          Severity: Minor
          Found in core/Federation.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 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct($fedname)
              {
          
                  // initialise the superclass variables
          
          
          Severity: Minor
          Found in core/Federation.php - About 1 hr to fix

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

                public function getIdentityProvidersCertStatus() {
                    $query = "SELECT distinct profile.profile_id  FROM profile JOIN profile_option ON profile.profile_id = profile_option.profile_id WHERE option_name='profile:production' AND profile.sufficient_config = 1";
                    $activeProfiles = [];
                    $result = $this->databaseHandle->exec($query);
                    $rows = $result->fetch_all();
            Severity: Minor
            Found in core/Federation.php - About 1 hr to fix

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

                  public function downloadStats($format, $detail = '')
                  {
                      $data = $this->downloadStatsCore($detail);
                      $retstring = "";
              
              
              Severity: Minor
              Found in core/Federation.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 listExternalEntities has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function listExternalEntities($unmappedOnly, $type = NULL)
                  {
                      $allExternals = [];
                      $usedarray = [];
                      $returnarray = [];
              Severity: Minor
              Found in core/Federation.php - About 1 hr to fix

                Method downloadStats has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function downloadStats($format, $detail = '')
                    {
                        $data = $this->downloadStatsCore($detail);
                        $retstring = "";
                
                
                Severity: Minor
                Found in core/Federation.php - About 1 hr to fix

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

                      public function newIdP($type, $ownerId, $level, $mail = NULL, $bestnameguess = NULL)
                  Severity: Minor
                  Found in core/Federation.php - About 35 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status