wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

Function getSaveFields has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget.prototype.getSaveFields = function () {
    const fields = {};

    if ( this.section === 'new' ) {
        // MediaWiki action=edit UI doesn't have separate parameters for edit summary and new section
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr 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

Function parseDocument has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.Target.static.parseDocument = function ( documentString, mode, section, onlySection ) {
    let doc;
    if ( mode === 'source' ) {
        // Parent method
        doc = ve.init.mw.Target.super.static.parseDocument.call( this, documentString, mode );
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.Target.js - About 1 hr 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

Function onWindowPopState has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.DesktopArticleTarget.prototype.onWindowPopState = function ( e ) {
    if ( !this.verifyPopState( e.state ) ) {
        // Ignore popstate events fired for states not created by us
        // This also filters out the initial fire in Chrome (T59901).
        return;
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 1 hr 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

Function parseMetadata has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget.prototype.parseMetadata = function ( response ) {
    const data = response ? ( response.visualeditor || response.visualeditoredit ) : null;

    if ( !data ) {
        this.loadFail( 've-api', { errors: [ {
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr 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

Function loadSuccess has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
    const data = response ? ( response.visualeditor || response.visualeditoredit ) : null;

    if ( !data || typeof data.content !== 'string' ) {
        this.loadFail( 've-api', { errors: [ {
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr 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

Function getAllParametersOrdered has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

ve.dm.MWTemplateModel.prototype.getAllParametersOrdered = function () {
    const spec = this.spec,
        usedAliases = {};

    let primaryName;
Severity: Minor
Found in modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js - About 1 hr 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

Function setTemplateData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

ve.dm.MWTemplateSpecModel.prototype.setTemplateData = function ( data ) {
    if ( !data || !ve.isPlainObject( data ) ) {
        return;
    }

Severity: Minor
Found in modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js - About 1 hr 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

Function insertOrUpdateNode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWGalleryDialog.prototype.insertOrUpdateNode = function () {
    const surfaceModel = this.getFragment().getSurface(),
        surfaceModelDocument = surfaceModel.getDocument(),
        items = this.galleryGroup.items,
        data = [];
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 1 hr 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

Function VeCeMWGalleryImageNode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

ve.ce.MWGalleryImageNode = function VeCeMWGalleryImageNode( model ) {
    // Parent constructor
    ve.ce.MWGalleryImageNode.super.apply( this, arguments );

    // DOM hierarchy for MWGalleryImageNode:
Severity: Minor
Found in modules/ve-mw/ce/nodes/ve.ce.MWGalleryImageNode.js - About 1 hr 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

Function findAddedContent has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

mw.editcheck.AddReferenceEditCheck.prototype.findAddedContent = function ( documentModel, includeReferencedContent ) {
    // Broken out so a helper for tagging can call it
    const ranges = this.getModifiedContentRanges( documentModel ).filter( ( range ) => {
        if ( !includeReferencedContent ) {
            // 4. Exclude any ranges that already contain references
Severity: Minor
Found in editcheck/modules/AddReferenceEditCheck.js - About 1 hr 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

Function checkRequiredParameters has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ve.ui.MWTemplateDialog.prototype.checkRequiredParameters = function () {
    const blankRequired = [],
        deferred = ve.createDeferred();

    this.bookletLayout.stackLayout.getItems().forEach( ( page ) => {
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js - About 1 hr to fix

    Function createItem has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ve.ui.MWLanguageVariantTwoWayInspector.prototype.createItem = function ( lang, content ) {
        const languageInput = new ve.ui.LanguageInputWidget( {
            dialogManager: this.manager.getSurface().getDialogs(),
            dirInput: 'none'
        } );
    Severity: Minor
    Found in modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js - About 1 hr to fix

      Function onSaveDialogPreview has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.init.mw.ArticleTarget.prototype.onSaveDialogPreview = function () {
          const api = this.getContentApi();
      
          if ( !this.saveDialog.$previewViewer.children().length ) {
              this.emit( 'savePreview' );
      Severity: Minor
      Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr to fix

        Function teardown has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.ui.MWCategoriesPage.prototype.teardown = function ( data ) {
            const currentDefaultSortKeyItem = this.getDefaultSortKeyItem(),
                newDefaultSortKey = this.defaultSortInput.getValue();
        
            if ( data && data.action === 'done' ) {
        Severity: Minor
        Found in modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js - About 1 hr to fix

          Method getAllowedParams has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getAllowedParams() {
                  return [
                      'page' => [
                          ParamValidator::PARAM_REQUIRED => true,
                      ],
          Severity: Minor
          Found in includes/ApiVisualEditor.php - About 1 hr to fix

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

            ve.ui.wikitextCommandRegistry.register(
                new ve.ui.Command(
                    'code', 'mwWikitext', 'toggleWrapSelection',
                    { args: [ '<code>', '</code>', OO.ui.deferMsg( 'visualeditor-annotationbutton-code-tooltip' ) ], supportedSelections: [ 'linear' ] }
                )
            Severity: Major
            Found in modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js and 8 other locations - About 1 hr to fix
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 104..109
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 110..115
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 116..121
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 122..127
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 128..133
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 134..139
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 193..198
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 222..227

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

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

            ve.ui.wikitextCommandRegistry.register(
                new ve.ui.Command(
                    'subscript', 'mwWikitext', 'toggleWrapSelection',
                    { args: [ '<sub>', '</sub>', OO.ui.deferMsg( 'visualeditor-annotationbutton-subscript-tooltip' ) ], supportedSelections: [ 'linear' ] }
                )
            Severity: Major
            Found in modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js and 8 other locations - About 1 hr to fix
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 98..103
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 104..109
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 110..115
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 122..127
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 128..133
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 134..139
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 193..198
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 222..227

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

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

            ve.ui.wikitextCommandRegistry.register(
                new ve.ui.Command(
                    'strikethrough', 'mwWikitext', 'toggleWrapSelection',
                    { args: [ '<s>', '</s>', OO.ui.deferMsg( 'visualeditor-annotationbutton-strikethrough-tooltip' ) ], supportedSelections: [ 'linear' ] }
                )
            Severity: Major
            Found in modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js and 8 other locations - About 1 hr to fix
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 98..103
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 110..115
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 116..121
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 122..127
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 128..133
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 134..139
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 193..198
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 222..227

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

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

            ve.ui.wikitextCommandRegistry.register(
                new ve.ui.Command(
                    'underline', 'mwWikitext', 'toggleWrapSelection',
                    { args: [ '<u>', '</u>', OO.ui.deferMsg( 'visualeditor-annotationbutton-underline-tooltip' ) ], supportedSelections: [ 'linear' ] }
                )
            Severity: Major
            Found in modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js and 8 other locations - About 1 hr to fix
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 98..103
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 104..109
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 116..121
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 122..127
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 128..133
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 134..139
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 193..198
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 222..227

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

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

            ve.ui.wikitextCommandRegistry.register(
                new ve.ui.Command(
                    'small', 'mwWikitext', 'toggleWrapSelection',
                    { args: [ '<small>', '</small>', OO.ui.deferMsg( 'visualeditor-annotationbutton-small-tooltip' ) ], supportedSelections: [ 'linear' ] }
                )
            Severity: Major
            Found in modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js and 8 other locations - About 1 hr to fix
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 98..103
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 104..109
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 110..115
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 116..121
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 122..127
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 128..133
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 193..198
            modules/ve-mw/ui/ve.ui.MWWikitextCommandRegistry.js on lines 222..227

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

            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

            Severity
            Category
            Status
            Source
            Language