wikimedia/mediawiki-extensions-MobileFrontend

View on GitHub

Showing 166 of 183 total issues

Method domParseMobile has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function domParseMobile( OutputPage $out, $html = '' ) {
        $services = MediaWikiServices::getInstance();
        /** @var FeaturesManager $featuresManager */
        $featuresManager = $services->getService( 'MobileFrontend.FeaturesManager' );
        /** @var MobileContext $context */
Severity: Major
Found in includes/ExtMobileFrontend.php - About 2 hrs to fix

    Function editorLoadingOverlay has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function editorLoadingOverlay( afterShow, afterHide, loadBasicEditor ) {
        let timeout;
        const
            $fakeToolbar = fakeToolbar(),
            $loadBasicWrapper = $( '<div>' ).addClass( 've-loadbasiceditor' ),
    Severity: Major
    Found in src/mobile.init/editorLoadingOverlay.js - About 2 hrs to fix

      Method detectMobileDevice has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function detectMobileDevice( $userAgent ) {
              $patterns = [
                  'mobi',
                  '240x240',
                  '240x320',
      Severity: Major
      Found in includes/Devices/UADeviceDetector.php - About 2 hrs to fix

        Function postRender has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            postRender: function () {
                let
                    $img;
                const
                    $el = this.$el,
        Severity: Major
        Found in src/mobile.mediaViewer/ImageCarousel.js - About 2 hrs to fix

          Function template has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              get template() {
                  return util.template( `
          <div class="block-message block-message-container">
            <div class="block-message-icon"></div>
            <div class="block-message-info">
          Severity: Major
          Found in src/mobile.editor.overlay/BlockMessageDetails.js - About 2 hrs to fix

            Function getStructuredLanguages has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                getStructuredLanguages: function (
                    languages,
                    variants,
                    frequentlyUsedLanguages,
                    showSuggestedLanguages,
            Severity: Major
            Found in src/mobile.languages.structured/util.js - About 2 hrs to fix

              Function getContent has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  getContent: function () {
                      let options;
              
                      const self = this;
              
              
              Severity: Major
              Found in src/mobile.editor.overlay/EditorGateway.js - About 2 hrs to fix

                Method executeViewEditWatchlist has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function executeViewEditWatchlist() {
                        $ns = NS_MAIN;
                        $images = [];
                
                        $watchlist = $this->getWatchlistInfo();
                Severity: Major
                Found in includes/specials/SpecialMobileEditWatchlist.php - About 2 hrs to fix

                  Function parseBlockInfo has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function parseBlockInfo( blockinfo ) {
                      const blockInfo = {
                          partial: blockinfo.blockpartial || false,
                          noCreateAccount: blockinfo.blocknocreate || false,
                          anonOnly: blockinfo.blockanononly === undefined ? true : blockinfo.blockanononly,
                  Severity: Major
                  Found in src/mobile.editor.overlay/parseBlockInfo.js - About 2 hrs to fix

                    Function amcOutreachDrawer has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    module.exports = function amcOutreachDrawer(
                        action,
                        promoCampaign,
                        mwMessage,
                        mwUtil,
                    Severity: Major
                    Found in src/mobile.startup/amcOutreach/amcOutreachDrawer.js - About 2 hrs to fix

                      Method submitSettingsForm has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function submitSettingsForm() {
                              $request = $this->getRequest();
                              $user = $this->getUser();
                      
                              if ( $user->isRegistered() && !$user->matchEditToken( $request->getVal( 'token' ) ) ) {
                      Severity: Major
                      Found in includes/specials/SpecialMobileOptions.php - About 2 hrs to fix

                        Method doRewriteImagesForLazyLoading has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function doRewriteImagesForLazyLoading( $el, ?DOMDocument $doc ) {
                                if ( $doc === null ) {
                                    return;
                                }
                                $lazyLoadSkipSmallImages = $this->skipSmall;
                        Severity: Minor
                        Found in includes/Transforms/LazyImageTransform.php - About 2 hrs to fix

                          Function referenceDrawer has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function referenceDrawer( props ) {
                              const errorIcon = props.error ? new IconButton( {
                                  name: 'error',
                                  isSmall: true
                              } ).$el : null;
                          Severity: Minor
                          Found in src/mobile.startup/references/references.js - About 2 hrs to fix

                            Function createAnonWarning has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                createAnonWarning: function ( options ) {
                                    const $actions = $( '<div>' ).addClass( 'actions' ),
                                        // Use MediaWiki ResourceLoader require(), not Webpack require()
                                        contLangMessages = (
                            
                            
                            Severity: Minor
                            Found in src/mobile.editor.overlay/EditorOverlayBase.js - About 1 hr to fix

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

                                  public function onBeforePageDisplay( $out, $skin ): void {
                                      $context = $this->mobileContext;
                                      $mfEnableXAnalyticsLogging = $this->config->get( 'MFEnableXAnalyticsLogging' );
                                      $mfNoIndexPages = $this->config->get( 'MFNoindexPages' );
                                      $isCanonicalLinkHandledByCore = $this->config->get( 'EnableCanonicalServerLink' );
                              Severity: Minor
                              Found in includes/MobileFrontendHooks.php - 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 findChildInSectionLead has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  findChildInSectionLead( sectionIndex, selector ) {
                                      let $heading, $nextHeading;
                              
                                      const headingSelector = HEADING_SELECTOR;
                              
                              
                              Severity: Minor
                              Found in src/mobile.startup/PageHTMLParser.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 getTopHeadings has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function getTopHeadings( DOMElement $doc ): array {
                                      $headings = [];
                              
                                      foreach ( $this->topHeadingTags as $tagName ) {
                                          $allTags = DOMCompat::querySelectorAll( $doc, $tagName );
                              Severity: Minor
                              Found in includes/Transforms/MakeSectionsTransform.php - 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 _switchToVisualEditor has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  _switchToVisualEditor: function ( wikitext ) {
                                      const self = this;
                                      this.log( {
                                          action: 'abort',
                                          type: 'switchnochange',
                              Severity: Minor
                              Found in src/mobile.editor.overlay/SourceEditorOverlay.js - About 1 hr to fix

                                Function getPreview has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    getPreview: function ( options ) {
                                        let
                                            sectionLine = '',
                                            sectionId = '';
                                
                                
                                Severity: Minor
                                Found in src/mobile.editor.overlay/EditorGateway.js - About 1 hr to fix

                                  Function defaults has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      get defaults() {
                                          return {
                                              createDetailsAnchorHref: function () {
                                                  return function ( blockId, render ) {
                                                      return mw.util.getUrl( 'Special:BlockList', { wpTarget: '#' + render( blockId ) } );
                                  Severity: Minor
                                  Found in src/mobile.editor.overlay/BlockMessageDetails.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language