wikimedia/mediawiki-extensions-MobileFrontend

View on GitHub

Showing 183 of 183 total issues

Avoid too many return statements within this method.
Open

        return true;
Severity: Major
Found in includes/MobileFrontendEditorHooks.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return true;
    Severity: Major
    Found in includes/MobileContext.php - About 30 mins to fix

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

          if ( isCollapsed ) {
              headingText.setAttribute( 'aria-expanded', 'true' );
              icon.classList.add( 'mf-icon-expand' );
              icon.classList.remove( 'mf-icon-collapse' );
          } else {
      Severity: Minor
      Found in src/mobile.startup/sectionCollapsing.js and 1 other location - About 30 mins to fix
      src/mobile.startup/sectionCollapsing.js on lines 22..26

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

      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

          } else {
              headingText.setAttribute( 'aria-expanded', 'false' );
              icon.classList.add( 'mf-icon-collapse' );
              icon.classList.remove( 'mf-icon-expand' );
          }
      Severity: Minor
      Found in src/mobile.startup/sectionCollapsing.js and 1 other location - About 30 mins to fix
      src/mobile.startup/sectionCollapsing.js on lines 18..22

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

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

          getThumbnail( $a ) {
              const notSelector = '.' + EXCLUDE_THUMBNAIL_CLASS_SELECTORS.join( ',.' ),
                  $lazyImage = $a.find( '.lazy-image-placeholder' ),
                  href = $a.attr( 'href' ),
                  url = href && new URL( href, location.href ),
      Severity: Minor
      Found in src/mobile.startup/PageHTMLParser.js - About 25 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 preRender has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          preRender() {
              // Mapping existing props to Codex props used in IconButton
              let action = 'default';
              if ( this.options.progressive ) {
                  action = 'progressive';
      Severity: Minor
      Found in src/mobile.startup/Button.js - About 25 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 onSaveComplete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          onSaveComplete: function ( newRevId, redirectUrl, tempUserCreated ) {
              const
                  self = this;
      
              this.saved = true;
      Severity: Minor
      Found in src/mobile.editor.overlay/EditorOverlayBase.js - About 25 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 isIos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          isIos: memoize( function ( version ) {
              const ua = this.userAgent,
                  ios = /ipad|iphone|ipod/i.test( ua );
      
              if ( ios && version ) {
      Severity: Minor
      Found in src/mobile.startup/Browser.js - About 25 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 toggle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      Toggler.prototype.toggle = function ( $heading, fromSaved ) {
          if ( !fromSaved && $heading.hasClass( 'collapsible-heading-disabled' ) ) {
              return false;
          }
      
      
      Severity: Minor
      Found in src/mobile.startup/Toggler.js - About 25 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 VisualEditorOverlay has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function VisualEditorOverlay( options ) {
          const surfaceReady = util.Deferred();
      
          EditorOverlayBase.call( this,
              util.extend( {
      Severity: Minor
      Found in src/mobile.editor.overlay/VisualEditorOverlay.js - About 25 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 _resizeEditor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          _resizeEditor: function () {
              let scrollTop, container, $scrollContainer;
      
              if ( !this.$scrollContainer ) {
                  container = OO.ui.Element.static
      Severity: Minor
      Found in src/mobile.editor.overlay/SourceEditorOverlay.js - About 25 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 onSpecialPageBeforeExecute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function onSpecialPageBeforeExecute( $special, $subpage ) {
              $isMobileView = $this->mobileContext->shouldDisplayMobileView();
              $taglines = $this->mobileContext->getConfig()->get( 'MFSpecialPageTaglines' );
              $name = $special->getName();
      
      
      Severity: Minor
      Found in includes/MobileFrontendHooks.php - About 25 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 onPostLoginRedirect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function onPostLoginRedirect( &$returnTo, &$returnToQuery, &$type ) {
              $context = $this->mobileContext;
      
              if ( !$context->shouldDisplayMobileView() ) {
                  return;
      Severity: Minor
      Found in includes/MobileFrontendHooks.php - About 25 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 makeHeader has a Cognitive Complexity of 6 (exceeds 5 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 25 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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function ( options ) {
          const isWatched = options.isWatched,
              watchstar = __non_webpack_require__( 'mediawiki.page.watch.ajax' ).watchstar,
              action = isWatched ? 'unwatch' : 'watch',
              iconProps = {
      Severity: Minor
      Found in src/mobile.startup/watchstar/watchstar.js - About 25 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 _enableArrowImages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          _enableArrowImages: function ( thumbs ) {
              const offset = this.galleryOffset;
              let lastThumb, nextThumb;
      
              if ( this.galleryOffset === undefined ) {
      Severity: Minor
      Found in src/mobile.mediaViewer/ImageCarousel.js - About 25 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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          constructor( options ) {
              const title = options.title || '';
              util.extend( this, {
                  id: options.id || 0,
                  // FIXME: Deprecate title property as it can be derived from titleObj
      Severity: Minor
      Found in src/mobile.startup/Page.js - About 25 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 handleCaptcha has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          handleCaptcha: function ( details ) {
              const self = this,
                  $input = this.$el.find( '.captcha-word' );
      
              if ( this.captchaShown ) {
      Severity: Minor
      Found in src/mobile.editor.overlay/EditorOverlayBase.js - About 25 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 execute has a Cognitive Complexity of 6 (exceeds 5 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 25 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 isNonLeadParagraph has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private function isNonLeadParagraph( $xPath, $node ) {
              if (
                  $node->nodeType === XML_ELEMENT_NODE &&
                  /** @phan-suppress-next-line PhanUndeclaredProperty DOMNode vs. DOMElement */
                  $node->tagName === 'p' &&
      Severity: Minor
      Found in includes/Transforms/MoveLeadParagraphTransform.php - About 25 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