Function getCommentInternal
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
private function getCommentInternal( ?IReadableDatabase $db, $key, $row, $fallback = false ) {
$row = (array)$row;
if ( array_key_exists( "{$key}_text", $row ) && array_key_exists( "{$key}_data", $row ) ) {
$cid = $row["{$key}_cid"] ?? null;
$text = $row["{$key}_text"];
- 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 getCommentInternal
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getCommentInternal( ?IReadableDatabase $db, $key, $row, $fallback = false ) {
$row = (array)$row;
if ( array_key_exists( "{$key}_text", $row ) && array_key_exists( "{$key}_data", $row ) ) {
$cid = $row["{$key}_cid"] ?? null;
$text = $row["{$key}_text"];
Method createComment
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createComment( IDatabase $dbw, $comment, array $data = null ) {
$comment = CommentStoreComment::newUnsavedComment( $comment, $data );
# Truncate comment in a Unicode-sensitive manner
$comment->text = $this->lang->truncateForVisual( $comment->text, self::COMMENT_CHARACTER_LIMIT );
Function createComment
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function createComment( IDatabase $dbw, $comment, array $data = null ) {
$comment = CommentStoreComment::newUnsavedComment( $comment, $data );
# Truncate comment in a Unicode-sensitive manner
$comment->text = $this->lang->truncateForVisual( $comment->text, self::COMMENT_CHARACTER_LIMIT );
- 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 decodeMessage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function decodeMessage( $data ) {
$key = array_shift( $data );
foreach ( $data as &$param ) {
if ( is_object( $param ) ) {
$param = (array)$param;
- 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"