wikimedia/mediawiki-extensions-Translate

View on GitHub
resources/js/ext.translate.special.aggregategroups.js

Summary

Maintainability
D
2 days
Test Coverage

File ext.translate.special.aggregategroups.js has 370 lines of code (exceeds 250 allowed). Consider refactoring.
Open

( function () {
    'use strict';

    function getApiParams( $target ) {
        return {
Severity: Minor
Found in resources/js/ext.translate.special.aggregategroups.js - About 4 hrs to fix

    Function successFunction has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                var successFunction = function ( data ) {
                    var aggregateGroupId = data.aggregategroups.aggregategroupId;
                    var subGroupId = 'tp-subgroup-' + aggregateGroupId;
    
                    var $removeSpan = $( '<span>' ).attr( 'id', aggregateGroupId )
    Severity: Major
    Found in resources/js/ext.translate.special.aggregategroups.js - About 3 hrs to fix

      Function associate has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function associate( event, subGroupId ) {
              var $target = $( event.target ),
                  $parent = $target.parents( '.mw-tpa-group' ),
                  parentId = $parent.data( 'id' ),
                  subgroupName = $parent
      Severity: Minor
      Found in resources/js/ext.translate.special.aggregategroups.js - About 1 hr to fix

        Function editGroup has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function editGroup( event ) {
                var $target = $( event.target ),
                    $parent = $target.closest( '.mw-tpa-group' ),
                    aggregateGroupId = $parent.data( 'groupid' ),
                    $displayGroup = $parent.children( '.tp-display-group' ),
        Severity: Minor
        Found in resources/js/ext.translate.special.aggregategroups.js - About 1 hr to fix

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

                  $( '.tp-aggregate-edit-ag-button' ).on( 'click', function ( event ) {
                      var $parent = $( event.target ).closest( '.mw-tpa-group' );
          
                      $parent.children( '.tp-display-group' ).addClass( 'hidden' );
                      $parent.children( '.tp-edit-group' ).removeClass( 'hidden' );
          Severity: Major
          Found in resources/js/ext.translate.special.aggregategroups.js and 1 other location - About 1 hr to fix
          resources/js/ext.translate.special.aggregategroups.js on lines 376..380

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

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

                          $editSpan.on( 'click', function ( event ) {
                              var $parent = $( event.target ).closest( '.mw-tpa-group' );
                              $parent.children( '.tp-display-group' ).addClass( 'hidden' );
                              $parent.children( '.tp-edit-group' ).removeClass( 'hidden' );
                          } );
          Severity: Major
          Found in resources/js/ext.translate.special.aggregategroups.js and 1 other location - About 1 hr to fix
          resources/js/ext.translate.special.aggregategroups.js on lines 259..264

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

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

          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

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

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

                          var $cancelButton = $( '<input>' )
                              .attr( {
                                  type: 'button',
                                  class: 'tp-aggregategroup-update-cancel'
                              } )
          Severity: Minor
          Found in resources/js/ext.translate.special.aggregategroups.js and 1 other location - About 35 mins to fix
          resources/js/ext.translate.special.aggregategroups.js on lines 304..309

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

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

                          var $saveButton = $( '<input>' )
                              .attr( {
                                  type: 'button',
                                  class: 'tp-aggregategroup-update'
                              } )
          Severity: Minor
          Found in resources/js/ext.translate.special.aggregategroups.js and 1 other location - About 35 mins to fix
          resources/js/ext.translate.special.aggregategroups.js on lines 310..315

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

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

                          var $divEdit = $( '<div>' )
                              .addClass( 'tp-edit-group hidden' )
                              .append( $( '<label>' )
                                  .text( mw.msg( 'tpt-aggregategroup-edit-name' ) ) )
                              .append( $( '<input>' )
          Severity: Minor
          Found in resources/js/ext.translate.special.aggregategroups.js and 1 other location - About 35 mins to fix
          resources/js/ext.translate.editor.js on lines 1260..1273

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

          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

          There are no issues that match your filters.

          Category
          Status