wikimedia/mediawiki-extensions-MobileFrontend

View on GitHub
src/mobile.init/editor.js

Summary

Maintainability
D
2 days
Test Coverage

Function setupEditor has 226 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function setupEditor( page, skin, currentPageHTMLParser, router ) {
    const
        overlayManager = OverlayManager.getSingleton(),
        isNewPage = page.id === 0;

Severity: Major
Found in src/mobile.init/editor.js - About 1 day to fix

    File editor.js has 357 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* global $ */
    const M = require( '../mobile.startup/moduleLoaderSingleton' ),
        util = require( '../mobile.startup/util' ),
        editorLoadingOverlay = require( './editorLoadingOverlay' ),
        OverlayManager = require( '../mobile.startup/OverlayManager' ),
    Severity: Minor
    Found in src/mobile.init/editor.js - About 4 hrs to fix

      Function loadVisualEditorMaybe has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function loadVisualEditorMaybe() {
                  logInit( 'visualeditor' );
                  // Inform other interested code that we're loading the editor
                  /**
                   * Internal for use in GrowthExperiments only.
      Severity: Minor
      Found in src/mobile.init/editor.js - About 1 hr to fix

        Function showLoading has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                function showLoading() {
                    let $sectionTop, fakeScroll, enableVisualSectionEditing;
        
                    $( document.body ).addClass( 've-loading' );
        
        
        Severity: Minor
        Found in src/mobile.init/editor.js - About 1 hr to fix

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

          function getPreferredEditor() {
              if ( editorOverride ) {
                  // Temporary override, set via the URL for this request
                  // or by clicking the chosen mode when both tabs are shown
                  return editorOverride;
          Severity: Minor
          Found in src/mobile.init/editor.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 setupEditor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function setupEditor( page, skin, currentPageHTMLParser, router ) {
              const
                  overlayManager = OverlayManager.getSingleton(),
                  isNewPage = page.id === 0;
          
          
          Severity: Minor
          Found in src/mobile.init/editor.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 onEditLinkClick has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function onEditLinkClick( elem, ev, router ) {
              let section;
              if ( $( EDITSECTION_SELECTOR ).length === 0 ) {
                  // If section edit links are not available, the only edit link
                  // should allow editing the whole page (T232170)
          Severity: Minor
          Found in src/mobile.init/editor.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 bindEditLinksLoginDrawer has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function bindEditLinksLoginDrawer( router ) {
              let drawer;
              function showLoginDrawer() {
                  if ( !drawer ) {
                      drawer = new CtaDrawer( {
          Severity: Minor
          Found in src/mobile.init/editor.js - About 1 hr to fix

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

            function init( currentPage, currentPageHTMLParser, skin, router ) {
                let editErrorMessage, editRestrictions;
                // see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific
                const isReadOnly = mw.config.get( 'wgMinervaReadOnly' );
                const isEditable = !isReadOnly && mw.config.get( 'wgIsProbablyEditable' );
            Severity: Minor
            Found in src/mobile.init/editor.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 too many return statements within this function.
            Open

                return 'SourceEditor';
            Severity: Major
            Found in src/mobile.init/editor.js - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status