wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

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

            } else {
                y1 = alignPixel(chart, me.top, firstLineWidth) - firstLineWidth / 2;
                y2 = alignPixel(chart, me.bottom, lastLineWidth) + lastLineWidth / 2;
                x1 = x2 = borderValue;
            }
Severity: Major
Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 hr to fix
resources/lib/Chart.js/Chart.js on lines 12353..12357

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

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 showTranslation has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function showTranslation( translation ) {
        var $target = $( '.translations' ),
            translationLang = translation.title.split( '/' ).pop();

        $target.append( $( '<div>' )
Severity: Minor
Found in resources/js/ext.translate.special.managetranslatorsandbox.js - About 1 hr to fix

    Function toggleSubscription has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function toggleSubscription() {
            var api = new mw.Api();
            var $button = $( this );
            $button.prop( 'disabled', true );
    
    
    Severity: Minor
    Found in resources/js/ext.translate.special.translate.js - About 1 hr to fix

      Method __construct has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct() {
              parent::__construct();
              $this->addDescription( 'Review and move translatable bundles including their subpages' );
      
              $this->addArg(
      Severity: Minor
      Found in src/PageTranslation/MoveTranslatableBundleMaintenanceScript.php - About 1 hr to fix

        Method classifyPages has 36 lines of code (exceeds 25 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 1 hr to fix

          Function _drawTitle has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _drawTitle: function() {
                  var me = this;
                  var ctx = me.ctx;
                  var options = me.options;
                  var scaleLabel = options.scaleLabel;
          Severity: Minor
          Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

            Function decodeFill has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function decodeFill(el, index, count) {
                var model = el._model || {};
                var fill = model.fill;
                var target;
            
            
            Severity: Minor
            Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

              Function _drawLabels has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _drawLabels: function() {
                      var me = this;
                      var ctx = me.ctx;
                      var opts = me.options;
                      var tickOpts = opts.ticks;
              Severity: Minor
              Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

                Function render has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    render: function(config) {
                        var me = this;
                
                        if (!config || typeof config !== 'object') {
                            // backwards compatibility
                Severity: Minor
                Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

                  Method move has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function move(
                          TranslatableBundle $sourceBundle,
                          User $performer,
                          array $pagesToMove,
                          array $pagesToRedirect,
                  Severity: Minor
                  Found in src/PageTranslation/TranslatableBundleMover.php - About 1 hr to fix

                    Method handlePriorityLanguages has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function handlePriorityLanguages(
                            TranslatablePage $page,
                            TranslatablePageSettings $pageSettings,
                            UserIdentity $user
                        ): void {
                    Severity: Minor
                    Found in src/PageTranslation/TranslatablePageMarker.php - About 1 hr to fix

                      Method deleteUser has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function deleteUser( User $user, string $force = '' ): void {
                              $uid = $user->getId();
                              $actorId = $user->getActorId();
                      
                              if ( $force !== 'force' && !self::isSandboxed( $user ) ) {
                      Severity: Minor
                      Found in src/TranslatorSandbox/TranslateSandbox.php - About 1 hr to fix

                        Method getWritable has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getWritable(): array {
                                $writableServers = $readOnlyServers = [];
                                $ttmServerIds = $this->getNames();
                        
                                foreach ( $ttmServerIds as $serverId ) {
                        Severity: Minor
                        Found in src/TtmServer/TtmServerFactory.php - About 1 hr to fix

                          Method createSearch has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function createSearch( string $queryString, array $opts, array $highlight ): Search {
                                  $query = new Query();
                          
                                  [ $searchQuery, $highlights ] = $this->parseQueryString( $queryString, $opts );
                                  $query->setQuery( $searchQuery );
                          Severity: Minor
                          Found in src/TtmServer/ElasticSearchTtmServer.php - About 1 hr to fix

                            Method addUser has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function addUser( string $name, string $email, string $password ): User {
                                    $user = $this->userFactory->newFromName( $name, UserFactory::RIGOR_CREATABLE );
                            
                                    if ( !$user ) {
                                        throw new InvalidArgumentException( 'Invalid user name' );
                            Severity: Minor
                            Found in src/TranslatorSandbox/TranslateSandbox.php - About 1 hr to fix

                              Method getHtmlForGroupErrors has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function getHtmlForGroupErrors(
                                      GroupSynchronizationResponse $groupErrorResponse,
                                      Language $language,
                                      string $wrapperClass
                                  ): string {
                              Severity: Minor
                              Found in src/Synchronization/DisplayGroupSynchronizationInfo.php - About 1 hr to fix

                                Method save has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function save(
                                        Title $pageTitle,
                                        RevisionRecord $revisionRecord,
                                        MessageBundleContent $content
                                    ): void {
                                Severity: Minor
                                Found in src/MessageBundleTranslation/MessageBundleStore.php - About 1 hr to fix

                                  Method getMessages has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function getMessages(): array {
                                          if ( $this->messages !== null ) {
                                              return $this->messages;
                                          }
                                  
                                  
                                  Severity: Minor
                                  Found in src/MessageBundleTranslation/MessageBundleContent.php - About 1 hr to fix

                                    Method getTable has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        private function getTable( array $stats ): string {
                                            $table = $this->table;
                                            $out = '';
                                    
                                            // This avoids a database query per translatable page, which would be caused by
                                    Severity: Minor
                                    Found in src/Statistics/LanguageStatsSpecialPage.php - About 1 hr to fix

                                      Method getGroupLoaders has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          protected function getGroupLoaders(): array {
                                              if ( $this->groupLoaders !== null ) {
                                                  return $this->groupLoaders;
                                              }
                                      
                                      
                                      Severity: Minor
                                      Found in src/MessageGroupProcessing/MessageGroups.php - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language