wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

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

    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

    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

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

        public function getDefinitions() {
            $groups = MessageGroups::getAllGroups();
            $keys = [];
    
            /** @var $g MessageGroup */
    Severity: Minor
    Found in messagegroups/WorkflowStatesMessageGroup.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 exports has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function ( grunt ) {
        const conf = grunt.file.readJSON( 'extension.json' );
    
        grunt.loadNpmTasks( 'grunt-eslint' );
        grunt.loadNpmTasks( 'grunt-banana-checker' );
    Severity: Minor
    Found in Gruntfile.js - About 1 hr to fix

      Function showShortcuts has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              showShortcuts: function () {
                  // Any better way?
                  var rtl = $( document.body ).is( '.rtl' );
      
                  var editorOffset = this.$editor.offset();
      Severity: Minor
      Found in resources/js/ext.translate.editor.shortcuts.js - About 1 hr to fix

        Function saveDocumentation has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                saveDocumentation: function () {
                    var translateEditor = this,
                        api = new mw.Api(),
                        newDocumentation = translateEditor.$editor.find( '.tux-textarea-documentation' ).val();
        
        
        Severity: Minor
        Found in resources/js/ext.translate.editor.helpers.js - About 1 hr to fix

          Function calculatePointY has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              calculatePointY: function(value, index, datasetIndex) {
                  var me = this;
                  var chart = me.chart;
                  var yScale = me._yScale;
                  var sumPos = 0;
          Severity: Minor
          Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

            Function hsl has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            convert.rgb.hsl = function (rgb) {
                var r = rgb[0] / 255;
                var g = rgb[1] / 255;
                var b = rgb[2] / 255;
                var min = Math.min(r, g, b);
            Severity: Minor
            Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

              Function proofread has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      proofread: function () {
                          var message = this.message,
                              $message = this.$message,
                              api = new mw.Api();
              
              
              Severity: Minor
              Found in resources/js/ext.translate.proofread.js - About 1 hr to fix

                Function listen has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        listen: function () {
                            var statsbar = this;
                            statsbar.$statsBar.on( 'change', function ( event, to, from ) {
                                // This updates the value in mw.translate.languagestats as a reference to
                                // the object is returned here.
                Severity: Minor
                Found in resources/js/ext.translate.statsbar.js - About 1 hr to fix

                  Function rgb has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  convert.hcg.rgb = function (hcg) {
                      var h = hcg[0] / 360;
                      var c = hcg[1] / 100;
                      var g = hcg[2] / 100;
                  
                  
                  Severity: Minor
                  Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

                    Function handleEvent has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        handleEvent: function(e) {
                            var me = this;
                            var opts = me.options;
                            var type = e.type === 'mouseup' ? 'click' : e.type;
                            var hoveredItem;
                    Severity: Minor
                    Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

                      Method getArrayDiff has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getArrayDiff( array $old, array $new ): array {
                              $values = [];
                              $record = static function ( $groups ) use ( &$values ) {
                                  foreach ( $groups as $group ) {
                                      $values[$group] = true;
                      Severity: Minor
                      Found in src/MessageLoading/MessageIndex.php - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language