BadrIT/translation_center

View on GitHub
app/assets/javascripts/translation_center/translations.js

Summary

Maintainability
F
3 days
Test Coverage

Function editableTranslations has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function editableTranslations(){

  $.each($('.user_translation'), function(){
    var key_id = $(this).attr('data-key-id');

Severity: Minor
Found in app/assets/javascripts/translation_center/translations.js - About 1 hr to fix

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

          callback : function(data, settings) {
            data = $.parseJSON(data);
            $(this).text(data.value);
            if(Filter.key() == 'untranslated')
            {
    Severity: Minor
    Found in app/assets/javascripts/translation_center/translations.js - About 1 hr to fix

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

          {
            $(this).addClass('badge-success');
            $(this).attr('voted', 'true')
            // TODO use I18n.t
            $(this).text('Unvote');
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 67..76

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

      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

          {
            $(this).removeClass('badge-success');
            $(this).attr('voted', 'false') 
            // TODO use I18n.t
            $(this).text('Vote');
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 53..64

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

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

      function decrementAll(){
        var count = parseInt($('#all_keys_count_count').text().replace('(', '').replace(')', '')) - 1;
        $('#all_keys_count_count').text('(' + count +  ')');
      }
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 7 other locations - About 2 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 115..118
      app/assets/javascripts/translation_center/translations.js on lines 120..123
      app/assets/javascripts/translation_center/translations.js on lines 125..129
      app/assets/javascripts/translation_center/translations.js on lines 131..134
      app/assets/javascripts/translation_center/translations.js on lines 136..139
      app/assets/javascripts/translation_center/translations.js on lines 141..144
      app/assets/javascripts/translation_center/translations.js on lines 146..149

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

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

      function incrementUntranslated(){
        var count = parseInt($('#untranslated_keys_count').text().replace('(', '').replace(')', '')) + 1;
        $('#untranslated_keys_count').text('(' + count +  ')');
      }
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 7 other locations - About 2 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 115..118
      app/assets/javascripts/translation_center/translations.js on lines 120..123
      app/assets/javascripts/translation_center/translations.js on lines 125..129
      app/assets/javascripts/translation_center/translations.js on lines 136..139
      app/assets/javascripts/translation_center/translations.js on lines 141..144
      app/assets/javascripts/translation_center/translations.js on lines 146..149
      app/assets/javascripts/translation_center/translations.js on lines 151..154

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

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

      function incrementTranslated(){
        var count = parseInt($('#translated_keys_count').text().replace('(', '').replace(')', '')) + 1;
        $('#translated_keys_count').text('(' + count +  ')');
      }
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 7 other locations - About 2 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 115..118
      app/assets/javascripts/translation_center/translations.js on lines 120..123
      app/assets/javascripts/translation_center/translations.js on lines 125..129
      app/assets/javascripts/translation_center/translations.js on lines 131..134
      app/assets/javascripts/translation_center/translations.js on lines 141..144
      app/assets/javascripts/translation_center/translations.js on lines 146..149
      app/assets/javascripts/translation_center/translations.js on lines 151..154

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

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

      function decrementPending(){
        var count = parseInt($('#pending_keys_count').text().replace('(', '').replace(')', '')) - 1;
        $('#pending_keys_count').text('(' + count +  ')');
        
      }
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 7 other locations - About 2 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 115..118
      app/assets/javascripts/translation_center/translations.js on lines 120..123
      app/assets/javascripts/translation_center/translations.js on lines 131..134
      app/assets/javascripts/translation_center/translations.js on lines 136..139
      app/assets/javascripts/translation_center/translations.js on lines 141..144
      app/assets/javascripts/translation_center/translations.js on lines 146..149
      app/assets/javascripts/translation_center/translations.js on lines 151..154

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

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

      function decrementTranslated(){
        var count = parseInt($('#translated_keys_count').text().replace('(', '').replace(')', '')) - 1;
        $('#translated_keys_count').text('(' + count +  ')');
      }
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 7 other locations - About 2 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 115..118
      app/assets/javascripts/translation_center/translations.js on lines 125..129
      app/assets/javascripts/translation_center/translations.js on lines 131..134
      app/assets/javascripts/translation_center/translations.js on lines 136..139
      app/assets/javascripts/translation_center/translations.js on lines 141..144
      app/assets/javascripts/translation_center/translations.js on lines 146..149
      app/assets/javascripts/translation_center/translations.js on lines 151..154

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

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

      function decrementUntranslated(){
        var count = parseInt($('#untranslated_keys_count').text().replace('(', '').replace(')', '')) - 1;
        $('#untranslated_keys_count').text('(' + count +  ')');
      }
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 7 other locations - About 2 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 120..123
      app/assets/javascripts/translation_center/translations.js on lines 125..129
      app/assets/javascripts/translation_center/translations.js on lines 131..134
      app/assets/javascripts/translation_center/translations.js on lines 136..139
      app/assets/javascripts/translation_center/translations.js on lines 141..144
      app/assets/javascripts/translation_center/translations.js on lines 146..149
      app/assets/javascripts/translation_center/translations.js on lines 151..154

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

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

      function incrementPending(){
        var count = parseInt($('#pending_keys_count').text().replace('(', '').replace(')', '')) + 1;
        $('#pending_keys_count').text('(' + count +  ')');
      }
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 7 other locations - About 2 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 115..118
      app/assets/javascripts/translation_center/translations.js on lines 120..123
      app/assets/javascripts/translation_center/translations.js on lines 125..129
      app/assets/javascripts/translation_center/translations.js on lines 131..134
      app/assets/javascripts/translation_center/translations.js on lines 136..139
      app/assets/javascripts/translation_center/translations.js on lines 146..149
      app/assets/javascripts/translation_center/translations.js on lines 151..154

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

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

      function incrementAll(){
        var count = parseInt($('#all_keys_count_count').text().replace('(', '').replace(')', '')) + 1;
        $('#all_keys_count_count').text('(' + count +  ')');
      }
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 7 other locations - About 2 hrs to fix
      app/assets/javascripts/translation_center/translations.js on lines 115..118
      app/assets/javascripts/translation_center/translations.js on lines 120..123
      app/assets/javascripts/translation_center/translations.js on lines 125..129
      app/assets/javascripts/translation_center/translations.js on lines 131..134
      app/assets/javascripts/translation_center/translations.js on lines 136..139
      app/assets/javascripts/translation_center/translations.js on lines 141..144
      app/assets/javascripts/translation_center/translations.js on lines 151..154

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

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

        $(document).on('click', '.unaccept_translation', function(){
          $.ajax({
            type: 'POST',
            url: Routes.translation_center_translation_unaccept_path($(this).attr('data-translation-id')) + '.js'
          });
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 2 other locations - About 1 hr to fix
      app/assets/javascripts/translation_center/translations.js on lines 9..14
      app/assets/javascripts/translation_center/translations.js on lines 31..36

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

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

        $(document).on('click', '.translations_tab, .sort_by_date', function(){
          $.ajax({
            type: 'GET',
            url: Routes.translation_center_translation_key_translations_path($(this).attr('data-key-id')) + '.js'
          });
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 2 other locations - About 1 hr to fix
      app/assets/javascripts/translation_center/translations.js on lines 9..14
      app/assets/javascripts/translation_center/translations.js on lines 16..21

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

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

        $(document).on('click', '.accept_translation', function(){
          $.ajax({
            type: 'POST',
            url: Routes.translation_center_translation_accept_path($(this).attr('data-translation-id')) + '.js'
          });
      Severity: Major
      Found in app/assets/javascripts/translation_center/translations.js and 2 other locations - About 1 hr to fix
      app/assets/javascripts/translation_center/translations.js on lines 16..21
      app/assets/javascripts/translation_center/translations.js on lines 31..36

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

      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