wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

Function onToggleUnusedFields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onToggleUnusedFields = function ( visibility, fromClick ) {
    if ( visibility ) {
        this.createAllParameterCheckboxes();
    }

Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js - About 45 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

Function getRange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWAceEditorWidget.prototype.getRange = function () {
    let lines;
    function posToOffset( row, col ) {
        let offset = 0;

Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js - About 45 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

Function onRequestImagesSuccess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWGalleryDialog.prototype.onRequestImagesSuccess = function ( response ) {
    const thumbUrls = {},
        items = [],
        config = { isMobile: this.isMobile, draggable: !this.isReadOnly() };

Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 45 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

Function getActionProcess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWExtensionWindow.prototype.getActionProcess = function ( action, process ) {
    return process.first( () => {
        if ( action === 'done' ) {
            if ( this.constructor.static.allowedEmpty || this.input.getValue() !== '' ) {
                this.insertOrUpdateNode();
Severity: Minor
Found in modules/ve-mw/ui/ve.ui.MWExtensionWindow.js - About 45 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

Method transformWikitext has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        PageIdentity $page,
        Bcp47Code $targetLanguage,
        string $wikitext,
        bool $bodyOnly,
        ?int $oldid,
Severity: Minor
Found in includes/DirectParsoidClient.php - About 45 mins to fix

    Method onSkinEditSectionLinks has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function onSkinEditSectionLinks( $skin, $title, $section,
            $tooltip, &$result, $lang
    Severity: Minor
    Found in includes/Hooks.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if ( typeof change === 'string' ) {
                              listItem.appendChild( document.createTextNode( change ) );
                          } else {
                              change.forEach( ( node ) => {
                                  listItem.appendChild( node );
      Severity: Major
      Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js - About 45 mins to fix

        Function onBeforePageDisplay has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function onBeforePageDisplay( $output, $skin ): void {
                $services = MediaWikiServices::getInstance();
                $hookRunner = new VisualEditorHookRunner( $services->getHookContainer() );
                if ( !$hookRunner->onVisualEditorBeforeEditor( $output, $skin ) ) {
                    $output->addJsConfigVars( 'wgVisualEditorDisabledByHook', true );
        Severity: Minor
        Found in includes/Hooks.php - About 45 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

        Function onCustomEditor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function onCustomEditor( $article, $user ) {
                $req = $article->getContext()->getRequest();
                $services = MediaWikiServices::getInstance();
                $urlUtils = $services->getUrlUtils();
                $veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' );
        Severity: Minor
        Found in includes/Hooks.php - About 45 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

        Avoid deeply nested control flow statements.
        Open

                                            if ( data && data.action === 'prefer-ve' ) {
                                                location.href = veEditUrl;
                                            } else if ( data && data.action === 'multi-tab' ) {
                                                location.reload();
                                            }
        Severity: Major
        Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 45 mins to fix

          Method onBeforeInitialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  $title, $article, $output, $user, $request, $mediaWiki
          Severity: Minor
          Found in includes/Hooks.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if ( !paramChanges ) {
                                    paramChanges = document.createElement( 'ul' );
                                    descriptions.push( paramChanges );
                                }
            Severity: Major
            Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js - About 45 mins to fix

              Function VeCeMWInlineImageNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.ce.MWInlineImageNode = function VeCeMWInlineImageNode( model, config ) {
                  let $image;
                  let hasHref = false;
              
                  if ( model.getAttribute( 'isError' ) ) {
              Severity: Minor
              Found in modules/ve-mw/ce/nodes/ve.ce.MWInlineImageNode.js - About 45 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

              Function matchLanguage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.dm.MWLanguageVariantNode.static.matchLanguage = function ( items ) {
                  const userVariant = mw.config.get( 'wgUserVariant' ),
                      fallbacks = mw.config.get( 'wgVisualEditor' ).pageVariantFallbacks,
                      languageCodes =
                          ( userVariant ? [ userVariant ] : [] ).concat( fallbacks || [] );
              Severity: Minor
              Found in modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js - About 45 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

              Avoid deeply nested control flow statements.
              Open

                                              if ( confirmed ) {
                                                  return dataPromise;
                                              } else {
                                                  // If they requested the latest version, invalidate the autosave state
                                                  mw.storage.session.remove( 've-docstate' );
              Severity: Major
              Found in modules/ve-mw/preinit/ve.init.mw.ArticleTargetLoader.js - About 45 mins to fix

                Function register has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                mw.editcheck.EditCheckFactory.prototype.register = function ( constructor, name ) {
                    name = name || ( constructor.static && constructor.static.name );
                
                    if ( typeof name !== 'string' || name === '' ) {
                        throw new Error( 'Check names must be strings and must not be empty' );
                Severity: Minor
                Found in editcheck/modules/EditCheckFactory.js - About 45 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 4 locations. Consider refactoring.
                Open

                ve.ui.MWLanguageVariantOneWayInspector = function VeUiMWLanguageVariantOneWayInspector() {
                    ve.ui.MWLanguageVariantOneWayInspector.super.apply( this, arguments );
                };
                modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js on lines 362..364
                modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js on lines 427..429
                modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js on lines 541..543

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

                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 transformWikitext has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        PageIdentity $page,
                        Bcp47Code $targetLanguage,
                        string $wikitext,
                        bool $bodyOnly,
                        ?int $oldid,
                Severity: Minor
                Found in includes/ParsoidClient.php - About 45 mins to fix

                  Function getWikitext has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  ve.dm.MWTransclusionNode.static.getWikitext = function ( content ) {
                      let wikitext = '';
                  
                      // Normalize to multi template format
                      if ( content.params ) {
                  Severity: Minor
                  Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js - About 45 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

                  Avoid deeply nested control flow statements.
                  Open

                                              if ( section ) {
                                                  // switching from visual via the "add section" tab
                                                  target.switchToWikitextSection( section );
                                              } else {
                                                  target.editSource();
                  Severity: Major
                  Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language