bueltge/must-use-loader

View on GitHub

Showing 17 of 17 total issues

Method list_subdir_mu_plugins has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function list_subdir_mu_plugins() {

        foreach ( $this->plugins as $plugin_file ) {
            $plugin_data = $this->filter_plugin_data( $plugin_file );

Severity: Minor
Found in must_use_loader.php - About 1 hr to fix

    Filenames should be all lowercase with hyphens as word separators. Expected must-use-loader.php, but found must_use_loader.php.
    Open

    <?php
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    Opening PHP tag must be on a line by itself
    Open

                            <?php printf(
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    A gettext call containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.
    Open

                                esc_attr__( 'Version %1$s | By %2$s %3$s' ),
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    Class file names should be based on the class name with "class-" prepended. Expected class-must-use-loader.php, but found must_use_loader.php.
    Open

    <?php
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    When a multi-item array uses associative keys, each value should start on a new line.
    Open

                    'a'       => [ 'href' => TRUE, 'title' => TRUE ],
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    Class name must begin with a capital letter
    Open

    class must_use_loader {
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    Class name is not valid; consider Must_Use_Loader instead
    Open

    class must_use_loader {
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    Closing PHP tag must be on a line by itself
    Open

                            ); ?>
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    Use Yoda Condition checks, you must.
    Open

                if ( '.' !== dirname( $plugin_file ) && dirname( $plugin_file )[0] !== '_' ) {
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found 'sanitize_title'.
    Open

                <tr id="<?php echo sanitize_title( $plugin_file ); ?>" class="active">
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$this'.
    Open

                    mustuse = value + <?php echo $this->mustuse_total; ?>;
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    No space found before comment text; expected "// $this->set_network_plugin_option( $plugin_file );" but found "//$this->set_network_plugin_option( $plugin_file );"
    Open

                //$this->set_network_plugin_option( $plugin_file );
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

    Closing PHP tag must be on a line by itself
    Open

                ]; ?>
    Severity: Minor
    Found in must_use_loader.php by phpcodesniffer

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

        public function get_mu_plugins() {
    
            // Invalid cache
            $plugins = [];
    
    
    Severity: Minor
    Found in must_use_loader.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

    Avoid unused local variables such as '$not_used'.
    Open

            foreach ( $mu_plugins as $plugin_file => $not_used ) {
    Severity: Minor
    Found in must_use_loader.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    The method subdir_mu_plugins_files uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                // Get cached plugins.
                $plugins = $this->get_transient();
    
                // Refresh if the transient is wrong.
    Severity: Minor
    Found in must_use_loader.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Severity
    Category
    Status
    Source
    Language