Showing 912 of 912 total issues
Function onRequestImagesSuccess
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWGalleryDialog.prototype.onRequestImagesSuccess = function ( response ) {
const thumbUrls = {},
items = [],
config = { isMobile: this.isMobile, draggable: !this.isReadOnly() };
Function getHtml
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
getHtml: function ( newDoc, oldDoc ) {
function copyAttributes( from, to ) {
Array.prototype.forEach.call( from.attributes, ( attr ) => {
to.setAttribute( attr.name, attr.value );
} );
Method parseWikitext
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function parseWikitext( $newRevId, array $params ) {
$apiParams = [
'action' => 'parse',
'oldid' => $newRevId,
'prop' => 'text|revid|categorieshtml|sections|displaytitle|subtitle|modules|jsconfigvars',
Function describeChanges
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.dm.MWTransclusionNode.static.describeChanges = function ( attributeChanges ) {
const descriptions = [ ve.msg( 'visualeditor-changedesc-mwtransclusion' ) ];
// This method assumes that the behavior of isDiffComparable above remains
// the same, so it doesn't have to consider whether the actual template
Function generateContents
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ce.MWSignatureNode.prototype.generateContents = function () {
const doc = this.getModel().getDocument();
let abortable, aborted;
const abortedPromise = ve.createDeferred().reject( 'http',
{ textStatus: 'abort', exception: 'abort' } ).promise();
Function initialize
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.EditCheckInspector.prototype.initialize = function () {
// Parent method
ve.ui.EditCheckInspector.super.prototype.initialize.call( this );
// Survey panel
Function act
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.editcheck.AddReferenceEditCheck.prototype.act = function ( choice, action, contextItem ) {
// The complex citoid workflow means that we can't just count on a single "windowAction" here...
const windowAction = ve.ui.actionFactory.create( 'window', contextItem.context.getSurface(), 'check' );
switch ( choice ) {
case 'accept':
Function isSaveable
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWGalleryDialog.prototype.isSaveable = function () {
// Check attributes
if ( this.originalMwDataNormalized ) {
const mwDataCopy = ve.copy( this.selectedNode.getAttribute( 'mw' ) );
this.updateMwData( mwDataCopy );
- 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 wrapText
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
ve.dm.MWWikitextSurfaceFragment.prototype.wrapText = function ( before, after, placeholder, forceWrap ) {
placeholder = OO.ui.resolveMsg( placeholder );
function unwrap( fragment ) {
const text = fragment.getText();
- 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 __construct
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
ApiMain $main,
string $name,
RevisionLookup $revisionLookup,
TempUserCreator $tempUserCreator,
UserFactory $userFactory,
Function syncScalableToType
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
ve.dm.MWImageNode.static.syncScalableToType = function ( type, mediaType, scalable ) {
const defaultThumbSize = mw.config.get( 'wgVisualEditorConfig' )
.thumbLimits[ mw.user.options.get( 'thumbsize' ) ];
const originalDimensions = scalable.getOriginalDimensions();
- 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.dm.MWImageNode.static.isDiffComparable = function ( element, other ) {
// Images with different src's shouldn't be diffed
return element.type === other.type && element.attributes.resource === other.attributes.resource;
};
- 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 70.
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.dm.MWGalleryImageNode.static.isDiffComparable = function ( element, other ) {
// Images with different src's shouldn't be diffed
return element.type === other.type && element.attributes.resource === other.attributes.resource;
};
- 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 70.
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 fetchSpecialCharList
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.Platform.prototype.fetchSpecialCharList = function () {
return mw.loader.using( 'mediawiki.language.specialCharacters' ).then( () => {
const specialCharacterGroups = require( 'mediawiki.language.specialCharacters' ),
characters = {},
otherGroupName = mw.msg( 'visualeditor-special-characters-group-other' ),
Function resolveChangeQueue
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.dm.MWTransclusionModel.prototype.resolveChangeQueue = function ( queue ) {
const resolveQueue = [];
for ( let i = 0; i < queue.length; i++ ) {
const item = queue[ i ];
Function initialize
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWExportWikitextDialog.prototype.initialize = function () {
// Parent method
ve.ui.MWExportWikitextDialog.super.prototype.initialize.call( this );
this.titleInput = new mw.widgets.TitleInputWidget( {
Function getTeardownProcess
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWLinkNodeInspector.prototype.getTeardownProcess = function ( data ) {
data = data || {};
return ve.ui.MWLinkNodeInspector.super.prototype.getTeardownProcess.call( this, data )
.first( () => {
let value = this.targetInput.getValue();
Function VeInitMwDesktopArticleTarget
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.DesktopArticleTarget = function VeInitMwDesktopArticleTarget( config ) {
// Parent constructor
ve.init.mw.DesktopArticleTarget.super.call( this, config );
// Parent constructor bound key event handlers, but we don't want them bound until
Function initialize
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWAddParameterPage.prototype.initialize = function () {
this.template
.connect( this, {
// There is a "change" event, but it triggers way to often even for content changes
add: 'onTemplateParametersChanged',
Function setDiffAndReview
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWSaveDialog.prototype.setDiffAndReview = function ( wikitextDiffPromise, visualDiffGeneratorPromise, baseDoc ) {
this.clearDiff();
function createDiffElement( visualDiff ) {
const diffElement = new ve.ui.DiffElement( visualDiff );