felixarntz/wp-site-identity

View on GitHub

Showing 247 of 247 total issues

Method form has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function form( $instance ) {
        $instance = wp_parse_args( (array) $instance, $this->get_defaults() );

        foreach ( $this->fields as $attr => $field ) {
            $meta = $this->attrs( $field['meta'] );
Severity: Major
Found in src/widgets/class-wp-site-identity-widget.php - About 3 hrs to fix

    Function set_default_args_for_setting has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function set_default_args_for_setting( array $args, WP_Site_Identity_Setting $setting ) {
            $type = isset( $args['type'] ) ? $args['type'] : $setting->get_type();
    
            switch ( $type ) {
                case 'boolean':

    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 add_brand_data_content has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function add_brand_data_content( $wp_customize, $setting_registry, $panel_slug ) {
            $registry     = $setting_registry->get_setting( 'brand_data' );
            $data         = $this->plugin->brand_data();
            $section_slug = 'brand_data';
    
    
    Severity: Major
    Found in src/class-wp-site-identity-bootstrap-customizer.php - About 2 hrs to fix

      WP_Site_Identity_Settings_Field has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class WP_Site_Identity_Settings_Field {
      
          /**
           * Slug of the settings field.
           *

        Function render_site_identity_data_widget has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function render_site_identity_data_widget( $instance ) {
                $owner_data = $this->plugin->owner_data();
        
                $output = '';
        
        
        Severity: Minor
        Found in src/class-wp-site-identity-bootstrap-widgets.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 set_default_control_args_for_setting has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function set_default_control_args_for_setting( array $control_args, WP_Site_Identity_Setting $setting ) {
                $type = $setting->get_type();
        
                switch ( $type ) {
                    case 'boolean':
        Severity: Major
        Found in src/class-wp-site-identity-bootstrap-customizer.php - About 2 hrs to fix

          Method wpsi_load has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function wpsi_load() {
              $classes_dir = plugin_dir_path( __FILE__ ) . 'src/';
          
              // Main.
              require_once $classes_dir . 'class-wp-site-identity.php';
          Severity: Major
          Found in wp-site-identity.php - About 2 hrs to fix

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

                public function update( $new_instance, $old_instance ) {
                    $instance = $old_instance;
            
                    foreach ( $this->fields as $attr => $field ) {
                        switch ( $field['type'] ) {
            Severity: Major
            Found in src/widgets/class-wp-site-identity-widget.php - About 2 hrs to fix

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

                  public function action_init() {
                      $registry = $this->plugin->services()->get( 'shortcode_registry' );
                      $factory  = $registry->factory();
              
                      foreach ( $this->plugin->services()->get( 'setting_registry' )->get_all_settings() as $aggregate_setting ) {
              Severity: Major
              Found in src/class-wp-site-identity-bootstrap-shortcodes.php - About 2 hrs to fix

                File class-wp-site-identity-settings-field-control-callbacks.php has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * WP_Site_Identity_Settings_Field_Control_Callbacks class
                 *
                 * @package WPSiteIdentity

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

                      protected function attrs( $attrs ) {
                          $output = '';
                  
                          foreach ( $attrs as $attr => $value ) {
                              if ( is_bool( $value ) ) {
                  Severity: Minor
                  Found in src/widgets/class-wp-site-identity-widget.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

                  File class-wp-site-identity-widget.php has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * WP_Site_Identity_Widget class
                   *
                   * @package WPSiteIdentity
                  Severity: Minor
                  Found in src/widgets/class-wp-site-identity-widget.php - About 2 hrs to fix

                    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 set_default_args_for_setting has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function set_default_args_for_setting( array $args, WP_Site_Identity_Setting $setting ) {
                              $type = isset( $args['type'] ) ? $args['type'] : $setting->get_type();
                      
                              switch ( $type ) {
                                  case 'boolean':

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

                            protected function validate_value( $value, $args ) {
                                if ( empty( $args['type'] ) ) {
                                    return $value;
                                }
                        
                        
                        Severity: Major
                        Found in src/settings/class-wp-site-identity-setting-validator.php and 1 other location - About 1 hr to fix
                        src/settings/class-wp-site-identity-setting-sanitizer.php on lines 67..87

                        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 118.

                        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

                            protected function sanitize_value( $value, $args ) {
                                if ( empty( $args['type'] ) ) {
                                    return $value;
                                }
                        
                        
                        Severity: Major
                        Found in src/settings/class-wp-site-identity-setting-sanitizer.php and 1 other location - About 1 hr to fix
                        src/settings/class-wp-site-identity-setting-validator.php on lines 72..92

                        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 118.

                        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

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

                            public function render_number_control( $value, WP_Site_Identity_Settings_Field $field ) {
                                $attrs = $this->make_base_attrs( $field, array(
                                    'check_description' => true,
                                ) );
                                $props = $this->make_base_props( $field );

                        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_url_to_admin_page has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function get_url_to_admin_page( WP_Site_Identity_Admin_Page $admin_page ) {
                                $slug = $admin_page->get_slug();
                        
                                $query_args = array();
                        
                        

                        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 action_init has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function action_init() {
                                $registry = $this->plugin->services()->get( 'shortcode_registry' );
                                $factory  = $registry->factory();
                        
                                foreach ( $this->plugin->services()->get( 'setting_registry' )->get_all_settings() as $aggregate_setting ) {
                        Severity: Minor
                        Found in src/class-wp-site-identity-bootstrap-shortcodes.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

                        Avoid excessively long class names like WP_Site_Identity_Settings_Form_Not_Found_Exception. Keep class name length under 40.
                        Open

                        class WP_Site_Identity_Settings_Form_Not_Found_Exception extends Exception {
                        
                        }

                        LongClassName

                        Since: 2.9

                        Detects when classes or interfaces are declared with excessively long names.

                        Example

                        class ATooLongClassNameThatHintsAtADesignProblem {
                        
                        }
                        
                        interface ATooLongInterfaceNameThatHintsAtADesignProblem {
                        
                        }

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

                        Severity
                        Category
                        Status
                        Source
                        Language