felixarntz/theme-boilerplate

View on GitHub
inc/library/widgets/class-widget.php

Summary

Maintainability
D
1 day
Test Coverage

Method render_form_field has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function render_form_field( $id, $args, $value ) {
        $control_id     = $this->get_field_id( $id );
        $control_name   = $this->get_field_name( $id );
        $type           = $args[ self::FIELD_ARG_TYPE ];
        $title          = $args[ self::FIELD_ARG_TITLE ];
Severity: Major
Found in inc/library/widgets/class-widget.php - About 3 hrs to fix

    File class-widget.php has 275 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Super_Awesome_Theme_Widget class
     *
     * @package Super_Awesome_Theme
    Severity: Minor
    Found in inc/library/widgets/class-widget.php - About 2 hrs to fix

      Function render_form_field has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function render_form_field( $id, $args, $value ) {
              $control_id     = $this->get_field_id( $id );
              $control_name   = $this->get_field_name( $id );
              $type           = $args[ self::FIELD_ARG_TYPE ];
              $title          = $args[ self::FIELD_ARG_TITLE ];
      Severity: Minor
      Found in inc/library/widgets/class-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

      Function add_field has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function add_field( $id, array $args = array() ) {
              if ( ! isset( $args[ self::FIELD_ARG_TYPE ] ) ) {
                  $args[ self::FIELD_ARG_TYPE ] = self::FIELD_TYPE_TEXT;
              }
      
      
      Severity: Minor
      Found in inc/library/widgets/class-widget.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 add_field has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function add_field( $id, array $args = array() ) {
              if ( ! isset( $args[ self::FIELD_ARG_TYPE ] ) ) {
                  $args[ self::FIELD_ARG_TYPE ] = self::FIELD_TYPE_TEXT;
              }
      
      
      Severity: Minor
      Found in inc/library/widgets/class-widget.php - About 1 hr to fix

        Function default_sanitize_callback has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function default_sanitize_callback( $value, $args ) {
                switch ( $args[ self::FIELD_ARG_TYPE ] ) {
                    case self::FIELD_TYPE_NUMBER:
                        if ( isset( $args[ self::FIELD_ARG_INPUT_ATTRS ]['step'] ) && is_int( $args[ self::FIELD_ARG_INPUT_ATTRS ]['step'] ) ) {
                            $value = (int) $value;
        Severity: Minor
        Found in inc/library/widgets/class-widget.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 default_sanitize_callback has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function default_sanitize_callback( $value, $args ) {
                switch ( $args[ self::FIELD_ARG_TYPE ] ) {
                    case self::FIELD_TYPE_NUMBER:
                        if ( isset( $args[ self::FIELD_ARG_INPUT_ATTRS ]['step'] ) && is_int( $args[ self::FIELD_ARG_INPUT_ATTRS ]['step'] ) ) {
                            $value = (int) $value;
        Severity: Minor
        Found in inc/library/widgets/class-widget.php - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status