wikimedia/mediawiki-extensions-MobileFrontend

View on GitHub

Showing 183 of 183 total issues

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 scrollToLeadParagraph has a Cognitive Complexity of 10 (exceeds 5 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

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 domParseMobile has a Cognitive Complexity of 10 (exceeds 5 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: Minor
Found in includes/ExtMobileFrontend.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 delegateEvents has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    delegateEvents( events ) {
        let match, key, method;
        events = events || this.options.events;
        if ( events ) {
            // Remove current events before re-binding them
Severity: Minor
Found in src/mobile.startup/View.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 parseBlockInfo has a Cognitive Complexity of 10 (exceeds 5 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: Minor
Found in src/mobile.editor.overlay/parseBlockInfo.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 submitSettingsForm has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function submitSettingsForm() {
        $request = $this->getRequest();
        $user = $this->getUser();

        if ( $user->isRegistered() && !$user->matchEditToken( $request->getVal( 'token' ) ) ) {
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

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

    protected static function getUserPageContent( IContextSource $output,
        User $pageUser, Title $title
    ) {
        /** @var MobileContext $context */
        $context = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
Severity: Minor
Found in includes/ExtMobileFrontend.php - About 1 hr to fix

    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

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

                              if ( mw.user.isAnon() ) {
                                  mw.user.clientPrefs.set( FONT_SIZE_KEY, 'large' );
                              } else {
                                  api.saveOption( FONT_SIZE_KEY, 'large' );
                              }
                      Severity: Minor
                      Found in src/mobile.init/mobile.init.js and 1 other location - About 55 mins to fix
                      src/mobile.init/mobile.init.js on lines 120..124

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

                      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

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

                              if ( mw.user.isAnon() ) {
                                  mw.user.clientPrefs.set( SECTION_COLLAPSING_TOGGLE, '1' );
                              } else {
                                  api.saveOption( SECTION_COLLAPSING_TOGGLE, '1' );
                              }
                      Severity: Minor
                      Found in src/mobile.init/mobile.init.js and 1 other location - About 55 mins to fix
                      src/mobile.init/mobile.init.js on lines 109..113

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

                      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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language