wikimedia/mediawiki-core

View on GitHub
includes/parser/BlockLevelPass.php

Summary

Maintainability
F
6 days
Test Coverage

Function execute has a Cognitive Complexity of 117 (exceeds 5 allowed). Consider refactoring.
Open

    private function execute() {
        $text = $this->text;
        # Parsing through the text line by line.  The main thing
        # happening here is handling of block-level elements p, pre,
        # and making lists from lines starting with * # : etc.
Severity: Minor
Found in includes/parser/BlockLevelPass.php - About 2 days 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 findColonNoLinks has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    private function findColonNoLinks( $str, &$before, &$after ) {
        if ( !preg_match( '/:|<|-\{/', $str, $m, PREG_OFFSET_CAPTURE ) ) {
            # Nothing to find!
            return false;
        }
Severity: Minor
Found in includes/parser/BlockLevelPass.php - About 1 day 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 execute has 204 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function execute() {
        $text = $this->text;
        # Parsing through the text line by line.  The main thing
        # happening here is handling of block-level elements p, pre,
        # and making lists from lines starting with * # : etc.
Severity: Major
Found in includes/parser/BlockLevelPass.php - About 1 day to fix

    File BlockLevelPass.php has 462 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * This is the part of the wikitext parser which handles automatic paragraphs
     * and conversion of start-of-line prefixes to HTML lists.
    Severity: Minor
    Found in includes/parser/BlockLevelPass.php - About 7 hrs to fix

      Method findColonNoLinks has 153 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function findColonNoLinks( $str, &$before, &$after ) {
              if ( !preg_match( '/:|<|-\{/', $str, $m, PREG_OFFSET_CAPTURE ) ) {
                  # Nothing to find!
                  return false;
              }
      Severity: Major
      Found in includes/parser/BlockLevelPass.php - About 6 hrs to fix

        Function nextItem has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            private function nextItem( $char ) {
                if ( $char === '*' || $char === '#' ) {
                    return "</li>\n<li>";
                } elseif ( $char === ':' || $char === ';' ) {
                    $close = "</dd>\n";
        Severity: Minor
        Found in includes/parser/BlockLevelPass.php - About 55 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 deeply nested control flow statements.
        Open

                                if ( $this->findColonNoLinks( $t, $term, $t2 ) !== false ) {
                                    $t = $t2;
                                    // Trim whitespace in list items
                                    $output .= trim( $term ) . $this->nextItem( ':' );
                                }
        Severity: Major
        Found in includes/parser/BlockLevelPass.php - About 45 mins to fix

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

              private function closeList( $char ) {
                  if ( $char === '*' ) {
                      $text = "</li></ul>";
                  } elseif ( $char === '#' ) {
                      $text = "</li></ol>";
          Severity: Minor
          Found in includes/parser/BlockLevelPass.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 false;
          Severity: Major
          Found in includes/parser/BlockLevelPass.php - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status