wikimedia/mediawiki-extensions-VisualEditor

View on GitHub
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js

Summary

Maintainability
D
1 day
Test Coverage

Function matchFunction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.dm.MWMagicLinkNode.static.matchFunction = function ( element ) {
    const children = element.childNodes,
        href = element.getAttribute( 'href' );
    // All children must be text nodes, or a <span> representing an entity.
    for ( let i = 0; i < children.length; i++ ) {
Severity: Minor
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js - About 25 mins to fix

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 3 locations. Consider refactoring.
Open

ve.dm.MWMagicLinkNode.prototype.getMagicType = function () {
    const content = this.element.attributes.content,
        type = ve.dm.MWMagicLinkType.static.fromContent( content );
    return type.type;
};
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js and 2 other locations - About 2 hrs to fix
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 183..187
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 205..209

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 83.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

ve.dm.MWMagicLinkNode.prototype.getCode = function () {
    const content = this.element.attributes.content,
        type = ve.dm.MWMagicLinkType.static.fromContent( content );
    return type.num;
};
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js and 2 other locations - About 2 hrs to fix
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 183..187
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 194..198

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 83.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

ve.dm.MWMagicLinkNode.prototype.getRel = function () {
    const content = this.element.attributes.content,
        type = ve.dm.MWMagicLinkType.static.fromContent( content );
    return type.rel;
};
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js and 2 other locations - About 2 hrs to fix
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 194..198
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 205..209

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 83.

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

Further Reading

Similar blocks of code found in 12 locations. Consider refactoring.
Open

ve.dm.MWMagicLinkNode = function VeDmMWMagicLinkNode() {
    // Parent constructor
    ve.dm.MWMagicLinkNode.super.apply( this, arguments );

    // Mixin constructors
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js and 11 other locations - About 2 hrs to fix
modules/ve-mw/ce/nodes/ve.ce.MWAlienBlockExtensionNode.js on lines 20..26
modules/ve-mw/ce/nodes/ve.ce.MWImageCaptionNode.js on lines 19..25
modules/ve-mw/dm/nodes/ve.dm.MWAlienBlockExtensionNode.js on lines 20..26
modules/ve-mw/dm/nodes/ve.dm.MWAlienInlineExtensionNode.js on lines 19..25
modules/ve-mw/dm/nodes/ve.dm.MWGalleryNode.js on lines 18..24
modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js on lines 18..24
modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js on lines 19..25
modules/ve-mw/dm/nodes/ve.dm.MWNumberedExternalLinkNode.js on lines 18..24
modules/ve-mw/dm/nodes/ve.dm.MWTableNode.js on lines 19..25
modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 19..25
modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js on lines 19..25

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 76.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

ve.dm.MWMagicLinkRfcType = function VeDmMWMagicLinkRfcType( content ) {
    // Parent constructor
    ve.dm.MWMagicLinkRfcType.super.call( this, 'RFC', 'mw:ExtLink', content );
};
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js and 2 other locations - About 55 mins to fix
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 307..310
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 383..386

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 53.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

ve.dm.MWMagicLinkIsbnType = function VeDmMWMagicLinkIsbnType( content ) {
    // Parent constructor
    ve.dm.MWMagicLinkIsbnType.super.call( this, 'ISBN', 'mw:WikiLink', content );
};
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js and 2 other locations - About 55 mins to fix
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 383..386
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 404..407

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 53.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

ve.dm.MWMagicLinkPmidType = function VeDmMWMagicLinkPmidType( content ) {
    // Parent constructor
    ve.dm.MWMagicLinkPmidType.super.call( this, 'PMID', 'mw:ExtLink', content );
};
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js and 2 other locations - About 55 mins to fix
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 307..310
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 404..407

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 53.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

ve.dm.MWMagicLinkPmidType.prototype.getHref = function () {
    return mw.msg( 'pubmedurl', this.code );
};
Severity: Minor
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js and 1 other location - About 35 mins to fix
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 411..413

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 46.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

ve.dm.MWMagicLinkRfcType.prototype.getHref = function () {
    return mw.msg( 'rfcurl', this.code );
};
Severity: Minor
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js and 1 other location - About 35 mins to fix
modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.js on lines 390..392

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 46.

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

Further Reading

There are no issues that match your filters.

Category
Status