symphonycms/symphony-2

View on GitHub
symphony/lib/toolkit/class.administrationpage.php

Summary

Maintainability
F
6 days
Test Coverage

File class.administrationpage.php has 684 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * @package toolkit
 */
Severity: Major
Found in symphony/lib/toolkit/class.administrationpage.php - About 1 day to fix

    Function appendNavigation has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

        public function appendNavigation()
        {
            $nav = $this->getNavigationArray();
    
            /**
    Severity: Minor
    Found in symphony/lib/toolkit/class.administrationpage.php - About 6 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

    AdministrationPage has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class AdministrationPage extends HTMLPage
    {
        /**
         * An array of `Alert` objects used to display page level
         * messages to Symphony backend users one by one. Prior to Symphony 2.3
    Severity: Minor
    Found in symphony/lib/toolkit/class.administrationpage.php - About 4 hrs to fix

      Method build has 102 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function build(array $context = [])
          {
              parent::build($context);
      
              if (!$this->canAccessPage()) {
      Severity: Major
      Found in symphony/lib/toolkit/class.administrationpage.php - About 4 hrs to fix

        Function canAccessPage has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public function canAccessPage()
            {
                $nav = $this->getNavigationArray();
                $page = '/' . trim(getCurrentPage(), '/') . '/';
        
        
        Severity: Minor
        Found in symphony/lib/toolkit/class.administrationpage.php - About 3 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 buildExtensionsNavigation has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            private function buildExtensionsNavigation(&$nav)
            {
                // Loop over all the installed extensions to add in other navigation items
                $extensions = Symphony::ExtensionManager()->listInstalledHandles();
        
        
        Severity: Minor
        Found in symphony/lib/toolkit/class.administrationpage.php - About 3 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 appendNavigation has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function appendNavigation()
            {
                $nav = $this->getNavigationArray();
        
                /**
        Severity: Major
        Found in symphony/lib/toolkit/class.administrationpage.php - About 2 hrs to fix

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

              private function buildXmlNavigation(&$nav)
              {
                  $xml = simplexml_load_file(ASSETS . '/xml/navigation.xml');
          
                  // Loop over the default Symphony navigation file, converting
          Severity: Minor
          Found in symphony/lib/toolkit/class.administrationpage.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 canAccessPage has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function canAccessPage()
              {
                  $nav = $this->getNavigationArray();
                  $page = '/' . trim(getCurrentPage(), '/') . '/';
          
          
          Severity: Minor
          Found in symphony/lib/toolkit/class.administrationpage.php - About 1 hr to fix

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

                private function buildExtensionsNavigation(&$nav)
                {
                    // Loop over all the installed extensions to add in other navigation items
                    $extensions = Symphony::ExtensionManager()->listInstalledHandles();
            
            
            Severity: Minor
            Found in symphony/lib/toolkit/class.administrationpage.php - About 1 hr to fix

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

                  private function buildSectionNavigation(&$nav)
                  {
                      // Build the section navigation, grouped by their navigation groups
                      $sections = (new SectionManager)->select()->sort('sortorder')->execute()->rows();
              
              
              Severity: Minor
              Found in symphony/lib/toolkit/class.administrationpage.php - About 1 hr to fix

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

                    private static function __findActiveNavigationGroup(array &$nav, $pageroot, $pattern = false)
                    {
                        foreach ($nav as $index => $contents) {
                            if (is_array($contents['children']) && !empty($contents['children'])) {
                                foreach ($contents['children'] as $item) {
                Severity: Minor
                Found in symphony/lib/toolkit/class.administrationpage.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 addTimestampValidationPageAlert has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function addTimestampValidationPageAlert($errorMessage, $existingObject, $action)
                    {
                        $authorId = $existingObject->get('modification_author_id');
                        if (!$authorId) {
                            $authorId = $existingObject->get('author_id');
                Severity: Minor
                Found in symphony/lib/toolkit/class.administrationpage.php - About 1 hr to fix

                  Method buildXmlNavigation has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function buildXmlNavigation(&$nav)
                      {
                          $xml = simplexml_load_file(ASSETS . '/xml/navigation.xml');
                  
                          // Loop over the default Symphony navigation file, converting
                  Severity: Minor
                  Found in symphony/lib/toolkit/class.administrationpage.php - About 1 hr to fix

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

                        public function build(array $context = [])
                        {
                            parent::build($context);
                    
                            if (!$this->canAccessPage()) {
                    Severity: Minor
                    Found in symphony/lib/toolkit/class.administrationpage.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 doesAuthorHaveAccess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function doesAuthorHaveAccess($item_limit = null)
                        {
                            $can_access = false;
                    
                            if (!isset($item_limit) || $item_limit === 'author') {
                    Severity: Minor
                    Found in symphony/lib/toolkit/class.administrationpage.php - About 45 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

                    Consider simplifying this complex logical expression.
                    Open

                            if (!isset($item_limit) || $item_limit === 'author') {
                                $can_access = true;
                            } elseif ($item_limit === 'developer' && Symphony::Author()->isDeveloper()) {
                                $can_access = true;
                            } elseif ($item_limit === 'manager' && (Symphony::Author()->isManager() || Symphony::Author()->isDeveloper())) {
                    Severity: Major
                    Found in symphony/lib/toolkit/class.administrationpage.php - About 40 mins to fix

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

                          private function appendBodyAttributes(array $context = array())
                          {
                              foreach ($context as $key => $value) {
                                  if (is_numeric($value)) {
                                      $key = 'id';
                      Severity: Minor
                      Found in symphony/lib/toolkit/class.administrationpage.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 __switchboard has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function __switchboard($type = 'view')
                          {
                              if (!isset($this->_context['action']) || trim($this->_context['action']) === '') {
                                  $action = 'index';
                              } else {
                      Severity: Minor
                      Found in symphony/lib/toolkit/class.administrationpage.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