felixarntz/wp-site-identity

View on GitHub
src/class-wp-site-identity-bootstrap-admin-pages.php

Summary

Maintainability
B
6 hrs
Test Coverage

Method action_handle_settings_page has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function action_handle_settings_page() {
        $setting_registry = $this->plugin->services()->get( 'setting_registry' );

        $factory = $this->plugin->services()->get( 'settings_form_registry' )->factory();

Severity: Minor
Found in src/class-wp-site-identity-bootstrap-admin-pages.php - About 1 hr to fix

    Method action_render_settings_page has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function action_render_settings_page( $admin_page ) {
            if ( ! is_a( $admin_page, 'WP_Site_Identity_Admin_Submenu_Page' ) || 'options-general.php' !== $admin_page->get_parent_slug() ) {
                require ABSPATH . 'wp-admin/options-head.php';
            }
    
    
    Severity: Minor
    Found in src/class-wp-site-identity-bootstrap-admin-pages.php - About 1 hr to fix

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

          public function action_handle_settings_page() {
              $setting_registry = $this->plugin->services()->get( 'setting_registry' );
      
              $factory = $this->plugin->services()->get( 'settings_form_registry' )->factory();
      
      
      Severity: Minor
      Found in src/class-wp-site-identity-bootstrap-admin-pages.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 action_enqueue_settings_page has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function action_enqueue_settings_page() {
              $dependencies = array();
              $l10n         = array();
      
              $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
      Severity: Minor
      Found in src/class-wp-site-identity-bootstrap-admin-pages.php - About 1 hr to fix

        Function action_render_settings_page has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function action_render_settings_page( $admin_page ) {
                if ( ! is_a( $admin_page, 'WP_Site_Identity_Admin_Submenu_Page' ) || 'options-general.php' !== $admin_page->get_parent_slug() ) {
                    require ABSPATH . 'wp-admin/options-head.php';
                }
        
        
        Severity: Minor
        Found in src/class-wp-site-identity-bootstrap-admin-pages.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

        Function get_current_tab has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function get_current_tab( array $settings_forms = null ) {
                if ( null === $settings_forms ) {
                    $settings_forms = $this->plugin->services()->get( 'settings_form_registry' )->get_all_forms();
                }
        
        
        Severity: Minor
        Found in src/class-wp-site-identity-bootstrap-admin-pages.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

        Avoid excessively long variable names like $brand_data_field_slug. Keep variable name length under 20.
        Open

                    foreach ( $brand_data_section['fields'] as $brand_data_field_slug ) {

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Avoid excessively long variable names like $owner_data_field_slug. Keep variable name length under 20.
        Open

                    foreach ( $owner_data_section['fields'] as $owner_data_field_slug ) {

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        There are no issues that match your filters.

        Category
        Status