theodi/open-data-certificate

View on GitHub

Showing 322 of 581 total issues

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

  def remove_blank_translations(source)
    source.inject({}) do |result, (k,v)|
      result[k] = (v.is_a?(Hash) ? remove_blank_translations(v) : v) unless v.blank?
      result
    end
Severity: Minor
Found in app/models/survey.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 new_certificate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def new_certificate(options={}, &block)
    text = t('menu.create_certificate')
    if user_signed_in?
      button = button_tag(options) { text }
      content = block ? capture(button, &block) : button
Severity: Minor
Found in app/helpers/application_helper.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 end_of_dependencies has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def end_of_dependencies(question, answer, dependency, key, index, questions)
Severity: Minor
Found in app/helpers/flowchart_helper.rb - About 45 mins to fix

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

      def check_ckan_endpoint
        success = false
        redirect = nil
        if valid?
          begin
    Severity: Minor
    Found in lib/odibot.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 response_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def response_for(response_set, responses, question, answer = nil, response_group = nil)
    Severity: Minor
    Found in app/helpers/surveyor_helper.rb - About 35 mins to fix

      Method certificate_from_dataset_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def certificate_from_dataset_url
          params[:datasetUrl] ||= request.env['HTTP_REFERER']
          dataset = Dataset.match_to_user_domain(params[:datasetUrl])
          certificate = dataset.try(:certificate)
          raise ActiveRecord::RecordNotFound unless dataset && certificate
      Severity: Minor
      Found in app/controllers/certificates_controller.rb - About 35 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 compute_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def compute_fields
          return {} unless dataset.present?
      
          begin
            @fields = {}
      Severity: Minor
      Found in app/models/kitten_data.rb - About 35 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 precheck has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def precheck
          limit = params["limit"].blank? ? nil : params["limit"].to_i
          include_harvested = params.fetch("include_harvested", false)
          include_harvested = include_harvested.eql?("true")
      
      
      Severity: Minor
      Found in app/controllers/campaigns_controller.rb - About 35 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 start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def start
          @documentation_url, url_explanation = params[:response_set].values_at(
              :documentation_url, :documentation_url_explanation)
          if request.put?
            valid = false
      Severity: Minor
      Found in app/controllers/response_sets_controller.rb - About 35 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 schema has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.schema(request)
          survey = Survey.newest_survey_for_access_code request['jurisdiction']
          return {errors: ['Jurisdiction not found']} if !survey
      
          schema = {}
      Severity: Minor
      Found in app/models/certificate_generator.rb - About 35 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 cache_question_or_answer_corresponding_to_requirement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def cache_question_or_answer_corresponding_to_requirement
          if survey_section && is_requirement?
            self.question_corresponding_to_requirement ||= find_question_corresponding_to_requirement
      
            unless self.question_corresponding_to_requirement
      Severity: Minor
      Found in app/models/question.rb - About 35 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 get_dataset_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_dataset_url(resource)
            if resource['harvest_source_title'].blank?
              return build_url("/dataset/#{resource['name']}")
            else
              if @include_harvested
      Severity: Minor
      Found in lib/extra/certificate_factory/factory.rb - About 35 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 too many return statements within this function.
      Open

            return autoValues.filter(function(value, i) { return value != selectedValues[i]; }).length === 0;
      Severity: Major
      Found in app/assets/javascripts/surveyor_all.js - About 30 mins to fix

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

          def archive_other_response_sets
            related = dataset.try(:response_sets) || []
        
            related.each do |response_set|
              if response_set.id != self.id
        Severity: Minor
        Found in app/models/response_set.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 css_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def css_class(response_set)
            triggered = triggered?(response_set) || (part_of_group? && question_group.dependent?)
            [(dependent? ? "q_dependent" : nil), (triggered ? nil : "q_hidden"), custom_class].compact.join(" ")
          end
        Severity: Minor
        Found in app/models/question.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 response_errors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def response_errors
            errors = Hash.new { |h, k| h[k] = [] }
            incomplete_triggered_mandatory_questions.each do |question|
              response = responses.where(question_id: question.id).first
        
        
        Severity: Minor
        Found in app/models/response_set.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 no_published_certificate_exists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def no_published_certificate_exists
            documentation_url = params[:dataset][:documentationUrl]
            return unless documentation_url.present?
            existing_dataset = Dataset.where(documentation_url: documentation_url).first
            if existing_dataset.try(:certificate).present?
        Severity: Minor
        Found in app/controllers/datasets_controller.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 copy_answers_from_response_set! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def copy_answers_from_response_set!(source_response_set)
            ui_hash = HashWithIndifferentAccess.new
        
            raise "Attempt to over-write existing responses." if responses.any? # TODO: replace with specific exception
        
        
        Severity: Minor
        Found in app/models/response_set.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 get_responses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_responses
            responses = []
        
            self.response_set.survey.sections.each do |section|
              qs = section.questions_for_certificate self.response_set
        Severity: Minor
        Found in app/models/certificate.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 check_frequency has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_frequency
            num_distributions = data[:distributions].length
            if data[:update_frequency].blank?
              num_distributions == 1 ? "oneoff" : "collection"
            elsif num_distributions > 1
        Severity: Minor
        Found in app/models/kitten_data.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