core/UserAPI.php

Summary

Maintainability
D
2 days
Test Coverage

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

    UserAPI has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class UserAPI extends CAT
    {
    
        /**
         * nothing special to be done here.
    Severity: Minor
    Found in core/UserAPI.php - About 2 hrs to fix

      Method getLogo has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getLogo($identifier, $type, $widthIn, $heightIn)
          {
              $expiresString = '';
              $attributeName = [
                  'federation' => "fed:logo_file",
      Severity: Minor
      Found in core/UserAPI.php - About 1 hr to fix

        Function generateNewInstaller has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            private function generateNewInstaller($device, $profile, $generatedFor, $openRoaming, $token, $password)
            {
                $this->loggerInstance->debug(5, "generateNewInstaller() - Enter");
                $this->loggerInstance->debug(5, "generateNewInstaller:openRoaming:$openRoaming\n");
                $factory = new DeviceFactory($device);
        Severity: Minor
        Found in core/UserAPI.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 generateNewInstaller has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function generateNewInstaller($device, $profile, $generatedFor, $openRoaming, $token, $password)
            {
                $this->loggerInstance->debug(5, "generateNewInstaller() - Enter");
                $this->loggerInstance->debug(5, "generateNewInstaller:openRoaming:$openRoaming\n");
                $factory = new DeviceFactory($device);
        Severity: Minor
        Found in core/UserAPI.php - About 1 hr to fix

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

              protected function getLogo($identifier, $type, $widthIn, $heightIn)
              {
                  $expiresString = '';
                  $attributeName = [
                      'federation' => "fed:logo_file",
          Severity: Minor
          Found in core/UserAPI.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 listDevices has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function listDevices($showHidden = 0)
              {
                  $returnList = [];
                  $count = 0;
                  if ($showHidden !== 0 && $showHidden != 1) {
          Severity: Minor
          Found in core/UserAPI.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 detectOS has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function detectOS()
              {
                  $Dev = \devices\Devices::listDevices();
                  $devId = $this->deviceFromRequest();
                  if ($devId !== NULL) {
          Severity: Minor
          Found in core/UserAPI.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 generateInstaller has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function generateInstaller($device, $profileId, $generatedFor = "user", $openRoaming = 0, $token = NULL, $password = NULL)
          Severity: Minor
          Found in core/UserAPI.php - About 45 mins to fix

            Method downloadInstaller has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function downloadInstaller($device, $prof_id, $generated_for = 'user', $openRoaming = 0, $token = NULL, $password = NULL)
            Severity: Minor
            Found in core/UserAPI.php - About 45 mins to fix

              Method generateNewInstaller has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function generateNewInstaller($device, $profile, $generatedFor, $openRoaming, $token, $password)
              Severity: Minor
              Found in core/UserAPI.php - About 45 mins to fix

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

                    private function processImage($inputImage, $destFile, $width, $height, $resize)
                Severity: Minor
                Found in core/UserAPI.php - About 35 mins to fix

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

                      private function testForResize($width, $height)
                      {
                          if (is_numeric($width) && is_numeric($height) && ($width > 0 || $height > 0)) {
                              if ($height == 0) {
                                  $height = 10000;
                  Severity: Minor
                  Found in core/UserAPI.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 generateInstaller has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function generateInstaller($device, $profileId, $generatedFor = "user", $openRoaming = 0, $token = NULL, $password = NULL)
                      {
                          $this->loggerInstance->debug(4, "generateInstaller arguments:$device:$profileId:$openRoaming\n");
                          $validator = new \web\lib\common\InputValidation();
                          $profile = $validator->existingProfile($profileId);
                  Severity: Minor
                  Found in core/UserAPI.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 profileAttributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function profileAttributes($profId)
                      {
                          $validator = new \web\lib\common\InputValidation();
                          $profile = $validator->existingProfile($profId);
                          $attribs = $profile->getCollapsedAttributes();
                  Severity: Minor
                  Found in core/UserAPI.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