wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

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

            return setRename( renameParams ).done( function ( data ) {
                if ( data.managemessagegroups && data.managemessagegroups.success ) {
                    location.reload();
                }
            } ).fail( function ( code, result ) {
Severity: Major
Found in resources/js/ext.translate.special.managegroups.js and 2 other locations - About 50 mins to fix
resources/js/ext.translate.special.managegroups.js on lines 68..84
resources/js/ext.translate.special.managegroups.js on lines 98..110

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

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

            $message.proofread( {
                message: message,
                sourcelangcode: this.$container.data( 'sourcelangcode' ),
                targetlangcode: this.$container.data( 'targetlangcode' )
            } );
Severity: Minor
Found in resources/js/ext.translate.messagetable.js and 1 other location - About 50 mins to fix
resources/js/ext.translate.messagetable.js on lines 317..321

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

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

            atOffset = data.at[ 1 ] === 'top' ?
                data.targetHeight :
                data.at[ 1 ] === 'bottom' ?
                    -data.targetHeight :
                    0,
Severity: Minor
Found in resources/src/ext.translate.groupselector/ui.position.js and 1 other location - About 50 mins to fix
resources/src/ext.translate.groupselector/ui.position.js on lines 139..143

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

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

    delay = ( function () {
        var timer = 0;

        return function ( callback, milliseconds ) {
            clearTimeout( timer );
Severity: Minor
Found in resources/js/ext.translate.special.managetranslatorsandbox.js and 1 other location - About 50 mins to fix
resources/src/ext.translate.groupselector/index.js on lines 700..707

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

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

Avoid deeply nested control flow statements.
Open

                    if ( i !== 0 ) {
                        translationUnits[ i - 1 ] += '\n' + mergeText;
                    } else {
                        matchText = mergeText + matchText;
                    }
Severity: Major
Found in resources/js/ext.translate.special.pagemigration.js - About 45 mins to fix

    Function roundedRect has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        roundedRect: function(ctx, x, y, width, height, radius) {
    Severity: Minor
    Found in resources/lib/Chart.js/Chart.js - About 45 mins to fix

      Function drawPoint has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          drawPoint: function(ctx, style, radius, x, y, rotation) {
      Severity: Minor
      Found in resources/lib/Chart.js/Chart.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            while ( emptyCount !== 0 ) {
                                mergeText += translationUnits.splice( i, 1 ).toString() + '\n';
                                emptyCount += 1;
                            }
        Severity: Major
        Found in resources/js/ext.translate.special.pagemigration.js - About 45 mins to fix

          Function doFill has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function doFill(ctx, points, mapper, view, color, loop) {
          Severity: Minor
          Found in resources/lib/Chart.js/Chart.js - About 45 mins to fix

            Function getScrollInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function getScrollInfo( within ) {
                var overflowX = within.isWindow || within.isDocument ? '' :
                        within.element.css( 'overflow-x' ),
                    overflowY = within.isWindow || within.isDocument ? '' :
                        within.element.css( 'overflow-y' ),
            Severity: Minor
            Found in resources/src/ext.translate.groupselector/ui.position.js - About 45 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

            Avoid deeply nested control flow statements.
            Open

                  for (var i = 0; i < rgb.length; i++) {
                     rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
                  }
            Severity: Major
            Found in resources/lib/Chart.js/Chart.js - About 45 mins to fix

              Function parseGroupFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function parseGroupFile( $filename ) {
                      $data = file_get_contents( $filename );
                      $documents = preg_split( "/^---$/m", $data, -1, PREG_SPLIT_NO_EMPTY );
                      $groups = [];
                      $template = false;
              Severity: Minor
              Found in scripts/yaml-tests.php - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function execute() {
                      $this->bundleMover = Services::getInstance()->getTranslatableBundleMover();
              
                      $mwService = MediaWikiServices::getInstance();
                      $this->titleParser = $mwService->getTitleParser();
              Severity: Minor
              Found in src/PageTranslation/MoveTranslatableBundleMaintenanceScript.php - About 45 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

              Avoid deeply nested control flow statements.
              Open

                                  if (c1.valid) {
                                      view[key] = c1.mix(c0, ease).rgbString();
                                      continue;
                                  }
              Severity: Major
              Found in resources/lib/Chart.js/Chart.js - About 45 mins to fix

                Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        PageMoveOperation $translatablePage,
                        array $translationPagePairs,
                        array $unitPagesPairs,
                        array $subpagesPairs,
                        array $nonMovableSubpages,
                Severity: Minor
                Found in src/PageTranslation/PageMoveCollection.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden || value.min < 0 || value.max < 0) {
                                              continue;
                                          }
                  Severity: Major
                  Found in resources/lib/Chart.js/Chart.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                       else if (match = string.match(keyword)) {
                          if (match[1] == "transparent") {
                             return [0, 0, 0, 0];
                          }
                          rgb = colorName$1[match[1]];
                    Severity: Major
                    Found in resources/lib/Chart.js/Chart.js - About 45 mins to fix

                      Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              TranslatablePage $page,
                              ParserOutput $parserOutput,
                              array $units,
                              array $deletedUnits,
                              bool $firstMark,
                      Severity: Minor
                      Found in src/PageTranslation/TranslatablePageMarkOperation.php - About 45 mins to fix

                        Function getRenderJobs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function getRenderJobs( TranslatablePage $page, bool $nonPrioritizedJobs = false ): array {
                                $documentationLanguageCode = MediaWikiServices::getInstance()
                                    ->getMainConfig()
                                    ->get( 'TranslateDocumentationLanguageCode' );
                        
                        
                        Severity: Minor
                        Found in src/PageTranslation/UpdateTranslatablePageJob.php - About 45 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

                        Avoid deeply nested control flow statements.
                        Open

                                                if (value.min !== 0) {
                                                    me.minNotZero = Math.min(value.min, me.minNotZero);
                                                }
                        Severity: Major
                        Found in resources/lib/Chart.js/Chart.js - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language