Showing 11,545 of 11,545 total issues
Method extractPageInfo
has 201 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function extractPageInfo( $pageid, $page ) {
$title = $this->titleFactory->newFromPageIdentity( $page );
$pageInfo = [];
// $page->exists() needs pageid, which is not set for all title objects
$pageExists = $pageid > 0;
File mediawiki.page.preview.js
has 501 lines of code (exceeds 250 allowed). Consider refactoring. Open
( function () {
const api = new mw.Api();
const util = require( 'mediawiki.util' );
/**
SwiftFileBackend
has 56 functions (exceeds 20 allowed). Consider refactoring. Open
class SwiftFileBackend extends FileBackendStore {
private const DEFAULT_HTTP_OPTIONS = [ 'httpVersion' => 'v1.1' ];
private const AUTH_FAILURE_ERROR = 'Could not connect due to prior authentication failure';
/** @var MultiHttpClient */
ApiMain
has 56 functions (exceeds 20 allowed). Consider refactoring. Open
class ApiMain extends ApiBase {
/**
* When no format parameter is given, this format will be used
*/
private const API_DEFAULT_FORMAT = 'jsonfm';
SqlBagOStuff
has 56 functions (exceeds 20 allowed). Consider refactoring. Open
class SqlBagOStuff extends MediumSpecificBagOStuff {
/** @var callable|null Injected function which returns a LoadBalancer */
protected $loadBalancerCallback;
/** @var ILoadBalancer|null */
protected $loadBalancer;
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function fillParserOutput(
Content $content,
ContentParseParams $cpoParams,
ParserOutput &$output
) {
- 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 245.
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 2 locations. Consider refactoring. Open
protected function fillParserOutput(
Content $content,
ContentParseParams $cpoParams,
ParserOutput &$output
) {
- 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 245.
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
File JobQueueRedis.php
has 499 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 showEditForm
has 199 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showEditForm() {
# need to parse the preview early so that we know which templates are used,
# otherwise users with "show preview after edit box" will get a blank list
# we parse this near the beginning so that setHeaders can do the title
# setting work instead of leaving it in getPreviewText
Function limit
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
public function limit( RateLimitSubject $subject, string $action, int $incrBy = 1 ) {
// Bypass limit checks for actions that are defined to be non-limitable.
// This is a performance optimization.
if ( $this->nonLimitableActions[$action] ?? false ) {
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 makeLoad
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
public static function makeLoad( Context $mainContext, array $modules, $only,
array $extraQuery = []
) {
$rl = $mainContext->getResourceLoader();
$chunks = [];
- 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 truncateHtml
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
public function truncateHtml( $text, $length, $ellipsis = '...' ) {
# Use the localized ellipsis character
if ( $ellipsis == '...' ) {
$ellipsis = $this->msg( 'ellipsis' )->escaped();
}
- 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 addExtensionOptions
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
private function addExtensionOptions(): void {
global $wgLang;
$extensions = $this->parent->findExtensions()->value;
'@phan-var array[] $extensions';
- 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 autoCreateUser
has 197 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function autoCreateUser(
User $user,
$source,
$login = true,
$log = true,
File QueryPage.php
has 495 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Base code for "query" special pages.
*
* This program is free software; you can redistribute it and/or modify
File DiffEngine.php
has 494 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* New version of the difference engine
*
* Copyright © 2008 Guy Van den Broeck <guy@guyvdb.eu>
Function makeApi
has 196 lines of code (exceeds 25 allowed). Consider refactoring. Open
function makeApi(sinon) {
function assertType(value, type, name) {
var actual = sinon.typeOf(value);
if (actual !== type) {
throw new TypeError("Expected type of " + name + " to be " +
Method getInfo
has 196 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
$anyHidden = false;
$services = MediaWikiServices::getInstance();
Method execute
has 196 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
/** @var Language $wgLang */
global $wgLang;
$repo = $this->file->getRepo();
PageUpdater
has 55 functions (exceeds 20 allowed). Consider refactoring. Open
class PageUpdater {
/**
* Options that have to be present in the ServiceOptions object passed to the constructor.
* @note When adding options here, also add them to PageUpdaterFactory::CONSTRUCTOR_OPTIONS.