felixarntz/wp-site-identity

View on GitHub
src/settings/class-wp-site-identity-aggregate-setting.php

Summary

Maintainability
A
3 hrs
Test Coverage

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

Function validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( $data ) {
        if ( $data instanceof stdClass ) {
            $data = (array) $data;
        }

Severity: Minor
Found in src/settings/class-wp-site-identity-aggregate-setting.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 validate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function validate( $data ) {
        if ( $data instanceof stdClass ) {
            $data = (array) $data;
        }

Severity: Minor
Found in src/settings/class-wp-site-identity-aggregate-setting.php - About 1 hr to fix

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

        protected function generate_schema_for_setting( $setting ) {
            $base_schema = array(
                'type'        => $setting->get_type(),
                'description' => $setting->get_description(),
                'default'     => $setting->get_default(),
    Severity: Minor
    Found in src/settings/class-wp-site-identity-aggregate-setting.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

    Missing class import via use statement (line '278', column '14').
    Open

                throw new WP_Site_Identity_Setting_Validation_Error_Exception( sprintf( __( '%1$s is not of type %2$s.', 'wp-site-identity' ), $data, 'object' ) );

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '134', column '14').
    Open

                throw new WP_Site_Identity_Setting_Not_Found_Exception( sprintf( __( 'The setting with the name %s could not be found.', 'wp-site-identity' ), $name ) );

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '98', column '14').
    Open

                throw new WP_Site_Identity_Setting_Not_Found_Exception( sprintf( __( 'The setting with the name %s could not be found.', 'wp-site-identity' ), $name ) );

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '66', column '24').
    Open

            $this->factory = new WP_Site_Identity_Setting_Factory( $this );

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    TODO found
    Open

            // TODO: Make sure the REST Schema and default get updated in WordPress.

    TODO found
    Open

            // TODO: Make sure the REST Schema and default get updated in WordPress.

    There are no issues that match your filters.

    Category
    Status