wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Avoid too many return statements within this method.
Open

            return false;
Severity: Major
Found in src/FileFormatSupport/GettextFormat.php - About 30 mins to fix

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

            return a[l1] === b[l1]
                ? a[l2] - b[l2]
                : a[l1] - b[l1];
    Severity: Minor
    Found in resources/lib/Chart.js/Chart.js and 1 other location - About 30 mins to fix
    resources/lib/Chart.js/Chart.js on lines 7001..7003

    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

    Avoid too many return statements within this method.
    Open

            return GettextPlural::unflatten( $a, $expectedPluralCount )
                === GettextPlural::unflatten( $b, $expectedPluralCount );
    Severity: Major
    Found in src/FileFormatSupport/GettextFormat.php - About 30 mins to fix

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

              if (vLimits.end > furthestLimits.b) {
                  furthestLimits.b = vLimits.end;
                  furthestAngles.b = angleRadians;
              }
      Severity: Major
      Found in resources/lib/Chart.js/Chart.js and 3 other locations - About 30 mins to fix
      resources/lib/Chart.js/Chart.js on lines 13523..13526
      resources/lib/Chart.js/Chart.js on lines 13528..13531
      resources/lib/Chart.js/Chart.js on lines 13533..13536

      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

      Avoid too many return statements within this method.
      Open

              return 'ok';
      Severity: Major
      Found in src/Validation/Validators/GettextPluralValidator.php - About 30 mins to fix

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

            for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
                curr = timestamps[i];
                if (curr > min && curr < max) {
                    items.push(curr);
                }
        Severity: Minor
        Found in resources/lib/Chart.js/Chart.js and 1 other location - About 30 mins to fix
        resources/lib/Chart.js/Chart.js on lines 14498..14503

        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

                for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
                    timestamp = timestamps[i];
                    if (timestamp >= min && timestamp <= max) {
                        ticks.push(timestamp);
                    }
        Severity: Minor
        Found in resources/lib/Chart.js/Chart.js and 1 other location - About 30 mins to fix
        resources/lib/Chart.js/Chart.js on lines 14033..14038

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

        function positionElement( $targetElem, options ) {
            // Make a copy, we don't want to modify arguments
            options = $.extend( {}, options );
        
            var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
        Severity: Minor
        Found in resources/src/ext.translate.groupselector/ui.position.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 addMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function addMessage( message ) {
            var $messageTable = $( '.tux-messagelist' ),
                sourceLanguage = $messageTable.data( 'sourcelangcode' ),
                sourceLanguageDir = $.uls.data.getDir( sourceLanguage ),
                targetLanguage = $messageTable.data( 'targetlangcode' ),
        Severity: Minor
        Found in resources/src/ext.translate.specialTranslationStash/index.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 FormHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        var FormHandler = function () {
            var $form = $( '#translationStatsConfig' ),
                onFilter = null;
        
            function getHeight() {
        Severity: Minor
        Found in resources/js/ext.translate.special.translationstats.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 getNewTitle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getNewTitle( Title $title ): Title {
                $instructions = $this->map[$title->getNamespace()] ?? null;
                if ( $instructions === null ) {
                    throw new InvalidPageTitleRename(
                        'Trying to move a page which is not part of the translatable page', self::UNKNOWN_PAGE
        Severity: Minor
        Found in src/PageTranslation/PageTitleRenamer.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 classifyPages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function classifyPages( array $pages ): array {
                $out = [
                    // The ideal state for pages: marked and up to date
                    'active' => [],
                    'proposed' => [],
        Severity: Minor
        Found in src/PageTranslation/PageTranslationSpecialPage.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function execute() {
                global $wgTranslateGroupFiles, $wgTranslateYamlLibrary;
                $documents = [];
                $times = [];
                $mems = [];
        Severity: Minor
        Found in scripts/yaml-tests.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 getIssues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getIssues(): array {
                $issues = $usedNames = [];
                foreach ( $this->getVariables() as $variable ) {
                    $name = $variable->getName();
                    $pattern = '/^' . TranslatablePageInsertablesSuggester::NAME_PATTERN . '$/u';
        Severity: Minor
        Found in src/PageTranslation/TranslationUnit.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function execute() {
                $template =
                    <<<'XML'
                    <?xml version="1.0" encoding="UTF-8"?>
                    <graphml
        Severity: Minor
        Found in scripts/fallbacks-graph.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 getLeaveRedirectPairFromList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getLeaveRedirectPairFromList( array $pagePairs ): array {
                $pairs = [];
                foreach ( $pagePairs as $pair ) {
                    if ( $pair->shouldLeaveRedirect() ) {
                        $pairs[ $pair->getOldTitle()->getPrefixedText() ] = true;
        Severity: Minor
        Found in src/PageTranslation/PageMoveCollection.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 displayStateInfoMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function displayStateInfoMessage( Title $title, TranslatableBundleState $bundleState ): void {
                $stateId = $bundleState->getStateId();
                if ( $stateId === TranslatableBundleState::UNSTABLE ) {
                    $infoMessage = $this->msg( 'tpt-translation-settings-unstable-notice' );
                } elseif ( $stateId === TranslatableBundleState::PROPOSE ) {
        Severity: Minor
        Found in src/PageTranslation/PageTranslationSpecialPage.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 getTranslatablePageStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function getTranslatablePageStatus( ?PageReference $pageReference ): ?array {
                if ( $pageReference === null ) {
                    return null;
                }
                $title = Title::newFromPageReference( $pageReference );
        Severity: Minor
        Found in src/PageTranslation/Hooks.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function execute() {
                $this->checkUserRightsAny( self::$right );
        
                $params = $this->extractRequestParams();
        
        
        Severity: Minor
        Found in src/TranslatorInterface/ReviewTranslationActionApi.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 onDeleteTranslationUnit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function onDeleteTranslationUnit(
                WikiPage $unit,
                User $user,
                $reason,
                $id,
        Severity: Minor
        Found in src/PageTranslation/Hooks.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