VSVverkeerskunde/gvq-api

View on GitHub
public/js/quiz.js

Summary

Maintainability
F
6 days
Test Coverage

Function Quiz has 340 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function Quiz (quizConfig) {
    quizConfig = $.extend({}, defaultQuizConfig, quizConfig || cachedConfig);
    cachedConfig = quizConfig;
    let view = $('#gvq-quiz .gvq-quiz-view');
    let oldView = $('#gvq-quiz .gvq-quiz-old-view');
Severity: Major
Found in public/js/quiz.js - About 1 day to fix

    File quiz.js has 430 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    (function (window, document, $) {
      var logoOffsetCounter = 0;
    
      let defaultQuizConfig = {
        'channel': 'individual',
    Severity: Minor
    Found in public/js/quiz.js - About 6 hrs to fix

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

              controller: function (quizId, questionNr) {
                let deferredRender = $.Deferred();
                let counterInterval;
      
                function startCountdown () {
      Severity: Major
      Found in public/js/quiz.js - About 2 hrs to fix

        Function controller has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                controller: function (quizId, questionNr, answerId) {
                  let deferredRender = $.Deferred();
        
                  function renderAnsweredQuestion (data) {
                    let answerResult = 'wrong';
        Severity: Minor
        Found in public/js/quiz.js - About 1 hr to fix

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

                  controller: function () {
                    let startButton = view.find('button.gvq-start-button');
          
                    let teamSelect = view.find('select[name="choose-team"]');
          
          
          Severity: Minor
          Found in public/js/quiz.js - About 1 hr to fix

            Function controller has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                      controller: function () {
                        var sequences = [
                          {pct: 20, label: '4'},
                          {pct: 40, label: '3'},
                          {pct: 60, label: '2'},
            Severity: Minor
            Found in public/js/quiz.js - About 1 hr to fix

              Function renderAnsweredQuestion has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                        function renderAnsweredQuestion (data) {
                          let answerResult = 'wrong';
              
                          for (var i = 1; i <= 3; i++) {
                            view.find('[data-value="answer' + i + '"]').hide();
              Severity: Minor
              Found in public/js/quiz.js - About 1 hr to fix

                Function controller has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        controller: function (quizId, score, totalQuestions) {
                          setViewValue('score', score);
                          setViewValue('totalQuestions', totalQuestions);
                
                          function checkEmail () {
                Severity: Minor
                Found in public/js/quiz.js - About 1 hr to fix

                  Function controller has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          controller: function (quizId, score, totalQuestions) {
                            setViewValue('score', score);
                            setViewValue('totalQuestions', totalQuestions);
                  
                            view.find('button.gvq-play-again').on('click', function () {
                  Severity: Minor
                  Found in public/js/quiz.js - About 1 hr to fix

                    Function renderQuestion has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                              function renderQuestion (data) {
                                let imageLocation = quizConfig.imageDirectory + data.question.imageFileName;
                                let questionImage = new Image();
                                setViewValue('questionText', data.question.text);
                    
                    
                    Severity: Minor
                    Found in public/js/quiz.js - About 1 hr to fix

                      Function progress has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                                  function progress(val, label, css_class, bar, cont) {
                      Severity: Minor
                      Found in public/js/quiz.js - About 35 mins to fix

                        Function renderView has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            function renderView (viewName, quizId, questionNr, answerId, scroll) {
                        Severity: Minor
                        Found in public/js/quiz.js - About 35 mins to fix

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

                              nl: {
                                STARTING: 'De quiz start over',
                                START_QUIZ: 'Start!',
                                CONTINUE: 'Verdergaan',
                                QUESTION: 'Vraag',
                          Severity: Major
                          Found in public/js/quiz.js and 1 other location - About 4 hrs to fix
                          public/js/quiz.js on lines 50..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 121.

                          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

                              fr: {
                                STARTING: 'Vous ĂȘtes prĂȘt ?',
                                START_QUIZ: 'Commencer',
                                CONTINUE: 'Continuez',
                                QUESTION: 'Question',
                          Severity: Major
                          Found in public/js/quiz.js and 1 other location - About 4 hrs to fix
                          public/js/quiz.js on lines 25..49

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

                          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

                                      } else if (score <= 8) {
                                        view.find('#share-title-very-bad').hide();
                                        view.find('#share-title-bad').hide();
                                        view.find('#share-title-good').show();
                                        view.find('#share-title-very-good').hide();
                          Severity: Major
                          Found in public/js/quiz.js and 2 other locations - About 2 hrs to fix
                          public/js/quiz.js on lines 473..493
                          public/js/quiz.js on lines 478..493

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

                          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

                                      if (score <= 4) {
                                        view.find('#share-title-very-bad').show();
                                        view.find('#share-title-bad').hide();
                                        view.find('#share-title-good').hide();
                                        view.find('#share-title-very-good').hide();
                          Severity: Major
                          Found in public/js/quiz.js and 2 other locations - About 2 hrs to fix
                          public/js/quiz.js on lines 478..493
                          public/js/quiz.js on lines 483..493

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

                          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

                                      } else if (score <= 6) {
                                        view.find('#share-title-very-bad').hide();
                                        view.find('#share-title-bad').show();
                                        view.find('#share-title-good').hide();
                                        view.find('#share-title-very-good').hide();
                          Severity: Major
                          Found in public/js/quiz.js and 2 other locations - About 2 hrs to fix
                          public/js/quiz.js on lines 473..493
                          public/js/quiz.js on lines 483..493

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

                          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

                                      for (var i = 1; i <= 3; i++) {
                                        view.find('[data-value="answer' + i + '"]').hide();
                                      }
                          Severity: Minor
                          Found in public/js/quiz.js and 1 other location - About 40 mins to fix
                          public/js/quiz.js on lines 400..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 49.

                          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

                                      for (var i = 1; i <= 3; i++) {
                                        view.find('[data-value="answer' + i + '"]').hide();
                                      }
                          Severity: Minor
                          Found in public/js/quiz.js and 1 other location - About 40 mins to fix
                          public/js/quiz.js on lines 351..353

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

                          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