roqua/quby_engine

View on GitHub

Showing 107 of 107 total issues

Method clear? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def clear?(answer, question)
          # rubocop:disable LineLength
          return true if question.is_a?(Questionnaires::Entities::Questions::SelectQuestion)  && answer == question.extra_data[:placeholder].to_s
          return true if question.is_a?(Questionnaires::Entities::Questions::StringQuestion)  && answer == ""
          return true if question.is_a?(Questionnaires::Entities::Questions::TextQuestion)    && answer == ""
Severity: Minor
Found in lib/quby/answers/services/answer_validations.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

                    if(fieldsEmpty > 0 && fieldsEmpty < inputs.length) {
                      throw "invalidDate";
                    }
Severity: Major
Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                      if(result == null || result[0] != value){
                          pushFailVal(validation.type);
                      }
    Severity: Major
    Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                        if(count.visible > 0 && count.answered > validation.value){
                            pushFailVal(validation.type);
                        }
      Severity: Major
      Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

        Method pdf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def pdf
              if defined?(Appsignal) && on_ios_safari?
                session[:has_downloaded_pdf_for] = @answer.id
                Appsignal.increment_counter("ios_safari_downloaded_pdf", 1)
              end
        Severity: Minor
        Found in app/controllers/quby/answers_controller.rb - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method check_aborted has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_aborted
              if (params[:abort] && @questionnaire.abortable) ||
                (params[:save_anyway] && (@display_mode == "bulk" || @display_mode == "single_page")) ||
                (params[:previous_questionnaire])
                params[:answer] ||= HashWithIndifferentAccess.new
        Severity: Minor
        Found in app/controllers/quby/answers_controller.rb - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Avoid deeply nested control flow statements.
        Open

                          if (inputs.length == 3 && (values[0] != "" || values[1] != "" || values[2] != "")) {
                              value = values.join("-");
                          } else if (inputs.length == 1){
                              value = values[0];
                          }
        Severity: Major
        Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                            if(!isNumber){
                              pushFailVal(validation.type);
                            }
          Severity: Major
          Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                              if(count.visible > 0 && count.answered < validation.value){
                                  pushFailVal(validation.type);
                              }
            Severity: Major
            Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                if (checkboxes.length < validation.minimum_checked_value) {
                                  pushFailVal(validation.type);
                                }
              Severity: Major
              Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                  if ($(inputs[0]).attr('class') === 'date') {
                                    try {
                                      if(allDateFieldsFilledIn(inputs)) {
                                        var enteredDate = parsePartialDate(inputs);
                                        var maximumDate = new Date(validation.value)
                Severity: Major
                Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                    if(result === null || result[0] != value){
                                        pushFailVal(validation.type);
                                    }
                  Severity: Major
                  Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                      if (!is_answered(inputs)) {
                                        pushFailVal(validation.type);
                                      }
                    Severity: Major
                    Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                        if(value === undefined || value == ""){
                                            continue;
                                        }
                      Severity: Major
                      Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix

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

                                def validate_minimum(question, validation, value)
                                  # We have decided not to allow bypassing this validation when
                                  # aborted, since whatever is using this data further on is likely not
                                  # built to take into account values outside the intended range. (e.g.
                                  # BMI calculation)
                        Severity: Minor
                        Found in lib/quby/answers/services/answer_validator.rb and 1 other location - About 45 mins to fix
                        lib/quby/answers/services/answer_validator.rb on lines 154..164

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

                        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

                                def validate_maximum(question, validation, value)
                                  # We have decided not to allow bypassing this validation when
                                  # aborted, since whatever is using this data further on is likely not
                                  # built to take into account values outside the intended range. (e.g.
                                  # BMI calculation)
                        Severity: Minor
                        Found in lib/quby/answers/services/answer_validator.rb and 1 other location - About 45 mins to fix
                        lib/quby/answers/services/answer_validator.rb on lines 141..150

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

                        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

                            } else {
                              lastInput = panelInputs.filter(':eq('+index+'), :lt(' + index + ')').not(':hidden, :disabled').last();
                            }
                        Severity: Minor
                        Found in app/assets/javascripts/quby/answers/hotkeys.js and 1 other location - About 40 mins to fix
                        app/assets/javascripts/quby/answers/hotkeys.js on lines 42..44

                        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

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

                            if (forward) {
                              lastInput = panelInputs.filter(':eq('+index+'), :gt(' + index + ')').not(':hidden, :disabled').first();
                            } else {
                        Severity: Minor
                        Found in app/assets/javascripts/quby/answers/hotkeys.js and 1 other location - About 40 mins to fix
                        app/assets/javascripts/quby/answers/hotkeys.js on lines 44..46

                        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

                        Consider simplifying this complex logical expression.
                        Open

                              if (params[:abort] && @questionnaire.abortable) ||
                                (params[:save_anyway] && (@display_mode == "bulk" || @display_mode == "single_page")) ||
                                (params[:previous_questionnaire])
                                params[:answer] ||= HashWithIndifferentAccess.new
                                params[:answer][:aborted] = true
                        Severity: Major
                        Found in app/controllers/quby/answers_controller.rb - About 40 mins to fix

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

                          function setAllCheckboxes(checked, allKey, nothingKey, question, checkValue){
                          Severity: Minor
                          Found in app/assets/javascripts/quby/answers/rest.js - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language