Showing 912 of 912 total issues
Function onToggleUnusedFields
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onToggleUnusedFields = function ( visibility, fromClick ) {
if ( visibility ) {
this.createAllParameterCheckboxes();
}
- 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 getRange
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWAceEditorWidget.prototype.getRange = function () {
let lines;
function posToOffset( row, col ) {
let offset = 0;
- 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 onRequestImagesSuccess
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWGalleryDialog.prototype.onRequestImagesSuccess = function ( response ) {
const thumbUrls = {},
items = [],
config = { isMobile: this.isMobile, draggable: !this.isReadOnly() };
- 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 getActionProcess
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWExtensionWindow.prototype.getActionProcess = function ( action, process ) {
return process.first( () => {
if ( action === 'done' ) {
if ( this.constructor.static.allowedEmpty || this.input.getValue() !== '' ) {
this.insertOrUpdateNode();
- 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 transformWikitext
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
PageIdentity $page,
Bcp47Code $targetLanguage,
string $wikitext,
bool $bodyOnly,
?int $oldid,
Method onSkinEditSectionLinks
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function onSkinEditSectionLinks( $skin, $title, $section,
$tooltip, &$result, $lang
Avoid deeply nested control flow statements. Open
if ( typeof change === 'string' ) {
listItem.appendChild( document.createTextNode( change ) );
} else {
change.forEach( ( node ) => {
listItem.appendChild( node );
Function onBeforePageDisplay
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function onBeforePageDisplay( $output, $skin ): void {
$services = MediaWikiServices::getInstance();
$hookRunner = new VisualEditorHookRunner( $services->getHookContainer() );
if ( !$hookRunner->onVisualEditorBeforeEditor( $output, $skin ) ) {
$output->addJsConfigVars( 'wgVisualEditorDisabledByHook', 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 onCustomEditor
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function onCustomEditor( $article, $user ) {
$req = $article->getContext()->getRequest();
$services = MediaWikiServices::getInstance();
$urlUtils = $services->getUrlUtils();
$veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' );
- 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 ( data && data.action === 'prefer-ve' ) {
location.href = veEditUrl;
} else if ( data && data.action === 'multi-tab' ) {
location.reload();
}
Method onBeforeInitialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$title, $article, $output, $user, $request, $mediaWiki
Avoid deeply nested control flow statements. Open
if ( !paramChanges ) {
paramChanges = document.createElement( 'ul' );
descriptions.push( paramChanges );
}
Function VeCeMWInlineImageNode
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
ve.ce.MWInlineImageNode = function VeCeMWInlineImageNode( model, config ) {
let $image;
let hasHref = false;
if ( model.getAttribute( 'isError' ) ) {
- 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 matchLanguage
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
ve.dm.MWLanguageVariantNode.static.matchLanguage = function ( items ) {
const userVariant = mw.config.get( 'wgUserVariant' ),
fallbacks = mw.config.get( 'wgVisualEditor' ).pageVariantFallbacks,
languageCodes =
( userVariant ? [ userVariant ] : [] ).concat( fallbacks || [] );
- 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 ( confirmed ) {
return dataPromise;
} else {
// If they requested the latest version, invalidate the autosave state
mw.storage.session.remove( 've-docstate' );
Function register
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
mw.editcheck.EditCheckFactory.prototype.register = function ( constructor, name ) {
name = name || ( constructor.static && constructor.static.name );
if ( typeof name !== 'string' || name === '' ) {
throw new Error( 'Check names must be strings and must not be empty' );
- 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 4 locations. Consider refactoring. Open
ve.ui.MWLanguageVariantOneWayInspector = function VeUiMWLanguageVariantOneWayInspector() {
ve.ui.MWLanguageVariantOneWayInspector.super.apply( this, arguments );
};
- 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 50.
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
Method transformWikitext
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
PageIdentity $page,
Bcp47Code $targetLanguage,
string $wikitext,
bool $bodyOnly,
?int $oldid,
Function getWikitext
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
ve.dm.MWTransclusionNode.static.getWikitext = function ( content ) {
let wikitext = '';
// Normalize to multi template format
if ( content.params ) {
- 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 ( section ) {
// switching from visual via the "add section" tab
target.switchToWikitextSection( section );
} else {
target.editSource();