NUBIC/surveyor

View on GitHub

Showing 371 of 658 total issues

Avoid too many return statements within this function.
Open

                    return obj.slider(opts);
Severity: Major
Found in lib/assets/javascripts/surveyor/jquery-ui-timepicker-addon.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
    Severity: Major
    Found in lib/assets/javascripts/surveyor/jquery-ui-timepicker-addon.js - About 30 mins to fix

      Method build_and_set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def build_and_set(context, r)
          if !r[:section_header].blank?
            context[:survey_section].questions.build({:display_type => "label", :text => r[:section_header], :display_order => context[:survey_section].questions.size})
            Surveyor::RedcapParser.rake_trace "label_ "
          end
      Severity: Minor
      Found in lib/surveyor/redcap_parser.rb - About 25 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 to_formatted_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def to_formatted_s
              return "" if answer.nil? || answer.response_class.nil?
              return case t = answer.response_class.to_sym
                     when :string, :text, :integer, :float
                       send("#{t}_value".to_sym).to_s
      Severity: Minor
      Found in lib/surveyor/models/response_methods.rb - About 25 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 default_args has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def default_args
              self.is_mandatory ||= false
              self.display_type ||= "default"
              self.pick ||= "none"
              self.data_export_identifier ||= Surveyor::Common.normalize(text)
      Severity: Minor
      Found in lib/surveyor/models/question_methods.rb - About 25 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 default_args has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def default_args
              self.is_exclusive ||= false
              self.display_type ||= "default"
              self.response_class ||= "answer"
              self.short_text ||= text
      Severity: Minor
      Found in lib/surveyor/models/answer_methods.rb - About 25 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 has_blank_value? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def has_blank_value?(hash)
                return true if hash["answer_id"].blank?
                return false if (q = Question.find_by_id(hash["question_id"])) and q.pick == "one"
                hash.any?{|k,v| v.is_a?(Array) ? v.all?{|x| x.to_s.blank?} : v.to_s.blank?}
              end
      Severity: Minor
      Found in lib/surveyor/models/response_set_methods.rb - About 25 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 unparse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def unparse(dsl)
          with_defaults = ValidationCondition.new
          attrs = self.attributes.delete_if{|k,v| with_defaults[k] == v or %w(created_at updated_at operator rule_key id validation_id).include? k}.symbolize_keys!
          dsl << "  " if validation.answer.question.part_of_group?
          dsl << "    condition"
      Severity: Minor
      Found in lib/surveyor/unparser.rb - About 25 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 missing_columns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def missing_columns(r)
            missing = []
            missing << "choices_or_calculations" unless r.map(&:to_s).include?("choices_or_calculations") or r.map(&:to_s).include?("choices_calculations_or_slider_labels")
            missing << "text_validation_type" unless r.map(&:to_s).include?("text_validation_type") or r.map(&:to_s).include?("text_validation_type_or_show_slider_number")
            missing += (static_required_columns - r.map(&:to_s))
      Severity: Minor
      Found in lib/surveyor/redcap_parser.rb - About 25 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 all_dependencies has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def all_dependencies(question_ids = nil)
              arr = dependencies(question_ids).partition{|d| d.is_met?(self) }
              {
                :show => arr[0].map{|d| d.question_group_id.nil? ? "q_#{d.question_id}" : "g_#{d.question_group_id}"},
                :hide => arr[1].map{|d| d.question_group_id.nil? ? "q_#{d.question_id}" : "g_#{d.question_group_id}"}
      Severity: Minor
      Found in lib/surveyor/models/response_set_methods.rb - About 25 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 edit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def edit
            # @response_set is set in before_filter - set_response_set_and_render_context
            if @response_set
              @sections = SurveySection.where(survey_id: @response_set.survey_id).includes([:survey, {questions: [{answers: :question}, {question_group: :dependency}, :dependency]}])
              @section = (section_id_from(params) ? @sections.where(id: section_id_from(params)).first : @sections.first) || @sections.first
      Severity: Minor
      Found in lib/surveyor/surveyor_controller_methods.rb - About 25 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

      Severity
      Category
      Status
      Source
      Language