felixarntz/wp-site-identity

View on GitHub

Showing 247 of 247 total issues

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

( function( data ) {

    var typeRadios       = document.querySelectorAll( '#wpsi-owner-data-type input[type="radio"]' );
    var typeRadioChecked = document.querySelector( '#wpsi-owner-data-type input[type="radio"]:checked' );
    var colors           = document.querySelectorAll( '.form-table input[data-colorpicker]' );
Severity: Major
Found in assets/src/js/settings-page.js and 1 other location - About 1 wk to fix
assets/dist/js/settings-page.js on lines 6..180

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

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

( function( data ) {

    var typeRadios       = document.querySelectorAll( '#wpsi-owner-data-type input[type="radio"]' );
    var typeRadioChecked = document.querySelector( '#wpsi-owner-data-type input[type="radio"]:checked' );
    var colors           = document.querySelectorAll( '.form-table input[data-colorpicker]' );
Severity: Major
Found in assets/dist/js/settings-page.js and 1 other location - About 1 wk to fix
assets/src/js/settings-page.js on lines 1..175

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

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

( function( wp, _ ) {

    var Select = wp.media.view.MediaFrame.Select;
    var InsertFrame;

Severity: Major
Found in assets/dist/js/media-insert-frame.js and 1 other location - About 3 days to fix
assets/src/js/media-insert-frame.js on lines 1..78

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

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

( function( wp, _ ) {

    var Select = wp.media.view.MediaFrame.Select;
    var InsertFrame;

Severity: Major
Found in assets/src/js/media-insert-frame.js and 1 other location - About 3 days to fix
assets/dist/js/media-insert-frame.js on lines 6..83

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

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

( function( data ) {

    wp.customize.selectiveRefresh.partialConstructor.WPSiteIdentityPartial = wp.customize.selectiveRefresh.Partial.extend({
        initialize: function( id, options ) {
            if ( options && options.primarySetting && options.settings && 1 === options.settings.length && data.liveSettings.includes( options.primarySetting.replace( 'wpsi_owner_data[', '' ).replace( ']', '' ) ) ) {
Severity: Major
Found in assets/dist/js/customize-preview.js and 1 other location - About 1 day to fix
assets/src/js/customize-preview.js on lines 1..21

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

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

( function( data ) {

    wp.customize.selectiveRefresh.partialConstructor.WPSiteIdentityPartial = wp.customize.selectiveRefresh.Partial.extend({
        initialize: function( id, options ) {
            if ( options && options.primarySetting && options.settings && 1 === options.settings.length && data.liveSettings.includes( options.primarySetting.replace( 'wpsi_owner_data[', '' ).replace( ']', '' ) ) ) {
Severity: Major
Found in assets/src/js/customize-preview.js and 1 other location - About 1 day to fix
assets/dist/js/customize-preview.js on lines 6..26

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

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

( function( data ) {

    wp.customize.bind( 'ready', function() {

        wp.customize( 'wpsi_owner_data[type]', function( setting ) {
Severity: Major
Found in assets/dist/js/customize-controls.js and 1 other location - About 1 day to fix
assets/src/js/customize-controls.js on lines 1..39

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

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

( function( data ) {

    wp.customize.bind( 'ready', function() {

        wp.customize( 'wpsi_owner_data[type]', function( setting ) {
Severity: Major
Found in assets/src/js/customize-controls.js and 1 other location - About 1 day to fix
assets/dist/js/customize-controls.js on lines 6..44

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

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

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

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

        $type_choices = $this->bootstrap->get_type_choices();
Severity: Major
Found in src/class-wp-site-identity-bootstrap-settings.php - About 7 hrs to fix

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

    <?php
    /**
     * WP_Site_Identity_Bootstrap_Customizer class
     *
     * @package WPSiteIdentity
    Severity: Minor
    Found in src/class-wp-site-identity-bootstrap-customizer.php - About 4 hrs to fix

      Function format_address has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function format_address( $format, array $placeholders, array $placeholder_values ) {
              $formatted = str_replace( $placeholders, $placeholder_values, $format );
      
              $formatted_parts = array();
      
      
      Severity: Minor
      Found in src/class-wp-site-identity-owner-data.php - About 4 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 update has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function update( $new_instance, $old_instance ) {
              $instance = $old_instance;
      
              foreach ( $this->fields as $attr => $field ) {
                  switch ( $field['type'] ) {
      Severity: Minor
      Found in src/widgets/class-wp-site-identity-widget.php - About 4 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 set_default_control_args_for_setting has a Cognitive Complexity of 29 (exceeds 5 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: Minor
      Found in src/class-wp-site-identity-bootstrap-customizer.php - About 4 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 add_owner_data_content has 102 lines of code (exceeds 25 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: Major
      Found in src/class-wp-site-identity-bootstrap-customizer.php - About 4 hrs to fix

        Function form has a Cognitive Complexity of 26 (exceeds 5 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: Minor
        Found in src/widgets/class-wp-site-identity-widget.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

        The class WP_Site_Identity_Aggregate_Setting has 12 public methods. Consider refactoring WP_Site_Identity_Aggregate_Setting to keep number of public methods under 10.
        Open

        class WP_Site_Identity_Aggregate_Setting extends WP_Site_Identity_Setting implements WP_Site_Identity_Setting_Registry {
        
            /**
             * Prefix to use for all setting names within WordPress.
             *

        TooManyPublicMethods

        Since: 0.1

        A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

        By default it ignores methods starting with 'get' or 'set'.

        Example

        Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

        The class WP_Site_Identity_Standard_Setting_Registry has 11 public methods. Consider refactoring WP_Site_Identity_Standard_Setting_Registry to keep number of public methods under 10.
        Open

        class WP_Site_Identity_Standard_Setting_Registry implements WP_Site_Identity_Setting_Registry {
        
            /**
             * Prefix to use for all setting names within WordPress.
             *

        TooManyPublicMethods

        Since: 0.1

        A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

        By default it ignores methods starting with 'get' or 'set'.

        Example

        Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

        The class WP_Site_Identity_Bootstrap_Customizer has an overall complexity of 57 which is very high. The configured complexity threshold is 50.
        Open

        final class WP_Site_Identity_Bootstrap_Customizer {
        
            /**
             * Plugin bootstrap instance.
             *

        The class WP_Site_Identity_Widget has an overall complexity of 69 which is very high. The configured complexity threshold is 50.
        Open

        class WP_Site_Identity_Widget extends WP_Widget {
        
            /**
             * Render callback for the widget.
             *

        The class WP_Site_Identity_Settings_Field_Control_Callbacks has 12 public methods. Consider refactoring WP_Site_Identity_Settings_Field_Control_Callbacks to keep number of public methods under 10.
        Open

        final class WP_Site_Identity_Settings_Field_Control_Callbacks {
        
            /**
             * Renders a text control for a field.
             *

        TooManyPublicMethods

        Since: 0.1

        A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

        By default it ignores methods starting with 'get' or 'set'.

        Example

        Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

        Severity
        Category
        Status
        Source
        Language