wikimedia/mediawiki-extensions-TwnMainPage

View on GitHub

Showing 28 of 34 total issues

Function initLanguageSelector has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function initLanguageSelector() {
            $form.find( '.signup-language-selector' ).uls( {
                onSelect: function ( language ) {
                    var $checkbox = $form.find( 'input[name="signuplanguage"][value="' + language + '"]' );
                    if ( $checkbox.length ) {
Severity: Minor
Found in resources/js/ext.translate.mainpage.signup.js - About 1 hr to fix

    Method getStatsTiles has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getStatsTiles( $stats ): array {
            return [
                // Rows X cols
                [
                    [
    Severity: Minor
    Found in includes/specials/SpecialTwnMainPage.php - About 1 hr to fix

      Method getSandboxRows has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getSandboxRows(): string {
              global $wgTranslateSandboxLimit;
      
              $count = count( $this->translationStashReader->getTranslations( $this->getUser() ) );
      
      
      Severity: Minor
      Found in includes/specials/SpecialTwnMainPage.php - About 1 hr to fix

        Function exports has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function ( grunt ) {
            'use strict';
        
            grunt.loadNpmTasks( 'grunt-eslint' );
            grunt.loadNpmTasks( 'grunt-banana-checker' );
        Severity: Minor
        Found in Gruntfile.js - About 1 hr to fix

          Function getCategoryFilter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getCategoryFilter( array $args ): ?string {
                  foreach ( $args as $arg ) {
                      if ( trim( $arg ) === '' ) {
                          continue;
                      }
          Severity: Minor
          Found in src/Location/HookHandler.php - About 55 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

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

              public function __construct( $key, $staleAge, $expiredAge, $worker, $onMiss = 'update' ) {
          Severity: Minor
          Found in includes/CachedStat.php - About 35 mins to fix

            Function getStyles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getStyles( Context $context ) {
                    $out = '';
                    foreach ( $this->getData() as $key => $value ) {
                        if ( !isset( $value['raster'] ) ) {
                            continue;
            Severity: Minor
            Found in includes/ResourceLoaderProjectIconsModule.php - About 35 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 getProjects has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getProjects() {
                    $projects = [];
            
                    $cache = ObjectCache::getInstance( CACHE_ANYTHING );
                    $cacheKey = $cache->makeKey( __METHOD__ );
            Severity: Minor
            Found in includes/ProjectHandler.php - About 35 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