roqua/quby_engine

View on GitHub

Showing 107 of 107 total issues

Function handleAjaxFormRequests has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function handleAjaxFormRequests(prepareDisplayModeCallback) {
  $(document).on('ajax:success', "form", function(event, data, status, xhr) {
    content_type = (xhr.getResponseHeader("content-type")||"").split(';')[0];
    if (content_type == 'text/html') { // not json response
      $('#content').replaceWith(data);
Severity: Minor
Found in app/assets/javascripts/quby/answers/rest.js - About 1 hr to fix

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

                  case "answer_group_maximum":
                      var count = calculateAnswerGroup(validation.group, panel);
                      if(count.visible > 0 && count.answered > validation.value){
                          pushFailVal(validation.type);
                      }
    Severity: Major
    Found in app/assets/javascripts/quby/answers/validation.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/quby/answers/validation.js on lines 161..166

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

    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

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

    document.onkeydown = function(event) {
        if (event == null){
            event = window.event
        }
    
    
    Severity: Minor
    Found in app/assets/javascripts/quby/disable_keys.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if ((keyCode >= 112 && keyCode <= 123)   // F1 t/m F12
                  || (event.ctrlKey && keyCode == 70) // f (zoeken)
                  || (event.ctrlKey && keyCode == 79) // o (openen)
                  || (event.ctrlKey && keyCode == 80) // p (printen)
                  ) {
      Severity: Critical
      Found in app/assets/javascripts/quby/disable_keys.js - About 1 hr to fix

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

            case 37: // left arrow
              if (!$(lastInput).is("input[type=text]") && !$(lastInput).is("input[type=range]")) {
                preventDefault(event);
                focusPrevInput();
              }
        Severity: Major
        Found in app/assets/javascripts/quby/answers/hotkeys.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/quby/answers/hotkeys.js on lines 196..201

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

        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

            case 39: //right arrow
              if (!$(lastInput).is("input[type=text]") && !$(lastInput).is("input[type=range]")) {
                preventDefault(event);
                focusNextInput();
              }
        Severity: Major
        Found in app/assets/javascripts/quby/answers/hotkeys.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/quby/answers/hotkeys.js on lines 182..187

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

        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

        Function assignValue has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function assignValue(qkey, val){
            var inputs;
            if(val instanceof Object){//checkbox vals are passed as an object hash
                inputs = $("[name^='answer["+qkey+"_'][type!='hidden']");
            } else {
        Severity: Minor
        Found in app/assets/javascripts/quby/answers/rest.js - About 1 hr to fix

          Method load_item has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def self.load_item(questionnaire, item_json, panel: nil)
                  case item_json.fetch("type")
                  when "text"
                    panel.items << build_text(item_json)
                  when "question"
          Severity: Minor
          Found in lib/quby/questionnaires/deserializer.rb - About 1 hr to fix

            Method initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    def initialize(key, options = {})
                      super(options)
            
                      @extra_data ||= {}
                      @options = []
            Severity: Minor
            Found in lib/quby/questionnaires/entities/question.rb - About 1 hr 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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    def update(new_attributes = {})
                      save_raw_params_on_error(new_attributes) do
                        attribute_filter = FiltersAnswerValue.new(answer.questionnaire)
                        attribute_filter.filter(new_attributes).each { |name, value| answer.send("#{name}=", value) }
            
            
            Severity: Minor
            Found in lib/quby/answers/services/updates_answers.rb - About 1 hr 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 to_codebook has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def to_codebook(options = {})
                      output = []
                      output << title
                      output << "Date unknown"
                      output << ""
            Severity: Minor
            Found in lib/quby/questionnaires/entities/questionnaire.rb - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                    if Quby::Settings.authorize_with_hmac
                      fail TokenValidationError, "No HMAC secret is configured" unless Quby::Settings.shared_secret.present?
                      hmac      = (params['hmac']      || @hmac         || '').strip
                      token     = (params['token']     || @answer_token || '').strip
                      timestamp = (params['timestamp'] || @timestamp    || '').strip
              Severity: Major
              Found in app/controllers/quby/answers_controller.rb - About 1 hr to fix

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

                        rescue Exception => e
                          if defined? Roqua::Support::Errors
                            Roqua::Support::Errors.report e, root_path: Rails.root.to_s
                          end
                          raise e if Rails.env.development? || Rails.env.test?
                Severity: Minor
                Found in lib/quby/answers/entities/answer.rb and 1 other location - About 55 mins to fix
                lib/quby/answers/entities/answer.rb on lines 223..230

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

                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

                        rescue Exception => e
                          if defined? Roqua::Support::Errors
                            Roqua::Support::Errors.report e, root_path: Rails.root.to_s
                          end
                          raise e if Rails.env.development? || Rails.env.test?
                Severity: Minor
                Found in lib/quby/answers/entities/answer.rb and 1 other location - About 55 mins to fix
                lib/quby/answers/entities/answer.rb on lines 250..257

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

                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

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

                      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(value === undefined || value == ""){
                                              continue;
                                          }
                        Severity: Major
                        Found in app/assets/javascripts/quby/answers/validation.js - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language