File Linker.php
has 1475 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Methods to make links and related items.
*
* This program is free software; you can redistribute it and/or modify
Function makeThumbLink2
has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring. Open
public static function makeThumbLink2(
LinkTarget $title, $file, $frameParams = [], $handlerParams = [],
$time = false, $query = '', array $classes = [], ?Parser $parser = null
) {
$exists = $file && $file->exists();
- 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 makeImageLink
has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring. Open
public static function makeImageLink( Parser $parser, LinkTarget $title,
$file, $frameParams = [], $handlerParams = [], $time = false,
$query = '', $widthOption = null
) {
$title = Title::newFromLinkTarget( $title );
- 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
Linker
has 55 functions (exceeds 20 allowed). Consider refactoring. Open
class Linker {
/**
* Flags for userToolLinks()
*/
public const TOOL_LINKS_NOBLOCK = 1;
Method makeImageLink
has 191 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function makeImageLink( Parser $parser, LinkTarget $title,
$file, $frameParams = [], $handlerParams = [], $time = false,
$query = '', $widthOption = null
) {
$title = Title::newFromLinkTarget( $title );
Method makeThumbLink2
has 188 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function makeThumbLink2(
LinkTarget $title, $file, $frameParams = [], $handlerParams = [],
$time = false, $query = '', array $classes = [], ?Parser $parser = null
) {
$exists = $file && $file->exists();
Function normalizeSubpageLink
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
# Valid link forms:
# Foobar -- normal
# :Foobar -- override special treatment of prefix (images, language links)
# /Foobar -- convert to CurrentPage/Foobar
- 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 normalizeSubpageLink
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
# Valid link forms:
# Foobar -- normal
# :Foobar -- override special treatment of prefix (images, language links)
# /Foobar -- convert to CurrentPage/Foobar
Function generateTOC
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function generateTOC( ?TOCData $tocData, Language $lang = null, array $options = [] ): string {
$toc = '';
$lastLevel = 0;
$maxTocLevel = $options['maxtoclevel'] ?? null;
if ( $maxTocLevel === null ) {
- 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 makeBrokenImageLinkObj
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function makeBrokenImageLinkObj(
$title, $label = '', $query = '', $unused1 = '', $unused2 = '',
$time = false, array $handlerParams = [], bool $currentExists = false
) {
if ( !$title instanceof LinkTarget ) {
Function buildRollbackLink
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function buildRollbackLink(
RevisionRecord $revRecord,
IContextSource $context = null,
$editCount = 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 userToolLinkArray
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function userToolLinkArray(
$userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
): array {
$services = MediaWikiServices::getInstance();
$disableAnonTalk = $services->getMainConfig()->get( MainConfigNames::DisableAnonTalk );
- 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 getImageLinkMTOParams
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function getImageLinkMTOParams( $frameParams, $query = '', $parser = null ) {
$mtoParams = [];
if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) {
$mtoParams['custom-url-link'] = $frameParams['link-url'];
if ( isset( $frameParams['link-target'] ) ) {
- 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 titleAttrib
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function titleAttrib( $name, $options = null, array $msgParams = [], $localizer = null ) {
if ( !$localizer ) {
$localizer = self::getContextFromMain();
}
$message = $localizer->msg( "tooltip-$name", $msgParams );
- 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 buildRollbackLink
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function buildRollbackLink(
RevisionRecord $revRecord,
IContextSource $context = null,
$editCount = false
) {
Method userToolLinkArray
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function userToolLinkArray(
$userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
): array {
$services = MediaWikiServices::getInstance();
$disableAnonTalk = $services->getMainConfig()->get( MainConfigNames::DisableAnonTalk );
Function getRollbackEditCount
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function getRollbackEditCount( RevisionRecord $revRecord, $verify = true ) {
if ( func_num_args() > 1 ) {
wfDeprecated( __METHOD__ . ' with $verify parameter', '1.40' );
}
$showRollbackEditCount = MediaWikiServices::getInstance()->getMainConfig()
- 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 getRollbackEditCount
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getRollbackEditCount( RevisionRecord $revRecord, $verify = true ) {
if ( func_num_args() > 1 ) {
wfDeprecated( __METHOD__ . ' with $verify parameter', '1.40' );
}
$showRollbackEditCount = MediaWikiServices::getInstance()->getMainConfig()
Method makeExternalLink
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function makeExternalLink( $url, $text, $escape = true,
$linktype = '', $attribs = [], $title = null
) {
global $wgTitle;
$class = 'external';
Method generateTOC
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function generateTOC( ?TOCData $tocData, Language $lang = null, array $options = [] ): string {
$toc = '';
$lastLevel = 0;
$maxTocLevel = $options['maxtoclevel'] ?? null;
if ( $maxTocLevel === null ) {
Method titleAttrib
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function titleAttrib( $name, $options = null, array $msgParams = [], $localizer = null ) {
if ( !$localizer ) {
$localizer = self::getContextFromMain();
}
$message = $localizer->msg( "tooltip-$name", $msgParams );
Method userLink
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function userLink(
$userId,
$userName,
$altUserName = false,
$attributes = []
Method getRevDeleteLink
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getRevDeleteLink(
Authority $performer,
RevisionRecord $revRecord,
LinkTarget $title
) {
Function makeBrokenImageLinkObj
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function makeBrokenImageLinkObj(
$title, $label = '', $query = '', $unused1 = '', $unused2 = '',
$time = false, array $handlerParams = [], bool $currentExists = false
) {
if ( !$title instanceof LinkTarget ) {
- 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 userLink
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function userLink(
$userId,
$userName,
$altUserName = false,
$attributes = []
- 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 revUserTools
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function revUserTools(
RevisionRecord $revRecord,
$isPublic = false,
$useParentheses = true
) {
Method link
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function link(
$target, $html = null, $customAttribs = [], $query = [], $options = []
) {
if ( !$target instanceof LinkTarget ) {
wfWarn( __METHOD__ . ': Requires $target to be a LinkTarget object.', 2 );
Method getImageLinkMTOParams
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getImageLinkMTOParams( $frameParams, $query = '', $parser = null ) {
$mtoParams = [];
if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) {
$mtoParams['custom-url-link'] = $frameParams['link-url'];
if ( isset( $frameParams['link-target'] ) ) {
Method makeBrokenImageLinkObj
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$title, $label = '', $query = '', $unused1 = '', $unused2 = '',
$time = false, array $handlerParams = [], bool $currentExists = false
Method makeImageLink
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function makeImageLink( Parser $parser, LinkTarget $title,
$file, $frameParams = [], $handlerParams = [], $time = false,
$query = '', $widthOption = null
Method makeThumbLink2
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
LinkTarget $title, $file, $frameParams = [], $handlerParams = [],
$time = false, $query = '', array $classes = [], ?Parser $parser = null
Method makeThumbLinkObj
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
LinkTarget $title, $file, $label = '', $alt = '', $align = null,
$params = [], $framed = false, $manualthumb = ''
Function makeExternalLink
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function makeExternalLink( $url, $text, $escape = true,
$linktype = '', $attribs = [], $title = null
) {
global $wgTitle;
$class = 'external';
- 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 deeply nested control flow statements. Open
if ( $text === '' ) {
$text = $nodotdot . $suffix;
}
Method makeExternalLink
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function makeExternalLink( $url, $text, $escape = true,
$linktype = '', $attribs = [], $title = null
Method userToolLinks
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null,
$useParentheses = true
Function processResponsiveImages
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function processResponsiveImages( $file, $thumb, $hp ) {
$responsiveImages = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::ResponsiveImages );
if ( $responsiveImages && $thumb && !$thumb->isError() ) {
$hp15 = $hp;
$hp15['width'] = round( $hp['width'] * 1.5 );
- 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 makeHeadline
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function makeHeadline( $level, $attribs, $anchor, $html,
$link, $fallbackAnchor = false
Method makeSelfLinkObj
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '', $hash = '' ) {
Function link
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function link(
$target, $html = null, $customAttribs = [], $query = [], $options = []
) {
if ( !$target instanceof LinkTarget ) {
wfWarn( __METHOD__ . ': Requires $target to be a LinkTarget object.', 2 );
- 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 tocLine
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function tocLine( $linkAnchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
Method commentBlock
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$comment, $title = null, $local = false, $wikiId = null, $useParentheses = true
Method userToolLinkArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
Method linkKnown
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$target, $html = null, $customAttribs = [],
$query = [], $options = [ 'known' ]
Method link
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$target, $html = null, $customAttribs = [], $query = [], $options = []
Avoid too many return
statements within this method. Open
return str_replace( "\n", ' ', $s );
Avoid too many return
statements within this method. Open
return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
Function accesskey
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function accesskey( $name, $localizer = null ) {
if ( !isset( self::$accesskeycache[$name] ) ) {
if ( !$localizer ) {
$localizer = self::getContextFromMain();
}
- 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 2 locations. Consider refactoring. Open
public static function generateTOC( ?TOCData $tocData, Language $lang = null, array $options = [] ): string {
$toc = '';
$lastLevel = 0;
$maxTocLevel = $options['maxtoclevel'] ?? null;
if ( $maxTocLevel === null ) {
- 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 319.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
return '<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading">'
. Html::element( 'input', [
'type' => 'checkbox',
'role' => 'button',
'id' => 'toctogglecheckbox',
- 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 134.
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
public static function blockLink( $userId, $userText ) {
if ( $userText === '' ) {
wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
'that need to be fixed?' );
return wfMessage( 'empty-username' )->parse();
- 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 108.
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
public static function emailLink( $userId, $userText ) {
if ( $userText === '' ) {
wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
'that need to be fixed?' );
return wfMessage( 'empty-username' )->parse();
- 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 108.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
return Html::openElement( 'li', [ 'class' => $classes ] )
. Html::rawElement( 'a',
[ 'href' => "#$linkAnchor" ],
Html::element( 'span', [ 'class' => 'tocnumber' ], $tocnumber )
. ' '
- 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 91.
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