roqua/quby_engine

View on GitHub

Showing 107 of 107 total issues

Method rows has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

        def rows
          return @rows if @rows
          @item_table = [[]]
          @rows = [[[]]]
          filled_columns = 0
Severity: Minor
Found in lib/quby/questionnaires/entities/table.rb - About 1 day 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

Consider simplifying this complex logical expression.
Open

        if ((keyCode == 8 && 
            (target.tagName != 'INPUT' || (target.type != 'text' && target.type != 'password')) && 
            target.tagName != 'TEXTAREA') // Backspace outside input field
            || (event.ctrlKey && keyCode == 65) // a (alles selecteren)
            || (event.ctrlKey && keyCode == 66) // b (favorieten indelen)
Severity: Critical
Found in app/assets/javascripts/quby/disable_keys.js - About 7 hrs to fix

    Function validatePanel has 187 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      window.validatePanel = function(panel) {
        if(skipValidations){
            return true;
        }
        var failed = false;
    Severity: Major
    Found in app/assets/javascripts/quby/answers/validation.js - About 7 hrs to fix

      Function onkeydown has a Cognitive Complexity of 43 (exceeds 5 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 6 hrs 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

      File deserializer.rb has 404 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Quby
        module Questionnaires
          module Deserializer
            # This symbolizes various things. Do not run on arbitrary JSON.
            def self.from_json(json)
      Severity: Minor
      Found in lib/quby/questionnaires/deserializer.rb - About 5 hrs to fix

        Method value_by_regular_values has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

                def value_by_regular_values
                  result = {}
                  if value
                    result = value.dup
                    value.each do |key, answer|
        Severity: Minor
        Found in lib/quby/answers/entities/answer.rb - About 5 hrs 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

        Class Questionnaire has 34 methods (exceeds 20 allowed). Consider refactoring.
        Open

              class Questionnaire
                extend  ActiveModel::Naming
                include ActiveModel::Validations
        
                class ValidationError < StandardError; end
        Severity: Minor
        Found in lib/quby/questionnaires/entities/questionnaire.rb - About 4 hrs to fix

          File questionnaire.rb has 347 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'active_model'
          require 'quby/settings'
          require 'quby/questionnaires/entities/flag'
          require 'quby/questionnaires/entities/textvar'
          require 'quby/questionnaires/entities/validation'
          Severity: Minor
          Found in lib/quby/questionnaires/entities/questionnaire.rb - About 4 hrs to fix

            Method validate has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

                    def validate
                      questionnaire.questions.each do |question|
                        next unless question
                        next if question.hidden?
            
            
            Severity: Minor
            Found in lib/quby/answers/services/answer_validator.rb - About 4 hrs 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 build_question has 99 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def self.build_question(questionnaire, item_json, parent: nil, table: nil)
                    key = item_json.fetch("key").to_sym
                    attributes = {
                      questionnaire: questionnaire,
                      parent: parent,
            Severity: Major
            Found in lib/quby/questionnaires/deserializer.rb - About 3 hrs to fix

              Method rows has 92 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def rows
                        return @rows if @rows
                        @item_table = [[]]
                        @rows = [[[]]]
                        filled_columns = 0
              Severity: Major
              Found in lib/quby/questionnaires/entities/table.rb - About 3 hrs to fix

                Class Answer has 30 methods (exceeds 20 allowed). Consider refactoring.
                Open

                      class Answer
                        extend ActiveModel::Naming
                        extend ActiveModel::Translation
                
                        # @return [String]
                Severity: Minor
                Found in lib/quby/answers/entities/answer.rb - About 3 hrs to fix

                  Class AnswersController has 26 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class AnswersController < Quby::ApplicationController
                      DISPLAY_MODES = %w(paged bulk single_page).freeze
                  
                      before_action :load_token_and_hmac_and_timestamp
                      before_action :load_return_url_and_token
                  Severity: Minor
                  Found in app/controllers/quby/answers_controller.rb - About 3 hrs to fix

                    Class ScoreCalculator has 26 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                          class ScoreCalculator
                            class UnknownFieldsReferenced < StandardError; end
                    
                            class MissingAnswerValues < StandardError
                              attr_reader :questionnaire_key, :values, :missing
                    Severity: Minor
                    Found in lib/quby/answers/services/score_calculator.rb - About 3 hrs to fix

                      File validation.js has 290 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      (function() {
                        window.skipValidations = false;
                        var validationI = 0;
                        var fail_vals = new Array();
                      
                      
                      Severity: Minor
                      Found in app/assets/javascripts/quby/answers/validation.js - About 2 hrs to fix

                        File rest.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        function initShowsHides(untilPanelId) {
                          Quby.panels.find(function (bbPanel) {
                            bbPanel.initShowsHides(Quby.questions);
                            return bbPanel.get('panelId') == untilPanelId;
                          });
                        Severity: Minor
                        Found in app/assets/javascripts/quby/answers/rest.js - About 2 hrs to fix

                          Class Question has 24 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                                class Question < Item
                                  MARKDOWN_ATTRIBUTES = %w(description title).freeze
                          
                                  # Standard attributes
                                  attr_accessor :key
                          Severity: Minor
                          Found in lib/quby/questionnaires/entities/question.rb - About 2 hrs to fix

                            Method answer_dsl_module has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    def answer_dsl_module # rubocop:disable Metrics/MethodLength
                                      # Have to put this in a local variable so the module definition block can access it
                                      questions_in_var = questions
                            
                                      @answer_dsl_cache ||= Module.new do
                            Severity: Major
                            Found in lib/quby/questionnaires/entities/questionnaire.rb - About 2 hrs to fix

                              File answer.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              require 'active_model'
                              require 'quby/answers/entities/outcome'
                              require 'quby/answers/dsl'
                              
                              module Quby
                              Severity: Minor
                              Found in lib/quby/answers/entities/answer.rb - About 2 hrs to fix

                                Method verify_hmac has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def verify_hmac # rubocop:disable CyclomaticComplexity
                                      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
                                Severity: Minor
                                Found in app/controllers/quby/answers_controller.rb - About 2 hrs 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

                                Severity
                                Category
                                Status
                                Source
                                Language