felixarntz/wp-site-identity

View on GitHub

Showing 247 of 247 total issues

Function openImageMediaModal has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function openImageMediaModal() {
        var field        = document.getElementById( this.dataset.target );
        var preview      = document.getElementById( this.dataset.target + '-preview' );
        var selectButton = this;
        var deleteButton = document.getElementById( this.dataset.target + '-delete-button' );
Severity: Minor
Found in assets/dist/js/settings-page.js - About 1 hr to fix

    Function openImageMediaModal has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function openImageMediaModal() {
            var field        = document.getElementById( this.dataset.target );
            var preview      = document.getElementById( this.dataset.target + '-preview' );
            var selectButton = this;
            var deleteButton = document.getElementById( this.dataset.target + '-delete-button' );
    Severity: Minor
    Found in assets/src/js/settings-page.js - About 1 hr to fix

      Method render_site_identity_data_widget has 37 lines of code (exceeds 25 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 1 hr to fix

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

            protected function set_default_default_for_type( array $args ) {
                $type = isset( $args['type'] ) ? $args['type'] : '';
                $min  = isset( $args['min'] ) ? $args['min'] : false;
        
                switch ( $type ) {
        Severity: Minor
        Found in src/settings/class-wp-site-identity-setting-factory.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 add_owner_data_content has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            private function add_owner_data_content( $wp_customize, $setting_registry, $panel_slug ) {
                $registry     = $setting_registry->get_setting( 'owner_data' );
                $data         = $this->plugin->owner_data();
                $section_slug = 'owner_data';
        
        
        Severity: Minor
        Found in src/class-wp-site-identity-bootstrap-customizer.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 __construct has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct( WP_Site_Identity_Setting $setting, array $args = array(), WP_Site_Identity_Settings_Field_Registry $registry = null ) {
                $this->slug    = $setting->get_name();
                $this->setting = $setting;
        
                if ( ! empty( $args['title'] ) ) {

          Method render_number_control has 32 lines of code (exceeds 25 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 );

            Function __construct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public function __construct( WP_Site_Identity_Setting $setting, array $args = array(), WP_Site_Identity_Settings_Field_Registry $registry = null ) {
                    $this->slug    = $setting->get_name();
                    $this->setting = $setting;
            
                    if ( ! empty( $args['title'] ) ) {

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

                public function validate( $data ) {
                    if ( $data instanceof stdClass ) {
                        $data = (array) $data;
                    }
            
            
            Severity: Minor
            Found in src/settings/class-wp-site-identity-aggregate-setting.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 add_brand_data_content has a Cognitive Complexity of 11 (exceeds 5 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: Minor
            Found in src/class-wp-site-identity-bootstrap-customizer.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_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

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

                  public function validate( $data ) {
                      if ( $data instanceof stdClass ) {
                          $data = (array) $data;
                      }
              
              
              Severity: Minor
              Found in src/settings/class-wp-site-identity-aggregate-setting.php - About 1 hr to fix

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

                    public function get( $name ) {
                        switch ( $name ) {
                            case 'primary_shade_color':
                            case 'secondary_shade_color':
                            case 'tertiary_shade_color':
                Severity: Minor
                Found in src/class-wp-site-identity-brand-data.php - About 1 hr to fix

                  Avoid using undefined variables such as '$meta' which will lead to PHP notices.
                  Open

                                      if ( ! empty( $meta['multiple'] ) ) {

                  UndefinedVariable

                  Since: 2.8.0

                  Detects when a variable is used that has not been defined before.

                  Example

                  class Foo
                  {
                      private function bar()
                      {
                          // $message is undefined
                          echo $message;
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                  Method set_default_default_for_type has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function set_default_default_for_type( array $args ) {
                          $type = isset( $args['type'] ) ? $args['type'] : '';
                          $min  = isset( $args['min'] ) ? $args['min'] : false;
                  
                          switch ( $type ) {
                  Severity: Minor
                  Found in src/settings/class-wp-site-identity-setting-factory.php - About 1 hr to fix

                    Method build_rest_schema_for_wp has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function build_rest_schema_for_wp( WP_Site_Identity_Setting $setting ) {
                            $default_schema = array(
                                'type'        => $setting->get_type(),
                                'description' => $setting->get_description(),
                                'default'     => $setting->get_default(),
                    Severity: Minor
                    Found in src/settings/class-wp-site-identity-standard-setting-registry.php - About 1 hr to fix

                      Function initializeImageField has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function initializeImageField( field ) {
                              var selectButton = document.createElement( 'button' );
                              var deleteButton = document.createElement( 'button' );
                              var value        = parseInt( field.value, 10 );
                              var attachment   = document.getElementById( field.id + '-attachment-data' );
                      Severity: Minor
                      Found in assets/src/js/settings-page.js - About 1 hr to fix

                        Method get_as_html has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function get_as_html( $name ) {
                                switch ( $name ) {
                                    case 'phone_link':
                                    case 'email_link':
                                    case 'website_link':
                        Severity: Minor
                        Found in src/class-wp-site-identity-owner-data.php - About 1 hr to fix

                          Method wpsi_requirements_notice has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function wpsi_requirements_notice() {
                              $plugin_file = plugin_basename( __FILE__ );
                          
                              // WordPress before 4.9 didn't have a dedicated capability for this.
                              if ( version_compare( $GLOBALS['wp_version'], '4.9', '<' ) ) {
                          Severity: Minor
                          Found in wp-site-identity.php - About 1 hr to fix

                            Function initializeImageField has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function initializeImageField( field ) {
                                    var selectButton = document.createElement( 'button' );
                                    var deleteButton = document.createElement( 'button' );
                                    var value        = parseInt( field.value, 10 );
                                    var attachment   = document.getElementById( field.id + '-attachment-data' );
                            Severity: Minor
                            Found in assets/dist/js/settings-page.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language