deep-web-solutions/wordpress-framework-settings

View on GitHub

Showing 13 of 13 total issues

Function exports has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function( grunt ) {
    'use strict';

    // Load all grunt tasks matching the `grunt-*` pattern
    require( 'load-grunt-tasks' )( grunt );
Severity: Major
Found in Gruntfile.js - About 3 hrs to fix

    Method register_submenu_page has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function register_submenu_page( string $parent_slug, $page_title, $menu_title, string $menu_slug, string $capability, array $params = array() ): ?string {
            $page_title = Strings::resolve( $page_title );
            $menu_title = Strings::resolve( $menu_title );
            $params     = \wp_parse_args(
                $params,
    Severity: Minor
    Found in src/includes/Adapters/WordPressSettingsAdapter.php - About 1 hr to fix

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

          public function register_options_group( string $group_id, $group_title, $fields, string $page, array $params ) {
              if ( $this->is_run( SettingsActionsEnum::REGISTER_OPTIONS_GROUP ) || \did_action( $this->get_action_hook( SettingsActionsEnum::REGISTER_OPTIONS_GROUP ) ) ) {
                  return $this->array_walk_register_action( \get_defined_vars(), -1, SettingsActionsEnum::REGISTER_OPTIONS_GROUP );
              } else {
                  $this->options_groups[] = \get_defined_vars();
      Severity: Major
      Found in src/includes/AbstractSettingsHandler.php and 3 other locations - About 1 hr to fix
      src/includes/AbstractSettingsHandler.php on lines 260..268
      src/includes/AbstractSettingsHandler.php on lines 308..316
      src/includes/AbstractSettingsHandler.php on lines 324..332

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

      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 4 locations. Consider refactoring.
      Open

          public function register_generic_group( string $group_id, $group_title, $fields, array $locations, array $params ) {
              if ( $this->is_run( SettingsActionsEnum::REGISTER_GENERIC_GROUP ) || \did_action( $this->get_action_hook( SettingsActionsEnum::REGISTER_GENERIC_GROUP ) ) ) {
                  return $this->array_walk_register_action( \get_defined_vars(), -1, SettingsActionsEnum::REGISTER_GENERIC_GROUP );
              } else {
                  $this->generic_groups[] = \get_defined_vars();
      Severity: Major
      Found in src/includes/AbstractSettingsHandler.php and 3 other locations - About 1 hr to fix
      src/includes/AbstractSettingsHandler.php on lines 260..268
      src/includes/AbstractSettingsHandler.php on lines 292..300
      src/includes/AbstractSettingsHandler.php on lines 324..332

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

      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 4 locations. Consider refactoring.
      Open

          public function register_menu_page( $page_title, $menu_title, string $menu_slug, string $capability, array $params ) {
              if ( $this->is_run( SettingsActionsEnum::REGISTER_MENU_PAGE ) || \did_action( $this->get_action_hook( SettingsActionsEnum::REGISTER_MENU_PAGE ) ) ) {
                  return $this->array_walk_register_action( \get_defined_vars(), -1, SettingsActionsEnum::REGISTER_MENU_PAGE );
              } else {
                  $this->menu_pages[] = \get_defined_vars();
      Severity: Major
      Found in src/includes/AbstractSettingsHandler.php and 3 other locations - About 1 hr to fix
      src/includes/AbstractSettingsHandler.php on lines 292..300
      src/includes/AbstractSettingsHandler.php on lines 308..316
      src/includes/AbstractSettingsHandler.php on lines 324..332

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

      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 4 locations. Consider refactoring.
      Open

          public function register_field( string $group_id, string $field_id, $field_title, string $field_type, array $params ) {
              if ( $this->is_run( SettingsActionsEnum::REGISTER_FIELD ) || \did_action( $this->get_action_hook( SettingsActionsEnum::REGISTER_FIELD ) ) ) {
                  return $this->array_walk_register_action( \get_defined_vars(), -1, SettingsActionsEnum::REGISTER_FIELD );
              } else {
                  $this->fields[] = \get_defined_vars();
      Severity: Major
      Found in src/includes/AbstractSettingsHandler.php and 3 other locations - About 1 hr to fix
      src/includes/AbstractSettingsHandler.php on lines 260..268
      src/includes/AbstractSettingsHandler.php on lines 292..300
      src/includes/AbstractSettingsHandler.php on lines 308..316

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

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

          public function register_submenu_page( string $parent_slug, $page_title, $menu_title, string $menu_slug, string $capability, array $params = array() ): ?string {
              $page_title = Strings::resolve( $page_title );
              $menu_title = Strings::resolve( $menu_title );
              $params     = \wp_parse_args(
                  $params,
      Severity: Minor
      Found in src/includes/Adapters/WordPressSettingsAdapter.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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function run(): ?RunFailureException {
              foreach ( SettingsActionsEnum::get_all() as $action ) {
                  $hook = $this->get_action_hook( $action );
                  if ( \doing_action( $hook ) && \is_null( $this->is_run( $action ) ) ) {
                      switch ( $action ) {
      Severity: Minor
      Found in src/includes/AbstractSettingsHandler.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 run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function run(): ?RunFailureException {
              foreach ( SettingsActionsEnum::get_all() as $action ) {
                  $hook = $this->get_action_hook( $action );
                  if ( \doing_action( $hook ) && \is_null( $this->is_run( $action ) ) ) {
                      switch ( $action ) {
      Severity: Minor
      Found in src/includes/AbstractSettingsHandler.php - About 1 hr to fix

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

        <?php
        
        namespace DeepWebSolutions\Framework\Settings\Handlers;
        
        use DeepWebSolutions\Framework\Settings\AbstractSettingsHandler;
        Severity: Minor
        Found in src/includes/Handlers/MetaBoxSettingsHandler.php and 1 other location - About 1 hr to fix
        src/includes/Handlers/ACFSettingsHandler.php on lines 1..55

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

        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

        <?php
        
        namespace DeepWebSolutions\Framework\Settings\Handlers;
        
        use DeepWebSolutions\Framework\Settings\AbstractSettingsHandler;
        Severity: Minor
        Found in src/includes/Handlers/ACFSettingsHandler.php and 1 other location - About 1 hr to fix
        src/includes/Handlers/MetaBoxSettingsHandler.php on lines 1..55

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

        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

            public function maybe_get_validated_option_value( $value, string $field_id ) {
                $return = $value;
        
                if ( \is_null( $return ) ) {
                    $field_prefix = Strings::maybe_suffix( $this->get_group_name(), '/' );
        src/includes/Functionalities/AbstractOptionsGroupFunctionality.php on lines 175..186

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

        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

            public function maybe_get_option_value( $value, string $field_id ) {
                $return = $value;
        
                if ( \is_null( $return ) ) {
                    $field_prefix = Strings::maybe_suffix( $this->get_group_name(), '/' );
        src/includes/Functionalities/AbstractValidatedOptionsGroupFunctionality.php on lines 165..176

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

        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

        Severity
        Category
        Status
        Source
        Language