Bottaajat/cultura

View on GitHub
public/js/task.edit.js

Summary

Maintainability
F
3 days
Test Coverage

Function Edit_Crossword has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Edit_Crossword(answers,clues,positions,id) {
    var words = 0;
    $('<input type="button" class="btn btn-success" value="Lisää uusi"/>').attr( 'id', 'edit-'+id+'-add' ).appendTo( '#edit-'+id+'-input' );
    $('<input type="button" class="btn btn-danger" value="Poista viimeisin"/>').attr( 'id', 'edit-'+id+'-del' ).appendTo( '#edit-'+id+'-input' );
    $('<input type="text" name="vertical" readonly/>').attr( 'id', 'edit-'+id+'-vertical' ).attr( 'value', answers[answers.length-1] ).attr( 'placeholder', 'pystysana' ).appendTo( '#edit-'+id+'-preview' );
Severity: Major
Found in public/js/task.edit.js - About 2 hrs to fix

    Function Edit_MultipleChoice has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function Edit_MultipleChoice(questions,choices,solutions,id) {
        var questions_count = 0;
        $('<input type="button" class="btn btn-success" value="Lisää uusi"/>').attr( 'id', 'edit-'+id+'-add' ).appendTo( '#edit-'+id+'-input' );
        $('<input type="button" class="btn btn-danger" value="Poista viimeisin"/>').attr( 'id', 'edit-'+id+'-del' ).appendTo( '#edit-'+id+'-input' );
        
    Severity: Minor
    Found in public/js/task.edit.js - About 1 hr to fix

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

          $('#edit-'+id+'-add').on( 'click', function() {
              var pair_add = $('<div id="edit-'+id+'-pair-'+words+'" class="word_pair">');
              $(pair_add).append('<input type="text" name="droppable[]"  id="edit-'+id+'-droppable-'+words+'" placeholder="kohde" required/>');
              $(pair_add).append('<input type="text" name="draggable[]"  id="edit-'+id+'-draggable-'+words+'" placeholder="vedettävä" required/>');
              $(pair_add).append('<input type="text" name="showable[]"  id="edit-'+id+'-showable-'+words+'" placeholder="näytettävä" required/>');
      Severity: Major
      Found in public/js/task.edit.js and 1 other location - About 7 hrs to fix
      public/js/task.edit.js on lines 66..74

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

      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

          $('#edit-'+id+'-add').on( 'click', function() {
              var question_add = $('<div id="edit-'+id+'-question-'+questions_count+'" class="edit-question question">');
              $(question_add).append('<textarea class="column" name="questions[]" rows="4" id="edit-'+id+'-questions-'+questions_count+'" placeholder="kysymys" required />');
              $(question_add).append('<textarea class="column" name="choices[]" rows="4" id="edit-'+id+'-choices-'+questions_count+'" placeholder="vaihtoehdot" required />');
              $(question_add).append('<textarea class="column" name="solutions[]" rows="4" id="edit-'+id+'-solutions-'+questions_count+'" placeholder="vastaukset" required />');
      Severity: Major
      Found in public/js/task.edit.js and 1 other location - About 7 hrs to fix
      public/js/task.edit.js on lines 6..14

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

      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

          $('#edit-'+id+'-del').on( 'click', function() {
              if (words > 3) {
                  $( '#edit-'+id+'-pair-'+(words-1) ).remove();
                  words--;
              }
      Severity: Major
      Found in public/js/task.edit.js and 2 other locations - About 2 hrs to fix
      public/js/task.edit.js on lines 16..21
      public/js/task.edit.js on lines 76..81

      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

          $('#edit-'+id+'-del').on( 'click', function() {
              if (questions_count > 1) {
                  $( '#edit-'+id+'-question-'+(questions_count-1) ).remove();
                  questions_count--;
              }
      Severity: Major
      Found in public/js/task.edit.js and 2 other locations - About 2 hrs to fix
      public/js/task.edit.js on lines 16..21
      public/js/task.edit.js on lines 46..51

      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

          $('#edit-'+id+'-del').on( 'click', function() {
              if (words > 3) {
                  $( '#edit-'+id+'-pair-'+(words-1) ).remove();
                  words--;
              }
      Severity: Major
      Found in public/js/task.edit.js and 2 other locations - About 2 hrs to fix
      public/js/task.edit.js on lines 46..51
      public/js/task.edit.js on lines 76..81

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

          $('<input type="text" name="vertical" readonly/>').attr( 'id', 'edit-'+id+'-vertical' ).attr( 'value', answers[answers.length-1] ).attr( 'placeholder', 'pystysana' ).appendTo( '#edit-'+id+'-preview' );
      Severity: Major
      Found in public/js/task.edit.js and 1 other location - About 1 hr to fix
      public/js/task.edit.js on lines 98..98

      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

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

          $('<input type="text" name="vertical_clue"/>').attr( 'id', 'edit-'+id+'-vertical_clue' ).attr( 'value', clues[answers.length-1] ).attr( 'placeholder', 'pystysanan vihje' ).appendTo( '#edit-'+id+'-preview' );
      Severity: Major
      Found in public/js/task.edit.js and 1 other location - About 1 hr to fix
      public/js/task.edit.js on lines 97..97

      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

      There are no issues that match your filters.

      Category
      Status