wikimedia/mediawiki-extensions-VisualEditor

View on GitHub
modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js

Summary

Maintainability
C
1 day
Test Coverage

File ve.init.mw.MobileArticleTarget.js has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * VisualEditor MediaWiki Initialization MobileArticleTarget class.
 *
 * @copyright See AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js - About 2 hrs to fix

    Function onContainerScroll has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ve.init.mw.MobileArticleTarget.prototype.onContainerScroll = function () {
        // Editor may not have loaded yet, in which case `this.surface` is undefined
        const surfaceView = this.surface && this.surface.getView(),
            isActiveWithKeyboard = surfaceView && surfaceView.isFocused() && !surfaceView.isDeactivated();
    
    
    Severity: Minor
    Found in modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js - About 1 hr to fix

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

      ve.init.mw.MobileArticleTarget.prototype.setupToolbar = function ( surface ) {
          const originalToolbarGroups = this.toolbarGroups;
      
          // We don't want any of these tools to show up in subordinate widgets, so we
          // temporarily add them here. We need to do it _here_ rather than in their
      Severity: Minor
      Found in modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js - About 1 hr to fix

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

            {
                name: 'style',
                classes: [ 've-test-toolbar-style' ],
                type: 'list',
                icon: 'textStyle',
        Severity: Major
        Found in modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js and 1 other location - About 3 hrs to fix
        modules/ve-mw-collab/ve.init.mw.MobileCollabTarget.js on lines 48..60

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

        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

        ve.init.mw.MobileArticleTarget.prototype.getSurfaceClasses = function () {
            const classes = ve.init.mw.MobileArticleTarget.super.prototype.getSurfaceClasses.call( this );
            return [ ...classes, 'content' ];
        };
        Severity: Major
        Found in modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js and 1 other location - About 2 hrs to fix
        modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js on lines 1780..1783

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

        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

        ve.init.mw.MobileArticleTarget.prototype.setupToolbarSaveButton = function () {
            this.toolbarSaveButton = this.toolbar.getToolGroupByName( 'save' ).items[ 0 ];
        };
        modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js on lines 294..296

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

        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

        There are no issues that match your filters.

        Category
        Status