File ChangesListSpecialPage.php
has 1321 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
Method __construct
has 462 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(
$name,
$restriction,
UserIdentityUtils $userIdentityUtils,
TempUserConfig $tempUserConfig
ChangesListSpecialPage
has 57 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class ChangesListSpecialPage extends SpecialPage {
/** @var string */
protected $rcSubpage;
Method makeLegend
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function makeLegend() {
$context = $this->getContext();
$user = $context->getUser();
# The legend showing what the letters and stuff mean
$legend = Html::openElement( 'dl' ) . "\n";
Function areFiltersInConflict
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function areFiltersInConflict() {
$opts = $this->getOptions();
foreach ( $this->getFilterGroups() as $group ) {
if ( $group->getConflictingGroups() ) {
wfLogWarning(
- 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 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $subpage ) {
$this->rcSubpage = $subpage;
if ( $this->considerActionsForDefaultSavedQuery( $subpage ) ) {
// Don't bother rendering the page if we'll be performing a redirect (T330100).
Method registerFilters
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function registerFilters() {
$this->registerFiltersFromDefinitions( $this->filterGroupDefinitions );
// Make sure this is not being transcluded (we don't want to show this
// information to all users just because the user that saves the edit can
Function parseParameters
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function parseParameters( $par, FormOptions $opts ) {
$stringParameterNameSet = [];
$hideParameterNameSet = [];
// URL parameters can be per-group, like 'userExpLevel',
- 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 execute
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function execute( $subpage ) {
$this->rcSubpage = $subpage;
if ( $this->considerActionsForDefaultSavedQuery( $subpage ) ) {
// Don't bother rendering the page if we'll be performing a redirect (T330100).
- 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 includeRcFiltersApp
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function includeRcFiltersApp() {
$out = $this->getOutput();
if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
$jsData = $this->getStructuredFilterJsData();
$messages = [];
Function buildQuery
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
&$join_conds, FormOptions $opts
) {
$dbr = $this->getDB();
$isStructuredUI = $this->isStructuredFilterUiEnabled();
- 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 fixContradictoryOptions
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function fixContradictoryOptions( FormOptions $opts ) {
$fixed = $this->fixBackwardsCompatibilityOptions( $opts );
foreach ( $this->filterGroups as $filterGroup ) {
if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
- 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 buildQuery
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
&$join_conds, FormOptions $opts
) {
$dbr = $this->getDB();
$isStructuredUI = $this->isStructuredFilterUiEnabled();
Method considerActionsForDefaultSavedQuery
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function considerActionsForDefaultSavedQuery( $subpage ) {
if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) {
return false;
}
Method filterOnUserExperienceLevel
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
&$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
) {
$selected = array_fill_keys( $selectedExpLevels, true );
Method filterOnUserExperienceLevel
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
&$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
Method replaceOldOptions
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function replaceOldOptions( FormOptions $opts ) {
if ( !$this->isStructuredFilterUiEnabled() ) {
return false;
}
Function considerActionsForDefaultSavedQuery
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function considerActionsForDefaultSavedQuery( $subpage ) {
if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) {
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
Function getLegacyShowHideFilters
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function getLegacyShowHideFilters() {
$filters = [];
foreach ( $this->filterGroups as $group ) {
if ( $group instanceof ChangesListBooleanFilterGroup ) {
foreach ( $group->getFilters() as $key => $filter ) {
- 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 doMainQuery
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doMainQuery( $tables, $fields, $conds,
$query_options, $join_conds, FormOptions $opts
) {
$rcQuery = RecentChange::getQueryInfo();
$tables = array_merge( $tables, $rcQuery['tables'] );
Function replaceOldOptions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function replaceOldOptions( FormOptions $opts ) {
if ( !$this->isStructuredFilterUiEnabled() ) {
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 buildQuery
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
&$join_conds, FormOptions $opts
Method runMainQueryHook
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function runMainQueryHook( &$tables, &$fields, &$conds,
&$query_options, &$join_conds, $opts
Method doMainQuery
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function doMainQuery( $tables, $fields, $conds,
$query_options, $join_conds, FormOptions $opts
Function filterOnUserExperienceLevel
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
&$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
) {
$selected = array_fill_keys( $selectedExpLevels, true );
- 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 getLinkDays
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getLinkDays() {
$linkDays = $this->getConfig()->get( MainConfigNames::RCLinkDays );
$filterByAge = $this->getConfig()->get( MainConfigNames::RCFilterByAge );
$maxAge = $this->getConfig()->get( MainConfigNames::RCMaxAge );
if ( $filterByAge ) {
- 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 includeRcFiltersApp
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function includeRcFiltersApp() {
$out = $this->getOutput();
if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
$jsData = $this->getStructuredFilterJsData();
$messages = [];
- 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 $rc->getAttribute( 'rc_bot' );
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_NEW;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_CATEGORIZE;
Avoid too many return
statements within this method. Open
return $ctx->getUser()->equals( $rc->getPerformerIdentity() );
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_log_type' ) === "newusers";
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_AUTOPATROLLED;
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_PATROLLED;
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_minor' );
Avoid too many return
statements within this method. Open
return $performer->isRegistered() &&
MediaWikiServices::getInstance()
->getUserFactory()
->newFromUserIdentity( $performer )
->getExperienceLevel() === 'experienced';
Avoid too many return
statements within this method. Open
return $rcPatrolledValues[ $s ];
Avoid too many return
statements within this method. Open
return !$rc->getAttribute( 'rc_bot' );
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED;
Avoid too many return
statements within this method. Open
return !$rc->getAttribute( 'rc_minor' );
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_LOG;
Avoid too many return
statements within this method. Open
return !$ctx->getUser()->equals( $rc->getPerformerIdentity() );
Avoid too many return
statements within this method. Open
return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_EDIT;
Function registerFiltersFromDefinitions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function registerFiltersFromDefinitions( array $definition ) {
$autoFillPriority = -1;
foreach ( $definition as $groupDefinition ) {
if ( !isset( $groupDefinition['priority'] ) ) {
$groupDefinition['priority'] = $autoFillPriority;
- 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
Similar blocks of code found in 3 locations. Consider refactoring. Open
[
'name' => 'hidenewpages',
'label' => 'rcfilters-filter-newpages-label',
'description' => 'rcfilters-filter-newpages-description',
'default' => false,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 149.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
[
'name' => 'hidelog',
'label' => 'rcfilters-filter-logactions-label',
'description' => 'rcfilters-filter-logactions-description',
'default' => false,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 149.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
[
'name' => 'hidepageedits',
'label' => 'rcfilters-filter-pageedits-label',
'description' => 'rcfilters-filter-pageedits-description',
'default' => false,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 149.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76