wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 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

    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

      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

        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

        Function onTitleGetEditNotices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function onTitleGetEditNotices( Title $title, int $oldid, array &$notices ) {
                if ( TranslatablePage::isSourcePage( $title ) ) {
                    $msg = wfMessage( 'translate-edit-tag-warning' )->inContentLanguage();
                    if ( !$msg->isDisabled() ) {
                        $notices['translate-tag'] = $msg->parseAsBlock();
        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 translatablePageHeader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function translatablePageHeader( $article, &$outputDone, &$pcache ) {
                if ( $article->getOldID() ) {
                    return;
                }
        
        
        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 onBeforePageDisplay has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
                global $wgTranslatePageTranslationULS;
        
                $title = $out->getTitle();
                $isSource = TranslatablePage::isSourcePage( $title );
        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 markForTranslation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function markForTranslation(
                TranslatablePageMarkOperation $operation,
                TranslatablePageSettings $pageSettings,
                User $user
            ): int {
        Severity: Minor
        Found in src/PageTranslation/TranslatablePageMarker.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