felixarntz/wpdlib

View on GitHub
inc/WPDLib/Components/Manager.php

Summary

Maintainability
D
1 day
Test Coverage

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

        private static function get_components_results( $component_path, $current_children, $class_path_children ) {
            $results = array();

            if ( '*' == $component_path[0] ) {
                if ( isset( $component_path[1] ) ) {
Severity: Minor
Found in inc/WPDLib/Components/Manager.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 get has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        public static function get( $component_path, $class_path = '', $single = false ) {
            $component_path = explode( '.', $component_path, 2 );
            $class_path = explode( '.', $class_path, 2 );

            $toplevel_components = array();
Severity: Minor
Found in inc/WPDLib/Components/Manager.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 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        public static function add( $component ) {
            if ( self::is_too_late() ) {
                return new UtilError( 'too_late_component', sprintf( __( 'Components must not be added later than the %s hook.', 'wpdlib' ), '<code>init</code>' ), '', self::$current_scope );
            }

Severity: Minor
Found in inc/WPDLib/Components/Manager.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 get_dependency_info has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        public static function get_dependency_info( $dependency, $field = '' ) {
            $bower_file = self::get_base_dir() . '/assets/vendor/' . $dependency . '/.bower.json';
            if ( ! file_exists( $bower_file ) ) {
                $bower_file = self::get_base_dir() . '/assets/vendor/' . $dependency . '/bower.json';
            }
Severity: Minor
Found in inc/WPDLib/Components/Manager.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 exists has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        public static function exists( $slug, $class, $check_slug = '' ) {
            if ( ! isset( self::$component_finder[ $class ] ) ) {
                self::$component_finder[ $class ] = array();
            }

Severity: Minor
Found in inc/WPDLib/Components/Manager.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 get_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        public static function get_info( $field = '' ) {
            $composer_file = self::get_base_dir() . '/composer.json';
            if ( ! file_exists( $composer_file ) ) {
                if ( ! empty( $field ) ) {
                    return false;
Severity: Minor
Found in inc/WPDLib/Components/Manager.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 register_hierarchy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        public static function register_hierarchy( $hierarchy, $toplevel = true ) {
            foreach ( $hierarchy as $class => $children ) {
                if ( $toplevel && ! in_array( $class, self::$hierarchy_toplevel ) ) {
                    self::$hierarchy_toplevel[] = $class;
                }
Severity: Minor
Found in inc/WPDLib/Components/Manager.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

Avoid too many return statements within this method.
Open

            return $component;
Severity: Major
Found in inc/WPDLib/Components/Manager.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return new UtilError( 'no_valid_slug_component', sprintf( __( 'A component of class %1$s with slug %2$s already exists.', 'wpdlib' ), $component_class, $component->slug ), '', self::$current_scope );
    Severity: Major
    Found in inc/WPDLib/Components/Manager.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return self::merge_components( self::$components[ $component_class ][ $component->slug ], $component );
      Severity: Major
      Found in inc/WPDLib/Components/Manager.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $info;
        Severity: Major
        Found in inc/WPDLib/Components/Manager.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return $info;
          Severity: Major
          Found in inc/WPDLib/Components/Manager.php - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status