Admidio/admidio

View on GitHub
src/UserInterface/Preferences.php

Summary

Maintainability
F
2 wks
Test Coverage

File Preferences.php has 1892 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Admidio\UserInterface;

use ComponentUpdate;
use FileSystemUtils;
Severity: Major
Found in src/UserInterface/Preferences.php - About 5 days to fix

    Method createEmailDispatchForm has 141 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function createEmailDispatchForm(): string
        {
            global $gL10n, $gCurrentOrganization, $gSettingsManager, $gCurrentSession;
    
            $formValues = $gSettingsManager->getAll();
    Severity: Major
    Found in src/UserInterface/Preferences.php - About 5 hrs to fix

      Method createEventsForm has 118 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function createEventsForm(): string
          {
              global $gL10n, $gSettingsManager, $gDb, $gCurrentOrgId, $gCurrentSession;
      
              $formValues = $gSettingsManager->getAll();
      Severity: Major
      Found in src/UserInterface/Preferences.php - About 4 hrs to fix

        Method createPhotosForm has 117 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function createPhotosForm(): string
            {
                global $gL10n, $gSettingsManager, $gCurrentSession;
        
                $formValues = $gSettingsManager->getAll();
        Severity: Major
        Found in src/UserInterface/Preferences.php - About 4 hrs to fix

          Method initialize has 115 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function initialize(): void
              {
                  global $gL10n;
          
                  $this->accordionCommonPanels = array(
          Severity: Major
          Found in src/UserInterface/Preferences.php - About 4 hrs to fix

            Method createCaptchaForm has 106 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function createCaptchaForm(): string
                {
                    global $gL10n, $gSettingsManager, $gCurrentSession;
            
                    $formValues = $gSettingsManager->getAll();
            Severity: Major
            Found in src/UserInterface/Preferences.php - About 4 hrs to fix

              Method createMessagesForm has 94 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function createMessagesForm(): string
                  {
                      global $gL10n, $gSettingsManager, $gCurrentSession;
              
                      $formValues = $gSettingsManager->getAll();
              Severity: Major
              Found in src/UserInterface/Preferences.php - About 3 hrs to fix

                Method createCommonForm has 89 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function createCommonForm(): string
                    {
                        global $gL10n, $gSettingsManager, $gCurrentSession;
                
                        $formValues = $gSettingsManager->getAll();
                Severity: Major
                Found in src/UserInterface/Preferences.php - About 3 hrs to fix

                  Method createSystemInformationForm has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function createSystemInformationForm(): string
                      {
                          global $gL10n, $gDb, $gLogger;
                  
                          $this->assignSmartyVariable('operatingSystemName', SystemInfoUtils::getOS());
                  Severity: Major
                  Found in src/UserInterface/Preferences.php - About 3 hrs to fix

                    Method createGroupsRolesForm has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function createGroupsRolesForm(): string
                        {
                            global $gL10n, $gSettingsManager, $gDb, $gCurrentOrgId, $gCurrentSession;
                    
                            $formValues = $gSettingsManager->getAll();
                    Severity: Major
                    Found in src/UserInterface/Preferences.php - About 3 hrs to fix

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

                          public function createSystemNotificationsForm(): string
                          {
                              global $gL10n, $gDb, $gSettingsManager, $gCurrentOrgId, $gCurrentSession;
                      
                              $formValues = $gSettingsManager->getAll();
                      Severity: Major
                      Found in src/UserInterface/Preferences.php - About 3 hrs to fix

                        Preferences has 27 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        class Preferences extends HtmlPage
                        {
                            /**
                             * @var array Array with all possible accordion entries for the system preferences.
                             *            Each accordion entry consists of an array that has the following structure:
                        Severity: Minor
                        Found in src/UserInterface/Preferences.php - About 3 hrs to fix

                          Method show has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function show()
                              {
                                  if ($this->preferencesPanelToShow !== '') {
                                      // open the modules tab if the options of a module should be shown
                                      if (array_key_exists($this->preferencesPanelToShow, $this->accordionModulePanels)) {
                          Severity: Major
                          Found in src/UserInterface/Preferences.php - About 2 hrs to fix

                            Method createGuestbookForm has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function createGuestbookForm(): string
                                {
                                    global $gL10n, $gSettingsManager, $gCurrentSession;
                            
                                    $formValues = $gSettingsManager->getAll();
                            Severity: Major
                            Found in src/UserInterface/Preferences.php - About 2 hrs to fix

                              Method createPHPForm has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function createPHPForm(): string
                                  {
                                      global $gL10n;
                              
                                      if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '<')) {
                              Severity: Major
                              Found in src/UserInterface/Preferences.php - About 2 hrs to fix

                                Method createOrganizationForm has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function createOrganizationForm(): string
                                    {
                                        global $gDb, $gL10n, $gCurrentOrganization, $gSettingsManager, $gCurrentOrgId, $gCurrentSession;
                                
                                        // read organization and all system preferences values into form array
                                Severity: Major
                                Found in src/UserInterface/Preferences.php - About 2 hrs to fix

                                  Method createContactsForm has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function createContactsForm(): string
                                      {
                                          global $gL10n, $gSettingsManager, $gDb, $gCurrentOrgId, $gCurrentSession;
                                  
                                          $formValues = $gSettingsManager->getAll();
                                  Severity: Major
                                  Found in src/UserInterface/Preferences.php - About 2 hrs to fix

                                    Method createProfileForm has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function createProfileForm(): string
                                        {
                                            global $gL10n, $gSettingsManager, $gCurrentOrganization, $gCurrentSession;
                                    
                                            $formValues = $gSettingsManager->getAll();
                                    Severity: Major
                                    Found in src/UserInterface/Preferences.php - About 2 hrs to fix

                                      Method createLinksForm has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public function createLinksForm(): string
                                          {
                                              global $gL10n, $gSettingsManager, $gCurrentSession;
                                      
                                              $formValues = $gSettingsManager->getAll();
                                      Severity: Major
                                      Found in src/UserInterface/Preferences.php - About 2 hrs to fix

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

                                            public function createRegionalSettingsForm(): string
                                            {
                                                global $gL10n, $gSettingsManager, $gTimezone, $gCurrentSession;
                                        
                                                $formValues = $gSettingsManager->getAll();
                                        Severity: Major
                                        Found in src/UserInterface/Preferences.php - About 2 hrs to fix

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

                                              public function createSystemInformationForm(): string
                                              {
                                                  global $gL10n, $gDb, $gLogger;
                                          
                                                  $this->assignSmartyVariable('operatingSystemName', SystemInfoUtils::getOS());
                                          Severity: Minor
                                          Found in src/UserInterface/Preferences.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 createSecurityForm has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              public function createSecurityForm(): string
                                              {
                                                  global $gL10n, $gSettingsManager, $gCurrentSession;
                                          
                                                  $formValues = $gSettingsManager->getAll();
                                          Severity: Minor
                                          Found in src/UserInterface/Preferences.php - About 1 hr to fix

                                            Method createRegistrationForm has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                public function createRegistrationForm(): string
                                                {
                                                    global $gL10n, $gSettingsManager, $gCurrentSession;
                                            
                                                    $formValues = $gSettingsManager->getAll();
                                            Severity: Minor
                                            Found in src/UserInterface/Preferences.php - About 1 hr to fix

                                              Method createAnnouncementsForm has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  public function createAnnouncementsForm(): string
                                                  {
                                                      global $gL10n, $gSettingsManager, $gCurrentSession;
                                              
                                                      $formValues = $gSettingsManager->getAll();
                                              Severity: Minor
                                              Found in src/UserInterface/Preferences.php - About 1 hr to fix

                                                Method createCategoryReportForm has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                    public function createCategoryReportForm(): string
                                                    {
                                                        global $gL10n, $gSettingsManager, $gDb, $gCurrentOrgId, $gCurrentSession;
                                                
                                                        $formValues = $gSettingsManager->getAll();
                                                Severity: Minor
                                                Found in src/UserInterface/Preferences.php - About 1 hr to fix

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

                                                      public function createPHPForm(): string
                                                      {
                                                          global $gL10n;
                                                  
                                                          if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '<')) {
                                                  Severity: Minor
                                                  Found in src/UserInterface/Preferences.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 createDocumentsFilesForm has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      public function createDocumentsFilesForm(): string
                                                      {
                                                          global $gL10n, $gSettingsManager, $gCurrentSession;
                                                  
                                                          $formValues = $gSettingsManager->getAll();
                                                  Severity: Minor
                                                  Found in src/UserInterface/Preferences.php - About 1 hr to fix

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                            $this->accordionCommonPanels = array(
                                                                'Common' => array(
                                                                    'id' => 'Common',
                                                                    'title' => $gL10n->get('SYS_COMMON'),
                                                                    'icon' => 'bi-gear-fill'
                                                    Severity: Major
                                                    Found in src/UserInterface/Preferences.php and 1 other location - About 1 day to fix
                                                    src/UserInterface/Preferences.php on lines 126..182

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 307.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                            $this->accordionModulePanels = array(
                                                                'Announcements' => array(
                                                                    'id' => 'Announcements',
                                                                    'title' => $gL10n->get('SYS_ANNOUNCEMENTS'),
                                                                    'icon' => 'bi-newspaper'
                                                    Severity: Major
                                                    Found in src/UserInterface/Preferences.php and 1 other location - About 1 day to fix
                                                    src/UserInterface/Preferences.php on lines 69..125

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 307.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                            if ($gSettingsManager->getBool('events_rooms_enabled')) {
                                                                $selectBoxEntries = array(
                                                                    'detail' => $gL10n->get('SYS_DETAILED'),
                                                                    'compact' => $gL10n->get('SYS_COMPACT'),
                                                                    'room' => $gL10n->get('SYS_COMPACT') . ' - ' . $gL10n->get('SYS_ROOM'),
                                                    Severity: Major
                                                    Found in src/UserInterface/Preferences.php and 1 other location - About 5 hrs to fix
                                                    adm_program/modules/events/events.php on lines 166..181

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 199.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    There are no issues that match your filters.

                                                    Category
                                                    Status