rilwis/meta-box

View on GitHub
inc/fields/icon.php

Summary

Maintainability
A
3 hrs
Test Coverage

Method normalize_icon has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function normalize_icon( array $field, $key, $icon ): array {
        // Default: Font Awesome Free.
        if ( $field['icon_set'] === 'font-awesome-free' ) {
            $style = $icon['styles'][0];
            return [
Severity: Minor
Found in inc/fields/icon.php - About 1 hr to fix

    Function normalize_icon has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function normalize_icon( array $field, $key, $icon ): array {
            // Default: Font Awesome Free.
            if ( $field['icon_set'] === 'font-awesome-free' ) {
                $style = $icon['styles'][0];
                return [
    Severity: Minor
    Found in inc/fields/icon.php - About 45 mins 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 too many return statements within this method.
    Open

            return [
                'value' => $icon,
                'label' => $icon,
                'svg'   => '',
            ];
    Severity: Major
    Found in inc/fields/icon.php - About 30 mins to fix

      Function normalize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function normalize( $field ) {
              $field = wp_parse_args( $field, [
                  'placeholder'     => __( 'Select an icon', 'meta-box' ),
                  'icon_css'        => '',
                  'icon_set'        => '',
      Severity: Minor
      Found in inc/fields/icon.php - About 25 mins 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

      There are no issues that match your filters.

      Category
      Status