wikimedia/mediawiki-extensions-MobileFrontend

View on GitHub

Showing 166 of 183 total issues

Method isSupportedEditRequest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected static function isSupportedEditRequest( IContextSource $context ) {
        /** @var MobileContext $mobileContext */
        $mobileContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
        if ( !$mobileContext->shouldDisplayMobileView() ) {
            return false;
Severity: Minor
Found in includes/MobileFrontendEditorHooks.php - About 1 hr to fix

    Function scrollToLeadParagraph has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        scrollToLeadParagraph: function () {
            let editLead, editLeadView, readLead, offset, initialCursorOffset;
    
            const
                currentPageHTMLParser = this.options.currentPageHTMLParser,
    Severity: Minor
    Found in src/mobile.editor.overlay/VisualEditorOverlay.js - About 1 hr to fix

      Function getButtonConfig has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getButtonConfig() {
              let cta = true;
              const config = {
                      progressive: true
                  },
      Severity: Minor
      Found in src/mobile.editor.overlay/BlockMessageDetails.js - About 1 hr to fix

        Method identifyInfoboxElement has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function identifyInfoboxElement( DOMXPath $xPath, DOMElement $section ): ?DOMElement {
                $paths = [
                    // Infoboxes: *.infobox
                    './/*[contains(concat(" ",normalize-space(@class)," ")," infobox ")]',
                    // Thumbnail images: .thumb, figure (Parsoid)
        Severity: Minor
        Found in includes/Transforms/MoveLeadParagraphTransform.php - About 1 hr to fix

          Method onCustomEditor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function onCustomEditor( $article, $user ) {
                  $req = $article->getContext()->getRequest();
                  $title = $article->getTitle();
                  if (
                      !$req->getVal( 'mfnoscript' ) &&
          Severity: Minor
          Found in includes/MobileFrontendEditorHooks.php - About 1 hr to fix

            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

              Method shouldDisplayMobileViewInternal has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function shouldDisplayMobileViewInternal() {
                      // May be overridden programmatically
                      if ( $this->forceMobileView ) {
                          return true;
                      }
              Severity: Minor
              Found in includes/MobileContext.php - About 1 hr to fix

                Function getLicenseMsg has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    getLicenseMsg() {
                        const $licenseLinks = this.getLicenseLinks();
                
                        let licenseMsg;
                        if ( $licenseLinks.length ) {
                Severity: Minor
                Found in src/mobile.startup/Skin.js - About 1 hr to fix

                  Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          HookContainer $hookContainer,
                          Config $config,
                          SkinFactory $skinFactory,
                          UserOptionsLookup $userOptionsLookup,
                          WatchlistManager $watchlistManager,
                  Severity: Major
                  Found in includes/MobileFrontendHooks.php - About 1 hr to fix

                    Function exports has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    module.exports = function () {
                        const
                            currentPage = require( '../mobile.startup/currentPage' )(),
                            Toggler = require( '../mobile.startup/Toggler' ),
                            sectionCollapsing = require( '../mobile.startup/sectionCollapsing' ),
                    Severity: Minor
                    Found in src/mobile.init/toggling.js - About 55 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 makeSections has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function makeSections( DOMElement $body, array $headingWrappers ) {
                            $ownerDocument = $body->ownerDocument;
                            if ( $ownerDocument === null ) {
                                return;
                            }
                    Severity: Minor
                    Found in includes/Transforms/MakeSectionsTransform.php - About 55 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 executeViewEditWatchlist has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function executeViewEditWatchlist() {
                            $ns = NS_MAIN;
                            $images = [];
                    
                            $watchlist = $this->getWatchlistInfo();
                    Severity: Minor
                    Found in includes/specials/SpecialMobileEditWatchlist.php - About 55 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 showReference has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        showReference( id, page, refNumber, pageHTMLParser, gateway, props,
                            onShowNestedReference
                    Severity: Major
                    Found in src/mobile.startup/references/references.js - About 50 mins 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

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

                      function initMobileOptions() {
                          const $form = $( '#mobile-options' ),
                              $betaToggle = $( '#enable-beta-toggle' ),
                              $amcToggle = $( '#enable-amc-toggle' ),
                              toggles = [];
                      Severity: Minor
                      Found in src/mobile.special.mobileoptions.scripts.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 parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function parse( resp ) {
                          let displayTitle;
                          const thumb = resp.thumbnail,
                              pageprops = resp.pageprops || {
                                  displaytitle: mw.html.escape( resp.title )
                      Severity: Minor
                      Found in src/mobile.startup/page/pageJSONParser.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 getMobileUrl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function getMobileUrl( $url, $forceHttps = false ) {
                              $urlUtils = MediaWikiServices::getInstance()->getUrlUtils();
                              $parsedUrl = $urlUtils->parse( $url );
                              // if parsing failed, maybe it's a local Url, try to expand and reparse it - task T107505
                              if ( !$parsedUrl ) {
                      Severity: Minor
                      Found in includes/MobileContext.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

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

                          public function onMediaWikiPerformAction( $output, $article, $title, $user,
                              $request, $entryPoint
                      Severity: Minor
                      Found in includes/MobileFrontendHooks.php - About 45 mins to fix

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

                            protected static function isSupportedEditRequest( IContextSource $context ) {
                                /** @var MobileContext $mobileContext */
                                $mobileContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
                                if ( !$mobileContext->shouldDisplayMobileView() ) {
                                    return false;
                        Severity: Minor
                        Found in includes/MobileFrontendEditorHooks.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 createPromoCampaign has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            onShow,
                            actions,
                            campaignName,
                            campaignActive,
                            userEligible,
                        Severity: Minor
                        Found in src/mobile.startup/promoCampaign/promoCampaign.js - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language