lesterchan/wp-sweep

View on GitHub
inc/class-wpsweep-api.php

Summary

Maintainability
A
1 hr
Test Coverage

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

    public function __construct() {
        add_action(
            'rest_api_init', function() {
                register_rest_route(
                    $this->namespace, 'count/(?P<name>\w+)', array(
Severity: Minor
Found in inc/class-wpsweep-api.php - About 1 hr to fix

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

            return new WP_REST_Response(
    Severity: Minor
    Found in inc/class-wpsweep-api.php by phpmd

    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 '137', column '14').
    Open

            return new WP_REST_Response(
    Severity: Minor
    Found in inc/class-wpsweep-api.php by phpmd

    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 '161', column '14').
    Open

            return new WP_REST_Response(
    Severity: Minor
    Found in inc/class-wpsweep-api.php by phpmd

    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

    Avoid using static access to class 'WPSweep' in method 'sweep'.
    Open

            $sweep   = WPSweep::get_instance();
    Severity: Minor
    Found in inc/class-wpsweep-api.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class 'WPSweep' in method 'details'.
    Open

            $sweep   = WPSweep::get_instance();
    Severity: Minor
    Found in inc/class-wpsweep-api.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class 'WPSweep' in method 'count'.
    Open

            $sweep = WPSweep::get_instance();
    Severity: Minor
    Found in inc/class-wpsweep-api.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    The class WPSweep_Api is not named in CamelCase.
    Open

    class WPSweep_Api {
        /**
         * WP-Sweep WP Rest API namespace
         *
         * @var string
    Severity: Minor
    Found in inc/class-wpsweep-api.php by phpmd

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

    The method is_sweep_name_valid is not named in camelCase.
    Open

        public function is_sweep_name_valid( $name ) {
            return in_array( $name, $this->sweeps, true );
        }
    Severity: Minor
    Found in inc/class-wpsweep-api.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    The method permission_check is not named in camelCase.
    Open

        public function permission_check() {
            return current_user_can( 'activate_plugins' );
        }
    Severity: Minor
    Found in inc/class-wpsweep-api.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status