wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

File Chart.js has 11466 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * Chart.js v2.9.3
 * https://www.chartjs.org
 * (c) 2019 Chart.js Contributors
 * Released under the MIT License
Severity: Major
Found in resources/lib/Chart.js/Chart.js - About 1 mo to fix

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

    var colorName$1 = {
        "aliceblue": [240, 248, 255],
        "antiquewhite": [250, 235, 215],
        "aqua": [0, 255, 255],
        "aquamarine": [127, 255, 212],
    Severity: Major
    Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 wk to fix
    resources/lib/Chart.js/Chart.js on lines 23..172

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

    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

    var colorName = {
        "aliceblue": [240, 248, 255],
        "antiquewhite": [250, 235, 215],
        "aqua": [0, 255, 255],
        "aquamarine": [127, 255, 212],
    Severity: Major
    Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 wk to fix
    resources/lib/Chart.js/Chart.js on lines 1231..1380

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

    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 conversions has 682 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var conversions = createCommonjsModule(function (module) {
    /* MIT license */
    
    
    // NOTE: conversions should only return primitive values (i.e. arrays, or
    Severity: Major
    Found in resources/lib/Chart.js/Chart.js - About 3 days to fix

      File Hooks.php has 1201 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace MediaWiki\Extension\Translate\PageTranslation;
      
      use Article;
      Severity: Major
      Found in src/PageTranslation/Hooks.php - About 3 days to fix

        Function execute has a Cognitive Complexity of 150 (exceeds 5 allowed). Consider refactoring.
        Open

            public function execute() {
                $output = $this->getOption( 'output', 'default' );
        
                // Select an output engine
                switch ( $output ) {
        Severity: Minor
        Found in scripts/groupStatistics.php - About 3 days 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

        File PageTranslationSpecialPage.php has 1046 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        declare( strict_types = 1 );
        
        namespace MediaWiki\Extension\Translate\PageTranslation;
        
        
        Severity: Major
        Found in src/PageTranslation/PageTranslationSpecialPage.php - About 2 days to fix

          File ext.translate.editor.js has 1033 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* global autosize */
          
          ( function () {
              'use strict';
          
          
          Severity: Major
          Found in resources/js/ext.translate.editor.js - About 2 days to fix

            Function core_helpers has 468 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var core_helpers = function() {
            
                // -- Basic js utility methods
            
                helpers$1.where = function(collection, filterCallback) {
            Severity: Major
            Found in resources/lib/Chart.js/Chart.js - About 2 days to fix

              File Translate.alias.php has 935 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * Aliases for special pages of Translate extension.
               *
               * @file
              Severity: Major
              Found in Translate.alias.php - About 2 days to fix

                File ManageGroupsSpecialPage.php has 906 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                declare( strict_types = 1 );
                
                namespace MediaWiki\Extension\Translate\Synchronization;
                
                
                Severity: Major
                Found in src/Synchronization/ManageGroupsSpecialPage.php - About 2 days to fix

                  File HookHandler.php has 726 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  declare( strict_types=1 );
                  
                  namespace MediaWiki\Extension\Translate;
                  
                  
                  Severity: Major
                  Found in src/HookHandler.php - About 1 day to fix

                    Function prepareEditorColumn has 332 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            prepareEditorColumn: function () {
                                var translateEditor = this,
                                    $discardChangesButton = $( [] ),
                                    $saveButton = $( [] ),
                                    $messageTools = translateEditor.createMessageTools(),
                    Severity: Major
                    Found in resources/js/ext.translate.editor.js - About 1 day to fix

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

                          public function execute() {
                              $output = $this->getOption( 'output', 'default' );
                      
                              // Select an output engine
                              switch ( $output ) {
                      Severity: Major
                      Found in scripts/groupStatistics.php - About 1 day to fix

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

                            legendCallback: function(chart) {
                                var list = document.createElement('ul');
                                var data = chart.data;
                                var datasets = data.datasets;
                                var labels = data.labels;
                        Severity: Major
                        Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 day to fix
                        resources/lib/Chart.js/Chart.js on lines 5336..5356

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

                        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

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

                            legendCallback: function(chart) {
                                var list = document.createElement('ul');
                                var data = chart.data;
                                var datasets = data.datasets;
                                var labels = data.labels;
                        Severity: Major
                        Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 day to fix
                        resources/lib/Chart.js/Chart.js on lines 6154..6174

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

                        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

                        File ext.translate.messagetable.js has 621 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        ( function () {
                            'use strict';
                        
                            var itemsClass = {
                                proofread: '.tux-message-proofread',
                        Severity: Major
                        Found in resources/js/ext.translate.messagetable.js - About 1 day to fix

                          Function execute has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function execute( array $messages ): bool {
                                  $context = RequestContext::getMain();
                                  $output = $context->getOutput();
                          
                                  // Set up diff engine
                          Severity: Minor
                          Found in src/Synchronization/MessageWebImporter.php - About 1 day 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 setupTranslate has 258 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function setupTranslate(): void {
                                  global $wgTranslateYamlLibrary, $wgLogTypes;
                                  $hooks = [];
                          
                                  /*
                          Severity: Major
                          Found in src/HookHandler.php - About 1 day to fix

                            Function execute has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function execute(): void {
                                    $this->checkUserRightsAny( self::$right );
                                    $block = $this->getUser()->getBlock();
                                    if ( $block && $block->isSitewide() ) {
                                        $this->dieBlocked( $block );
                            Severity: Minor
                            Found in src/MessageGroupProcessing/AggregateGroupsActionApi.php - About 1 day 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