wikimedia/mediawiki-extensions-MobileFrontend

View on GitHub

Showing 183 of 183 total issues

Function exports has 37 lines of code (exceeds 25 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 1 hr to fix

    Method makeSections has 37 lines of code (exceeds 25 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 1 hr to fix

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

          showReference( id, page, refNumber, pageHTMLParser, gateway, props,
              onShowNestedReference
          ) {
              return gateway.getReference( id, page, pageHTMLParser ).then( ( reference ) => {
                  const drawer = referenceDrawer( util.extend( {
      Severity: Minor
      Found in src/mobile.startup/references/references.js - About 1 hr to fix

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

            preRender: function () {
                const options = this.options;
        
                this.options.headers = [
                    headers.formHeader(
        Severity: Minor
        Found in src/mobile.editor.overlay/EditorOverlayBase.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 identifyInfoboxElement has a Cognitive Complexity of 12 (exceeds 5 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

            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 addSettingsForm has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                private function addSettingsForm() {
                    $out = $this->getOutput();
                    $user = $this->getUser();
                    $isTemp = $user->isTemp();
            
            
            Severity: Minor
            Found in includes/specials/SpecialMobileOptions.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 blockMessageDrawer has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function blockMessageDrawer( props ) {
                const blockDrawer = new Drawer( {
                    className: 'drawer block-message',
                    onBeforeHide: function ( drawer ) {
                        drawer.$el.remove();
            Severity: Minor
            Found in src/mobile.editor.overlay/blockMessageDrawer.js - About 1 hr to fix

              Function onStageChanges has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  onStageChanges: function () {
                      const self = this,
                          params = {
                              text: this.getContent()
                          };
              Severity: Minor
              Found in src/mobile.editor.overlay/SourceEditorOverlay.js - About 1 hr to fix

                Method moveFirstParagraphBeforeInfobox has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function moveFirstParagraphBeforeInfobox( DOMElement $leadSection, ?DOMDocument $doc ) {
                        if ( $doc === null ) {
                            return;
                        }
                        $xPath = new DOMXPath( $doc );
                Severity: Minor
                Found in includes/Transforms/MoveLeadParagraphTransform.php - About 1 hr to fix

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

                      public function execute() {
                          $services = MediaWikiServices::getInstance();
                          $urlUtils = $services->getUrlUtils();
                  
                          $config = $this->getConfig();
                  Severity: Minor
                  Found in includes/Api/ApiWebappManifest.php - About 1 hr to fix

                    Function loadImage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function loadImage( placeholder ) {
                        const
                            deferred = util.Deferred(),
                            // data-width and height are attributes and do not specify dimension.
                            width = placeholder.dataset.width,
                    Severity: Minor
                    Found in src/mobile.startup/lazyImages/lazyImageLoader.js - About 1 hr to fix

                      Method buildMobileUserPreferences has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function buildMobileUserPreferences() {
                              $spacer = new OOUI\LabelWidget( [
                                  'name' => 'mobile_preference_spacer',
                              ] );
                              $userPreferences = new OOUI\FieldLayout(
                      Severity: Minor
                      Found in includes/specials/SpecialMobileOptions.php - About 1 hr to fix

                        Method onOutputPageBeforeHTML has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function onOutputPageBeforeHTML( $out, &$text ) {
                                // This hook can be executed more than once per page view if the page content is composed from
                                // multiple sources! Anything that doesn't depend on $text should use onBeforePageDisplay.
                        
                                $context = $this->mobileContext;
                        Severity: Minor
                        Found in includes/MobileFrontendHooks.php - About 1 hr to fix

                          Function makeHeader has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function makeHeader( headingOrView, headerActions, headerCancel, additionalClassNames ) {
                              const heading = typeof headingOrView === 'string' ? headingOrView : undefined,
                                  templateData = {
                                      hasActions: headerActions && headerActions.length,
                                      isHidden: false,
                          Severity: Minor
                          Found in src/mobile.startup/headers.js - About 1 hr to fix

                            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 doToggling has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function doToggling() {
                                    // make sure viewChange is set
                                    $this->shouldDisplayMobileView();
                            
                                    if ( !$this->viewChange ) {
                            Severity: Minor
                            Found in includes/MobileContext.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 onRequestContextCreateSkin has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function onRequestContextCreateSkin( $context, &$skin ) {
                                    $mobileContext = $this->mobileContext;
                            
                                    $mobileContext->doToggling();
                                    if ( !$mobileContext->shouldDisplayMobileView() ) {
                            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

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

                                    newOverlay.getLoadingPromise().then( function () {
                                        self.switching = true;
                                        self.overlayManager.replaceCurrent( newOverlay );
                                        self.switching = false;
                                    } );
                            Severity: Major
                            Found in src/mobile.editor.overlay/VisualEditorOverlay.js and 1 other location - About 1 hr to fix
                            src/mobile.editor.overlay/SourceEditorOverlay.js on lines 468..472

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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language