wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

File ve.dm.MWTransclusionModel.js has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * VisualEditor DataModel MWTransclusionModel class.
 *
 * @copyright See AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
Severity: Minor
Found in modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js - About 3 hrs to fix

    Function exports has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function () {
        const veDone = arguments[ arguments.length - 1 ];
    
        window.seleniumUtils = {
            getBoundingRect: function ( elements ) {
    Severity: Major
    Found in build/screenshots-client/utils.js - About 3 hrs to fix

      Function VeUiMWAdvancedSettingsPage has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.ui.MWAdvancedSettingsPage = function VeUiMWAdvancedSettingsPage( name, config ) {
          // Parent constructor
          ve.ui.MWAdvancedSettingsPage.super.apply( this, arguments );
      
          // Properties
      Severity: Major
      Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js - About 3 hrs to fix

        exports has 31 functions (exceeds 20 allowed). Consider refactoring.
        Open

        module.exports = {
            toolbar: function () {
                const done = arguments[ arguments.length - 1 ];
                // HACK: The test page is on the help namespace, so overwrite the
                // read tab with the nstab-main message.
        Severity: Minor
        Found in build/screenshots-client/userGuide.js - About 3 hrs to fix

          Function VeUiMWParameterPage has 95 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.ui.MWParameterPage = function VeUiMWParameterPage( parameter, config ) {
              const paramName = parameter.getName();
          
              // Configuration initialization
              config = ve.extendObject( {
          Severity: Major
          Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 3 hrs to fix

            File ve.ui.MWLinkAnnotationInspector.js has 323 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*!
             * VisualEditor UserInterface LinkAnnotationInspector class.
             *
             * @copyright See AUTHORS.txt
             * @license The MIT License (MIT); see LICENSE.txt
            Severity: Minor
            Found in modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js - About 3 hrs to fix

              Function processQueue has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.init.mw.ApiResponseCache.prototype.processQueue = function () {
                  const rejectSubqueue = ( rejectQueue ) => {
                      for ( let i = 0, len = rejectQueue.length; i < len; i++ ) {
                          this.deferreds[ rejectQueue[ i ] ].reject();
                      }
              Severity: Minor
              Found in modules/ve-mw/init/apiresponsecache/ve.init.mw.ApiResponseCache.js - About 3 hrs 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 toDomElements has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.dm.MWGalleryImageNode.static.toDomElements = function ( data, doc, converter ) {
                  // ImageNode:
                  //   <li> li (gallerybox)
                  //     <div> thumbDiv
                  //       <span> container
              Severity: Minor
              Found in modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js - About 3 hrs 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 toDomElements has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.dm.MWInlineImageNode.static.toDomElements = function ( dataElement, doc, converter ) {
                  const attributes = dataElement.attributes,
                      container = doc.createElement( 'span' ),
                      imgWrapper = doc.createElement( attributes.href ? 'a' : 'span' ),
                      img = doc.createElement( attributes.isError ? 'span' : attributes.mediaTag ),
              Severity: Minor
              Found in modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js - About 3 hrs 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 2 locations. Consider refactoring.
              Open

              ve.dm.MWGalleryCaptionNode.static.matchFunction = function ( element ) {
                  const parentTypeof = ( element.parentNode && element.parentNode.getAttribute( 'typeof' ) ) || '';
                  return element.getAttribute( 'class' ) === 'gallerycaption' &&
                      parentTypeof.trim().split( /\s+/ ).indexOf( 'mw:Extension/gallery' ) !== -1;
              };
              Severity: Major
              Found in modules/ve-mw/dm/nodes/ve.dm.MWGalleryCaptionNode.js and 1 other location - About 3 hrs to fix
              modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js on lines 35..39

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

              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.MWGalleryImageNode.static.matchFunction = function ( element ) {
                  const parentTypeof = ( element.parentNode && element.parentNode.getAttribute( 'typeof' ) ) || '';
                  return element.getAttribute( 'class' ) === 'gallerybox' &&
                      parentTypeof.trim().split( /\s+/ ).indexOf( 'mw:Extension/gallery' ) !== -1;
              };
              Severity: Major
              Found in modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js and 1 other location - About 3 hrs to fix
              modules/ve-mw/dm/nodes/ve.dm.MWGalleryCaptionNode.js on lines 29..33

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

              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

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

                  {
                      name: 'style',
                      classes: [ 've-test-toolbar-style' ],
                      type: 'list',
                      icon: 'textStyle',
              Severity: Major
              Found in modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js and 1 other location - About 3 hrs to fix
              modules/ve-mw-collab/ve.init.mw.MobileCollabTarget.js on lines 48..60

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

              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

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

                  {
                      name: 'style',
                      classes: [ 've-test-toolbar-style' ],
                      type: 'list',
                      icon: 'textStyle',
              Severity: Major
              Found in modules/ve-mw-collab/ve.init.mw.MobileCollabTarget.js and 1 other location - About 3 hrs to fix
              modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js on lines 61..73

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

              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.init.mw.DesktopArticleTarget.prototype.switchToWikitextEditor = function () {
                  // Parent method
                  ve.init.mw.DesktopArticleTarget.super.prototype.switchToWikitextEditor.apply( this, arguments );
              
                  if ( this.isModeAvailable( 'source' ) ) {
              modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js on lines 1381..1388

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

              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.init.mw.DesktopArticleTarget.prototype.switchToVisualEditor = function () {
                  // Parent method
                  ve.init.mw.DesktopArticleTarget.super.prototype.switchToVisualEditor.apply( this, arguments );
              
                  if ( this.isModeAvailable( 'visual' ) ) {
              modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js on lines 1393..1400

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

              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

              Function saveFail has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.init.mw.ArticleTarget.prototype.saveFail = function ( doc, saveData, code, data ) {
                  this.pageDeletedWarning = false;
              
                  let handled = false;
                  // Handle empty response
              Severity: Minor
              Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 3 hrs 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 getSetupProcess has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.ui.MWGalleryDialog.prototype.getSetupProcess = function ( data ) {
                  return ve.ui.MWGalleryDialog.super.prototype.getSetupProcess.call( this, data )
                      .next( () => {
                          const namespaceIds = mw.config.get( 'wgNamespaceIds' ),
                              mwData = this.selectedNode && this.selectedNode.getAttribute( 'mw' ),
              Severity: Minor
              Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 3 hrs 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 postContent has 88 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      postContent: function ( data, options ) {
                          options = options || {};
                          const api = options.api || new mw.Api();
              
                          let start;
              Severity: Major
              Found in modules/ve-mw/preinit/ve.init.mw.ArticleTargetSaver.js - About 3 hrs to fix

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

                ve.init.mw.DesktopArticleTarget.prototype.unbindHandlers = function () {
                    ve.init.mw.DesktopArticleTarget.super.prototype.unbindHandlers.call( this );
                    if ( this.onWatchToggleHandler ) {
                        mw.hook( 'wikipage.watchlistChange' ).remove( this.onWatchToggleHandler );
                    }
                modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js on lines 363..368

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

                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.init.mw.DesktopArticleTarget.prototype.bindHandlers = function () {
                    ve.init.mw.DesktopArticleTarget.super.prototype.bindHandlers.call( this );
                    if ( this.onWatchToggleHandler ) {
                        mw.hook( 'wikipage.watchlistChange' ).add( this.onWatchToggleHandler );
                    }
                modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js on lines 373..378

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

                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