MatthewMi11er/wordpress-plugin-mi11er-utility

View on GitHub

Showing 7 of 154 total issues

Consider simplifying this complex logical expression.
Open

            if ( $offset > 0 && $offset + mb_strlen( $matches[0], 'UTF-8' ) !== mb_strlen( $title, 'UTF-8' )
                && preg_match( $small_words, $matches[0] ) && ( $offset - 2 < 0 || mb_substr( $title, $offset - 2, 1 , 'UTF-8' ) !== ':' )
                && ( mb_substr( $title, $offset + mb_strlen( $matches[0], 'UTF-8' ), 1 ) !== '-'
                    || $offset - 1 < 0 || mb_substr( $title, $offset - 1, 1, 'UTF-8' ) === '-' )
                && ( $offset - 1 < 0 || ! preg_match( '/[^\s-]/', mb_substr( $title, $offset - 1, 1, 'UTF-8' ) ) ) ) {
Severity: Critical
Found in includes/mi11er-utility/class-template-tags.php - About 2 hrs to fix

Method template_redirect_action has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function template_redirect_action() {
        global $wpdb;

        if ( ! is_404() ) {
            return;
Severity: Minor
Found in includes/mi11er-utility/class-redirect.php - About 1 hr to fix

Method the_posts_filter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function the_posts_filter( $posts, $wp_query ) {
        $file_config = $this->get_config();
        if ( false !== $file_config && $wp_query->is_main_query() && ! is_admin() ) {
            $default_post = [
                'post_author'    => 1,
Severity: Minor
Found in includes/mi11er-utility/class-file-handler.php - About 1 hr to fix

Method add_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function add_config( $file, $rewrite, $template, $prevent_slash = true, $post = [] ) {
Severity: Minor
Found in includes/mi11er-utility/class-file-handler.php - About 35 mins to fix

Function template_redirect_action has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function template_redirect_action() {
        global $wpdb;

        if ( ! is_404() ) {
            return;
Severity: Minor
Found in includes/mi11er-utility/class-redirect.php - About 35 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

Function _format_time has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _format_time( $the_time ) {

        $time_parts = explode( '|', $the_time );

        // Reformat to noon and midnight.
Severity: Minor
Found in includes/mi11er-utility/class-ap-style.php - About 35 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 $home_url;
Severity: Major
Found in includes/mi11er-utility/class-template-tags.php - About 30 mins to fix
Severity
Category
Status
Source
Language