web/lib/admin/OptionParser.php

Summary

Maintainability
F
4 days
Test Coverage

Function sanitiseInputs has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

    private function sanitiseInputs(array $listOfEntries) {
        $retval = [];
        $bad = [];
        $multilangAttrsWithC = [];
        foreach ($listOfEntries as $objId => $objValueRaw) {
Severity: Minor
Found in web/lib/admin/OptionParser.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

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

    private function postProcessValidAttributes(array $options, array &$good, array &$bad) {
        foreach ($options as $index => $iterateOption) {
            foreach ($iterateOption as $name => $optionPayload) {
                switch ($name) {
                    case "eap:ca_url": // eap:ca_url becomes eap:ca_file by downloading the file
Severity: Minor
Found in web/lib/admin/OptionParser.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

File OptionParser.php has 343 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 web/lib/admin/OptionParser.php - About 4 hrs to fix

    Method sanitiseInputs has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function sanitiseInputs(array $listOfEntries) {
            $retval = [];
            $bad = [];
            $multilangAttrsWithC = [];
            foreach ($listOfEntries as $objId => $objValueRaw) {
    Severity: Major
    Found in web/lib/admin/OptionParser.php - About 3 hrs to fix

      Method furtherStringChecks has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function furtherStringChecks($attribute, $previsionalContent, &$bad) {
              $content = FALSE;
              switch ($attribute) {
                  case "media:consortium_OI":
                      $content = $this->validator->consortiumOI($previsionalContent);
      Severity: Major
      Found in web/lib/admin/OptionParser.php - About 2 hrs to fix

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

            private function sendOptionsToDatabase($object, array $options, array $pendingattributes, string $device = NULL, int $eaptype = NULL) {
                $retval = [];
                foreach ($options as $iterateOption) {
                    foreach ($iterateOption as $name => $optionPayload) {
                        $optiontype = $this->optioninfoObject->optionType($name);
        Severity: Minor
        Found in web/lib/admin/OptionParser.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 postProcessValidAttributes has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function postProcessValidAttributes(array $options, array &$good, array &$bad) {
                foreach ($options as $index => $iterateOption) {
                    foreach ($iterateOption as $name => $optionPayload) {
                        switch ($name) {
                            case "eap:ca_url": // eap:ca_url becomes eap:ca_file by downloading the file
        Severity: Minor
        Found in web/lib/admin/OptionParser.php - About 1 hr to fix

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

              private function furtherStringChecks($attribute, $previsionalContent, &$bad) {
                  $content = FALSE;
                  switch ($attribute) {
                      case "media:consortium_OI":
                          $content = $this->validator->consortiumOI($previsionalContent);
          Severity: Minor
          Found in web/lib/admin/OptionParser.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 checkUploadSanity has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function checkUploadSanity(string $optiontype, string $incomingBinary) {
                  switch ($optiontype) {
                      case "general:logo_file":
                      case "fed:logo_file":
                      case "internal:logo_from_url":
          Severity: Minor
          Found in web/lib/admin/OptionParser.php - About 1 hr to fix

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

                private function sendOptionsToDatabase($object, array $options, array $pendingattributes, string $device = NULL, int $eaptype = NULL) {
                    $retval = [];
                    foreach ($options as $iterateOption) {
                        foreach ($iterateOption as $name => $optionPayload) {
                            $optiontype = $this->optioninfoObject->optionType($name);
            Severity: Minor
            Found in web/lib/admin/OptionParser.php - About 1 hr to fix

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

                  private function sendOptionsToDatabase($object, array $options, array $pendingattributes, string $device = NULL, int $eaptype = NULL) {
              Severity: Minor
              Found in web/lib/admin/OptionParser.php - About 35 mins to fix

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

                    public function processSubmittedFields($object, array $postArray, array $filesArray, int $eaptype = NULL, string $device = NULL) {
                Severity: Minor
                Found in web/lib/admin/OptionParser.php - About 35 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return FALSE;
                  Severity: Major
                  Found in web/lib/admin/OptionParser.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return FALSE;
                    Severity: Major
                    Found in web/lib/admin/OptionParser.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return FALSE;
                      Severity: Major
                      Found in web/lib/admin/OptionParser.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return FALSE;
                        Severity: Major
                        Found in web/lib/admin/OptionParser.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return $content;
                          Severity: Major
                          Found in web/lib/admin/OptionParser.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return TRUE;
                            Severity: Major
                            Found in web/lib/admin/OptionParser.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return FALSE;
                              Severity: Major
                              Found in web/lib/admin/OptionParser.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return FALSE;
                                Severity: Major
                                Found in web/lib/admin/OptionParser.php - About 30 mins to fix

                                  There are no issues that match your filters.

                                  Category
                                  Status