Showing 11,461 of 11,461 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
OO.ui.PopupToolGroup.prototype.onToolbarResize = function () {
if ( !this.narrowConfig ) {
return;
}
if ( this.toolbar.isNarrow() ) {
- 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 317.
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
OO.ui.Tool.prototype.onToolbarResize = function () {
if ( !this.narrowConfig ) {
return;
}
if ( this.toolbar.isNarrow() ) {
- 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 317.
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
Function loadSessionInfoFromStore
has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring. Open
private function loadSessionInfoFromStore( SessionInfo &$info, WebRequest $request ) {
$key = $this->store->makeKey( 'MWSession', $info->getId() );
$blob = $this->store->get( $key );
// If we got data from the store and the SessionInfo says to force use,
- 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 convertGrammar
has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring. Open
public function convertGrammar( $word, $case ) {
$grammarForms =
MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
if ( isset( $grammarForms['tyv'][$case][$word] ) ) {
return $grammarForms['tyv'][$case][$word];
- 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 createSetupStore
has 351 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
let scope;
const optionsForPlugin = assign({ actions: {} }, options);
/* istanbul ignore if */
// @ts-expect-error: active is an internal property
File SpecialWatchlist.php
has 750 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
File SessionManager.php
has 749 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* MediaWiki\Session entry point
*
* This program is free software; you can redistribute it and/or modify
Method getHelpInternal
has 348 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function getHelpInternal( IContextSource $context, array $modules,
array $options, &$haveModules
) {
$out = '';
Function execute
has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
$params = $this->extractRequestParams();
if ( $params['lang'] === null ) {
$langObj = $this->getLanguage();
} elseif ( !$this->languageNameUtils->isValidCode( $params['lang'] ) ) {
- 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
File MainConfigNames.php
has 743 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This file is automatically generated using maintenance/generateConfigSchema.php.
* Do not modify this file manually, edit includes/MainConfigSchema.php instead.
* @file
File config-vars.php
has 741 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This file is automatically generated using maintenance/generateConfigSchema.php.
* Do not modify this file manually, edit includes/MainConfigSchema.php instead.
*/
File SpecialRecentChanges.php
has 740 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
Function openShowImage
has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring. Open
protected function openShowImage() {
$context = $this->getContext();
$mainConfig = $context->getConfig();
$enableUploads = $mainConfig->get( MainConfigNames::EnableUploads );
$send404Code = $mainConfig->get( MainConfigNames::Send404Code );
- 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
File InfoAction.php
has 739 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Displays information about a page.
*
* Copyright © 2011 Alexandre Emsenhuber
File NormalizeAr.php
has 737 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
// Generated by generateNormalizerDataAr.php. Do not modify!
namespace MediaWiki\Languages\Data;
Function pluralRuleParser
has 341 lines of code (exceeds 25 allowed). Consider refactoring. Open
function pluralRuleParser(rule, number) {
'use strict';
/*
Syntax: see http://unicode.org/reports/tr35/#Language_Plural_Rules
File TextPassDumper.php
has 734 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* BackupDumper that postprocesses XML dumps from dumpBackup.php to add page text
*
* Copyright (C) 2005 Brooke Vibber <bvibber@wikimedia.org>
File jquery.ui.sortable.js
has 733 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* jQuery UI Sortable 1.9.2
* http://jqueryui.com
*
* Copyright 2012 jQuery Foundation and other contributors
FileBackendStore
has 89 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class FileBackendStore extends FileBackend {
/** @var WANObjectCache */
protected $memCache;
/** @var BagOStuff */
protected $srvCache;
Function makeApi
has 335 lines of code (exceeds 25 allowed). Consider refactoring. Open
function makeApi(sinon) {
var push = Array.prototype.push;
var slice = Array.prototype.slice;
var callId = 0;