wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

Method execute has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function execute( $subPage ) {
        $this->setHeaders();
        $this->checkPermissions();

        $output = $this->getOutput();
Severity: Major
Found in includes/SpecialCollabPad.php - About 3 hrs to fix

    Function createScreenshotEnvironment has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function createScreenshotEnvironment( test ) {
        let clientSize, driver;
    
        test.beforeEach( function () {
            const lang = this.currentTest.parent.lang || 'en';
    Severity: Major
    Found in build/screenshots.js - About 3 hrs to fix

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

      ve.ui.MWLinkNodeInspector.prototype.getReadyProcess = function ( data ) {
          return ve.ui.MWLinkNodeInspector.super.prototype.getReadyProcess.call( this, data )
              .next( () => {
                  this.targetInput.focus().select();
              } );
      Severity: Major
      Found in modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js and 1 other location - About 3 hrs to fix
      modules/ve-mw/ui/inspectors/ve.ui.MWMagicLinkNodeInspector.js on lines 135..140

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

      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.ui.MWMagicLinkNodeInspector.prototype.getReadyProcess = function ( data ) {
          return ve.ui.MWMagicLinkNodeInspector.super.prototype.getReadyProcess.call( this, data )
              .next( () => {
                  this.targetInput.focus().select();
              } );
      modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js on lines 90..95

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

      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 teardown has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.ui.MWAdvancedSettingsPage.prototype.teardown = function ( data ) {
          // Data initialization
          data = data || {};
          if ( data.action !== 'done' ) {
              return;
      Severity: Major
      Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js - About 3 hrs to fix

        Function restorePage has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        ve.init.mw.DesktopArticleTarget.prototype.restorePage = function () {
            // Restore any previous redirectMsg/redirectsub
            this.setRealRedirectInterface();
            if ( this.$originalCategories ) {
                $( '#catlinks' ).replaceWith( this.$originalCategories );
        Severity: Minor
        Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.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 toDataElement has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter ) {
            const figure = domElements[ 0 ];
            const img = figure.querySelector( '.mw-file-element' ); // <img>, <video>, <audio>, or <span> if mw:Error
            // Images copied from the old parser output can have typeof=mw:Image but no resource information. T337438
            if ( !img || !img.hasAttribute( 'resource' ) ) {
        Severity: Major
        Found in modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js - About 3 hrs to fix

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

          ve.dm.MWBlockImageNode = function VeDmMWBlockImageNode() {
              // Parent constructor
              ve.dm.MWBlockImageNode.super.apply( this, arguments );
          
              // Mixin constructors
          Severity: Major
          Found in modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js and 2 other locations - About 3 hrs to fix
          modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js on lines 19..26
          modules/ve-mw/dm/nodes/ve.dm.MWSignatureNode.js on lines 19..26

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

          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.MWSignatureNode = function VeDmMWSignatureNode() {
              // Parent constructor
              ve.dm.MWSignatureNode.super.apply( this, arguments );
          
              // Mixin constructors
          Severity: Major
          Found in modules/ve-mw/dm/nodes/ve.dm.MWSignatureNode.js and 2 other locations - About 3 hrs to fix
          modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js on lines 20..27
          modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js on lines 19..26

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

          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.MWExtensionNode = function VeDmMWExtensionNode() {
              // Parent constructor
              ve.dm.MWExtensionNode.super.apply( this, arguments );
          
              // Mixin constructors
          Severity: Major
          Found in modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js and 2 other locations - About 3 hrs to fix
          modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js on lines 20..27
          modules/ve-mw/dm/nodes/ve.dm.MWSignatureNode.js on lines 19..26

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

          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 toDataElement has 74 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.dm.MWInlineImageNode.static.toDataElement = function ( domElements, converter ) {
              const container = domElements[ 0 ]; // <span>
              if ( !container.children.length ) {
                  // Malformed image, alienate (T267282)
                  return null;
          Severity: Major
          Found in modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js - About 2 hrs to fix

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

            ve.dm.MWTemplateSpecModel.prototype.getParameterExampleValue = function ( name, languageCode ) {
                const param = this.templateData.params[ this.getPrimaryParameterName( name ) ];
                return this.constructor.static.getLocalValue( param && param.example || null, languageCode );
            };
            Severity: Major
            Found in modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js and 1 other location - About 2 hrs to fix
            modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js on lines 318..321

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

            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.MWTemplateSpecModel.prototype.getParameterDescription = function ( name, languageCode ) {
                const param = this.templateData.params[ this.getPrimaryParameterName( name ) ];
                return this.constructor.static.getLocalValue( param && param.description || null, languageCode );
            };
            Severity: Major
            Found in modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js and 1 other location - About 2 hrs to fix
            modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js on lines 349..352

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

            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

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

                public function getAllowedParams() {
                    return [
                        'paction' => [
                            ParamValidator::PARAM_REQUIRED => true,
                            ParamValidator::PARAM_TYPE => [
            Severity: Major
            Found in includes/ApiVisualEditorEdit.php - About 2 hrs to fix

              Function VeUiMWTemplatePage has 70 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ve.ui.MWTemplatePage = function VeUiMWTemplatePage( template, name, config ) {
                  const link = template.getTemplateDataQueryTitle();
              
                  // Configuration initialization
                  config = ve.extendObject( {
              Severity: Major
              Found in modules/ve-mw/ui/pages/ve.ui.MWTemplatePage.js - About 2 hrs to fix

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

                ve.ce.MWIncludesNode = function VeCeMWIncludesNode() {
                    // Parent constructor
                    ve.ce.MWIncludesNode.super.apply( this, arguments );
                
                    // DOM changes
                Severity: Major
                Found in modules/ve-mw/ce/nodes/ve.ce.MWIncludesNode.js and 1 other location - About 2 hrs to fix
                modules/ve-mw/ce/nodes/ve.ce.MWAnnotationNode.js on lines 17..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 91.

                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.ce.MWAnnotationNode = function VeCeMWAnnotationNode() {
                    // Parent constructor
                    ve.ce.MWAnnotationNode.super.apply( this, arguments );
                
                    // DOM changes
                Severity: Major
                Found in modules/ve-mw/ce/nodes/ve.ce.MWAnnotationNode.js and 1 other location - About 2 hrs to fix
                modules/ve-mw/ce/nodes/ve.ce.MWIncludesNode.js on lines 17..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 91.

                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 addExactMatch has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                ve.ui.MWTemplateTitleInputWidget.prototype.addExactMatch = function ( response ) {
                    const query = this.getQueryValue(),
                        title = mw.Title.newFromText( query, this.namespace );
                    // No point in trying anything when the title is invalid
                    if ( !title ) {
                Severity: Major
                Found in modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js - About 2 hrs to fix

                  Function getVisualDiffGeneratorPromise has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  ve.init.mw.ArticleTarget.prototype.getVisualDiffGeneratorPromise = function () {
                      return mw.loader.using( 'ext.visualEditor.diffLoader' ).then( () => {
                          const mode = this.getSurface().getMode();
                  
                          if ( !this.originalDmDocPromise ) {
                  Severity: Minor
                  Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 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 exports has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  module.exports = function () {
                      const veDone = arguments[ arguments.length - 1 ];
                  
                      window.seleniumUtils = {
                          getBoundingRect: function ( elements ) {
                  Severity: Minor
                  Found in build/screenshots-client/utils.js - About 2 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

                  Severity
                  Category
                  Status
                  Source
                  Language