Showing 912 of 912 total issues
Function updateRedirectInterface
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.ArticleTarget.prototype.updateRedirectInterface = function ( $sub, $msg ) {
// For the subtitle, replace the real one with ours.
// This is more complicated than it should be because we have to fiddle with the <br>.
const $currentSub = $( '#redirectsub' );
if ( $currentSub.length ) {
Function initialize
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWLanguageVariantFilterInspector.prototype.initialize = function () {
ve.ui.MWLanguageVariantFilterInspector.super.prototype.initialize.call( this );
this.textTarget = this.createTextTarget( OO.ui.msg(
'visualeditor-mwlanguagevariantinspector-filter-text-placeholder'
) );
Function getActionProcess
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWTransclusionDialog.prototype.getActionProcess = function ( action ) {
const willLoseProgress = this.getMode() === 'insert' ?
// A new template with no parameters is not considered valuable.
this.transclusionModel.containsValuableData() :
// The user has changed a parameter, and is not on the template search page.
Function VeUiMWTransclusionOutlinePartWidget
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWidget( part, config ) {
this.part = part;
// Parent constructor
ve.ui.MWTransclusionOutlinePartWidget.super.call( this, ve.extendObject( config, {
Function VeUiMWCategoryWidget
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWCategoryWidget = function VeUiMWCategoryWidget( config ) {
// Config initialization
config = config || {};
// Parent constructor
Function getUpdatedAttributes
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.dm.MWImageModel.prototype.getUpdatedAttributes = function () {
const origAttrs = this.getOriginalImageAttributes();
let currentDimensions;
// Adjust default dimensions if size is set to default
Function setEditorPreference
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setEditorPreference( editor ) {
// If visual mode isn't available, don't set the editor preference as the
// user has expressed no choice by opening this editor. (T246259)
// Strictly speaking the same thing should happen if visual mode is
// available but source mode isn't, but that is never the case.
Function getPreviewHtml
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.dm.MWLanguageVariantNode.static.getPreviewHtml = function ( variantInfo, opts ) {
if ( variantInfo.disabled ) {
return variantInfo.disabled.t;
} else if ( variantInfo.name ) {
return ve.init.platform.getLanguageName( variantInfo.name.t.toLowerCase() );
Function reduplicateStyles
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.libs.ve.reduplicateStyles = function ( element ) {
Array.prototype.forEach.call( element.querySelectorAll( 'link[rel~="mw-deduplicated-inline-style"]' ), ( link ) => {
const href = link.getAttribute( 'href' );
if ( !href || href.slice( 0, 'mw-data:'.length ) !== 'mw-data:' ) {
return;
Function getSetupProcess
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWMediaDialog.prototype.getSetupProcess = function ( data ) {
return ve.ui.MWMediaDialog.super.prototype.getSetupProcess.call( this, data )
.next( () => {
const isReadOnly = 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 VeUiMWWikitextSurface
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWWikitextSurface = function VeUiMWWikitextSurface() {
// Parent constructor
ve.ui.MWWikitextSurface.super.apply( this, arguments );
// Initialization
- 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 teardown
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
ve.init.mw.DesktopArticleTarget.prototype.teardown = function ( trackMechanism ) {
// Event tracking
let abortType, abortedMode;
if ( trackMechanism ) {
if ( this.activating ) {
- 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 surfaceReady
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
ve.init.mw.ArticleTarget.prototype.surfaceReady = function () {
const accessKeyPrefix = $.fn.updateTooltipAccessKeys.getAccessKeyPrefix().replace( /-/g, '+' ),
accessKeyModifiers = new ve.ui.Trigger( accessKeyPrefix + '-' ).modifiers,
surfaceModel = this.getSurface().getModel();
- 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 insertImageNode
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
const nodeType = this.getImageNodeType(),
surfaceModel = fragment.getSurface();
if ( !( fragment.getSelection() instanceof ve.dm.LinearSelection ) ) {
- 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 changeImageSource
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
ve.dm.MWImageModel.prototype.changeImageSource = function ( attrs, APIinfo ) {
this.changedImageSource = true;
if ( attrs.mediaType ) {
this.setMediaType( attrs.mediaType );
- 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 getPartsList
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
ve.dm.MWTransclusionNode.prototype.getPartsList = function () {
if ( !this.partsList ) {
this.partsList = [];
const content = this.getAttribute( 'mw' );
for ( let i = 0; i < content.parts.length; i++ ) {
- 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
ve.ui.MWGalleryDialog.prototype.updateActions = function () {
this.actions.setAbilities( { done: this.isSaveable() } );
};
- 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 60.
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
ve.ui.MWExtensionWindow.prototype.updateActions = function () {
this.actions.setAbilities( { done: this.isSaveable() } );
};
- 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 60.
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 wrapLine
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWWikitextAction.prototype.wrapLine = function ( before, after, placeholder, unwrapOffsetsCallback ) {
let originalFragment = this.surface.getModel().getFragment( null, false, true /* excludeInsertions */ );
const selectedNodes = originalFragment.getLeafNodes();
let unwrapped = false;
Function export
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWExportWikitextDialog.prototype.export = function () {
const wikitext = this.wikitextLayout.textInput.getValue(),
title = this.titleInput.getMWTitle(),
importTitle = ve.init.target.getImportTitle();