wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Function getTargetLanguage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTargetLanguage(): Language {
        $ui = $this->getLanguage();
        $source = $this->getSourceLanguage();
        if ( !$ui->equals( $source ) ) {
            return $ui;
Severity: Minor
Found in src/TranslatorSandbox/TranslationStashSpecialPage.php - About 1 hr 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 __construct has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

        UserFactory $userFactory,
        IConnectionProvider $dbProvider,
        PermissionManager $permissionManager,
        AuthManager $authManager,
        UserGroupManager $userGroupManager,
Severity: Major
Found in src/TranslatorSandbox/TranslateSandbox.php - About 1 hr to fix

    Function doQuery has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        private function doQuery( string $sourceLanguage, string $targetLanguage, string $text ): array {
            if ( !$this->useWikimediaExtraPlugin() ) {
                // ElasticTTM is currently not compatible with elasticsearch 2.x/5.x
                // It needs FuzzyLikeThis ported via the wmf extra plugin
                throw new RuntimeException( 'The wikimedia extra plugin is mandatory.' );
    Severity: Minor
    Found in src/TtmServer/ElasticSearchTtmServer.php - About 1 hr 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 onChangesListSpecialPageStructuredFilters has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function onChangesListSpecialPageStructuredFilters( $special ): void {
            $translateRcFilterDefault = $this->config->get( 'TranslateRcFilterDefault' );
            $defaultFilter = $translateRcFilterDefault !== 'noaction' ?
                $translateRcFilterDefault :
                ChangesListStringOptionsFilterGroup::NONE;
    Severity: Minor
    Found in src/RecentChangesTranslationFilterHookHandler.php - About 1 hr 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 __construct has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            Config $config,
            TranslatorActivity $translatorActivity,
            LanguageNameUtils $langNameUtils,
            ILoadBalancer $loadBalancer,
            ConfigHelper $configHelper,
    Severity: Major
    Found in src/Statistics/ActiveLanguagesSpecialPage.php - About 1 hr to fix

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

          public function execute() {
              $params = $this->extractRequestParams();
      
              $target = $this->validateTargetParamater( $params );
              $cache = $this->loadStatistics( $target, MessageGroupStats::FLAG_CACHE_ONLY );
      Severity: Minor
      Found in src/Statistics/QueryStatsActionApi.php - About 1 hr 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 form has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          private function form( FormOptions $opts ): void {
              $script = $this->getConfig()->get( 'Script' );
      
              $this->setHeaders();
              $out = $this->getOutput();
      Severity: Minor
      Found in src/Statistics/TranslationStatsSpecialPage.php - About 1 hr 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 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute(): void {
              $this->checkUserRightsAny( self::RIGHT );
              $params = $this->extractRequestParams();
      
              $groupId = $params['groupId'];
      Severity: Minor
      Found in src/MessageGroupProcessing/ManageMessageGroupsActionApi.php - About 1 hr 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 roundTimestampToCutoff has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function roundTimestampToCutoff(
              string $scale, int $cutoff, string $direction = 'earlier'
          ): int {
              $dir = $direction === 'earlier' ? -1 : 1;
      
      
      Severity: Minor
      Found in src/Statistics/TranslationStatsDataProvider.php - About 1 hr 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 calculateGroup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function calculateGroup( MessageGroup $group, string $languageCode ): array {
              global $wgTranslateDocumentationLanguageCode;
              // Calculate if missing and store in the db
              $collection = $group->initCollection( $languageCode );
      
      
      Severity: Minor
      Found in src/Statistics/MessageGroupStats.php - About 1 hr 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

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

              api.postWithToken( 'csrf', params )
                  .done( successFunction )
                  .fail( function ( code, data ) {
                      // eslint-disable-next-line no-alert
                      alert( data.error && data.error.info );
      Severity: Major
      Found in resources/js/ext.translate.special.aggregategroups.js and 3 other locations - About 1 hr to fix
      resources/js/ext.translate.special.aggregategroups.js on lines 75..80
      resources/js/ext.translate.special.aggregategroups.js on lines 103..108
      resources/js/ext.translate.special.aggregategroups.js on lines 397..402

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

      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 4 locations. Consider refactoring.
      Open

                  api.postWithToken( 'csrf', params )
                      .done( successFunction )
                      .fail( function ( code, data ) {
                          // eslint-disable-next-line no-alert
                          alert( data.error && data.error.info );
      Severity: Major
      Found in resources/js/ext.translate.special.aggregategroups.js and 3 other locations - About 1 hr to fix
      resources/js/ext.translate.special.aggregategroups.js on lines 24..29
      resources/js/ext.translate.special.aggregategroups.js on lines 75..80
      resources/js/ext.translate.special.aggregategroups.js on lines 103..108

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

      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 6 locations. Consider refactoring.
      Open

          lighten: function (ratio) {
              var hsl = this.values.hsl;
              hsl[2] += hsl[2] * ratio;
              this.setValues('hsl', hsl);
              return this;
      Severity: Major
      Found in resources/lib/Chart.js/Chart.js and 5 other locations - About 1 hr to fix
      resources/lib/Chart.js/Chart.js on lines 1858..1863
      resources/lib/Chart.js/Chart.js on lines 1865..1870
      resources/lib/Chart.js/Chart.js on lines 1872..1877
      resources/lib/Chart.js/Chart.js on lines 1879..1884
      resources/lib/Chart.js/Chart.js on lines 1886..1891

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

      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 6 locations. Consider refactoring.
      Open

          desaturate: function (ratio) {
              var hsl = this.values.hsl;
              hsl[1] -= hsl[1] * ratio;
              this.setValues('hsl', hsl);
              return this;
      Severity: Major
      Found in resources/lib/Chart.js/Chart.js and 5 other locations - About 1 hr to fix
      resources/lib/Chart.js/Chart.js on lines 1851..1856
      resources/lib/Chart.js/Chart.js on lines 1858..1863
      resources/lib/Chart.js/Chart.js on lines 1865..1870
      resources/lib/Chart.js/Chart.js on lines 1879..1884
      resources/lib/Chart.js/Chart.js on lines 1886..1891

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

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

          public static function reloadIgnorePatterns(): void {
              $validationExclusionFile = Services::getInstance()->getConfigHelper()->getValidationExclusionFile();
      
              if ( $validationExclusionFile === false ) {
                  self::$ignorePatterns = [];
      Severity: Minor
      Found in src/Validation/ValidationRunner.php - About 1 hr 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

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

          whiten: function (ratio) {
              var hwb = this.values.hwb;
              hwb[1] += hwb[1] * ratio;
              this.setValues('hwb', hwb);
              return this;
      Severity: Major
      Found in resources/lib/Chart.js/Chart.js and 5 other locations - About 1 hr to fix
      resources/lib/Chart.js/Chart.js on lines 1851..1856
      resources/lib/Chart.js/Chart.js on lines 1858..1863
      resources/lib/Chart.js/Chart.js on lines 1865..1870
      resources/lib/Chart.js/Chart.js on lines 1872..1877
      resources/lib/Chart.js/Chart.js on lines 1886..1891

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

      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 6 locations. Consider refactoring.
      Open

          darken: function (ratio) {
              var hsl = this.values.hsl;
              hsl[2] -= hsl[2] * ratio;
              this.setValues('hsl', hsl);
              return this;
      Severity: Major
      Found in resources/lib/Chart.js/Chart.js and 5 other locations - About 1 hr to fix
      resources/lib/Chart.js/Chart.js on lines 1851..1856
      resources/lib/Chart.js/Chart.js on lines 1865..1870
      resources/lib/Chart.js/Chart.js on lines 1872..1877
      resources/lib/Chart.js/Chart.js on lines 1879..1884
      resources/lib/Chart.js/Chart.js on lines 1886..1891

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

      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 6 locations. Consider refactoring.
      Open

          blacken: function (ratio) {
              var hwb = this.values.hwb;
              hwb[2] += hwb[2] * ratio;
              this.setValues('hwb', hwb);
              return this;
      Severity: Major
      Found in resources/lib/Chart.js/Chart.js and 5 other locations - About 1 hr to fix
      resources/lib/Chart.js/Chart.js on lines 1851..1856
      resources/lib/Chart.js/Chart.js on lines 1858..1863
      resources/lib/Chart.js/Chart.js on lines 1865..1870
      resources/lib/Chart.js/Chart.js on lines 1872..1877
      resources/lib/Chart.js/Chart.js on lines 1879..1884

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

      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 4 locations. Consider refactoring.
      Open

                  api.postWithToken( 'csrf', params )
                      .done( successFunction )
                      .fail( function ( code, data ) {
                          // eslint-disable-next-line no-alert
                          alert( data.error && data.error.info );
      Severity: Major
      Found in resources/js/ext.translate.special.aggregategroups.js and 3 other locations - About 1 hr to fix
      resources/js/ext.translate.special.aggregategroups.js on lines 24..29
      resources/js/ext.translate.special.aggregategroups.js on lines 103..108
      resources/js/ext.translate.special.aggregategroups.js on lines 397..402

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

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

          public function getIssues( Message $message, string $targetLanguage ): ValidationIssues {
              $issues = new ValidationIssues();
      
              $expectedKeywords = UnicodePlural::getPluralKeywords( $targetLanguage );
              // Skip validation for languages for which we do not know the plural rule
      Severity: Minor
      Found in src/Validation/Validators/SmartFormatPluralValidator.php - About 1 hr 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