Showing 11,545 of 11,545 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
[
'wgServer', 'wgScriptPath',
'wgPasswordSender', 'wgImageMagickConvertCommand',
'wgLanguageCode', 'wgLocaltimezone', 'wgEnableEmail', 'wgEnableUserEmail',
'wgDiff3', 'wgEnotifUserTalk', 'wgEnotifWatchlist', 'wgEmailAuthentication',
- 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 120.
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 maybeFetch
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function maybeFetch() {
if ( typeof context.config.update.before === 'function' ) {
context.config.update.before.call( context.data.$textbox );
}
Function convertGrammar
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.language.convertGrammar = function ( word, form ) {
let grammarForms = mw.language.getData( 'os', 'grammarForms' ),
// Ending for allative case
endAllative = 'мæ',
// Variable for 'j' beetwen vowels
Function Uri
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Uri( uri, options ) {
let prop, hrefCur,
hasOptions = ( options !== undefined ),
defaultUri = getDefaultUri();
Function MwWidgetsComplexNamespaceInputWidget
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.widgets.ComplexNamespaceInputWidget = function MwWidgetsComplexNamespaceInputWidget( config ) {
// Configuration initialization
config = Object.assign(
{
// Config options for nested widgets
Function test
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
test: function ( map, profile, exactMatchOnly ) {
var conditions, dir, i, op, val, j, pieceVersion, pieceVal, compare;
profile = $.isPlainObject( profile ) ? profile : $.client.profile();
if ( map.ltr && map.rtl ) {
dir = $( document.body ).is( '.rtl' ) ? 'rtl' : 'ltr';
Function hide$1
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
const hide$1 = function(options) {
if (options === void 0) {
options = {};
}
return {
Function setup
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
setup(props, { emit }) {
const rootElement = ref();
const rootClasses = computed(() => {
return {
"cdx-input-chip--disabled": props.disabled
Function _sfc_render$1
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
const _component_cdx_label = resolveComponent("cdx-label");
return openBlock(), createElementBlock(
"span",
{
Function _animate
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
_animate: function( toShow, toHide, data ) {
var total, easing, duration,
that = this,
adjust = 0,
down = toShow.length &&
Function _toggle
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
_toggle: function( event, eventData ) {
var that = this,
toShow = eventData.newPanel,
toHide = eventData.oldPanel;
Function _determineDate
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
_determineDate: function(inst, date, defaultDate) {
var offsetNumeric = function(offset) {
var date = new Date();
date.setDate(date.getDate() + offset);
return date;
Function push
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Deflate.prototype.push = function (data, flush_mode) {
const strm = this.strm;
const chunkSize = this.options.chunkSize;
let status, _flush_mode;
Function tr_static_init
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
const tr_static_init = () => {
let n; /* iterates over tree elements */
let bits; /* bit counter */
let length; /* length value */
Method getSiteConfigSettings
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getSiteConfigSettings(
Context $context, Config $conf
): array {
$services = MediaWikiServices::getInstance();
// Namespace related preparation
Method extractResourceLoaderModules
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function extractResourceLoaderModules( $dir, array $info ) {
$defaultPaths = $info['ResourceFileModulePaths'] ?? false;
if ( isset( $defaultPaths['localBasePath'] ) ) {
if ( $defaultPaths['localBasePath'] === '' ) {
// Avoid double slashes (e.g. /extensions/Example//path)
Method generateUndoEditSummary
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function generateUndoEditSummary( ?RevisionRecord $oldrev, int $undo,
?RevisionRecord $undorev, MediaWikiServices $services
) {
// If we just undid one rev, use an autosummary
$firstrev = $this->revisionStore->getNextRevision( $oldrev );
Method getFunctionStats
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getFunctionStats() {
$this->close();
$cpuStats = $this->cpuProf->getLog()->aggregateByFunction();
'@phan-var array $cpuStats';
$realStats = $this->realProf->getLog()->aggregateByFunction();
Method getSecondaryDataUpdates
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSecondaryDataUpdates( $recursive = false ) {
if ( $this->isContentDeleted() ) {
// This shouldn't happen, since the current content is always public,
// and DataUpdates are only needed for current content.
return [];
Method parse
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function parse( $value, $options = 0 ) {
if ( $options & self::STRIP_COMMENTS ) {
$value = self::stripComments( $value );
}
$assoc = ( $options & self::FORCE_ASSOC ) !== 0;