includes/Category/Category.php
File Category.php
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* Representation for a category.
*
* This program is free software; you can redistribute it and/or modify
Method refreshCounts
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function refreshCounts() {
if ( $this->readOnlyMode->isReadOnly() ) {
return false;
}
Function initialize
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function initialize( $mode = self::LOAD_ONLY ) {
if ( $this->mName === null && $this->mID === null ) {
throw new RuntimeException( __METHOD__ . ' has both names and IDs null' );
} elseif ( $this->mID === null ) {
$where = [ 'cat_title' => $this->mName ];
- 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 initialize
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function initialize( $mode = self::LOAD_ONLY ) {
if ( $this->mName === null && $this->mID === null ) {
throw new RuntimeException( __METHOD__ . ' has both names and IDs null' );
} elseif ( $this->mID === null ) {
$where = [ 'cat_title' => $this->mName ];
Method refreshCountsIfSmall
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function refreshCountsIfSmall( $maxSize = self::ROW_COUNT_SMALL ) {
$dbw = $this->dbProvider->getPrimaryDatabase();
$dbw->startAtomic( __METHOD__ );
$typeOccurances = $dbw->newSelectQueryBuilder()
Function refreshCounts
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
public function refreshCounts() {
if ( $this->readOnlyMode->isReadOnly() ) {
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 newFromRow
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function newFromRow( stdClass $row, ?PageIdentity $page = null ) {
$cat = new self();
$cat->mPage = $page;
# NOTE: the row often results from a LEFT JOIN on categorylinks. This may result in