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.
- Read upRead up
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;
}
- Read upRead up
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.
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.
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;
}
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";
- Read upRead up
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( ':' );
}
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>";
- Read upRead up
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;