theodi/open-data-certificate

View on GitHub

Showing 322 of 581 total issues

Method initialize has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(user)

    can :manage, ResponseSet do |response_set|
      response_set.nil? || response_set.unowned_or_by?(user)
    end
Severity: Minor
Found in app/models/ability.rb - About 1 hr to fix

    Method typeahead has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def typeahead
        # responses for the autocomplete, gives results in
        # [{title:"the match title", path:"/some/path"},…]
        @response = case params[:mode]
          when 'dataset'
    Severity: Minor
    Found in app/controllers/datasets_controller.rb - About 1 hr to fix

      Method response_for has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def response_for(response_set, responses, question, answer = nil, response_group = nil)
          return nil unless responses && question && question.id
          result = responses.detect{|r| (r.question_id == question.id) && (answer.blank? ? true : r.answer_id == answer.id) && (r.response_group.blank? ? true : r.response_group.to_i == response_group.to_i)}
          result ? result : response_set.responses.build(:question_id => question.id, :response_group => response_group)
        end
      Severity: Minor
      Found in app/helpers/surveyor_helper.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 show has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def show
          @certificate_level = params.fetch("certificate_level", "all")
          @generators = @campaign.certificate_generators.includes(:dataset, :certificate).where(latest: true)
          respond_to do |want|
            want.html do
      Severity: Minor
      Found in app/controllers/campaigns_controller.rb - About 1 hr to fix

        Method continue has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def continue
            if Survey::MIGRATIONS.has_key?(@response_set.survey.access_code)
              # lets switch over to the new questionnaire
              nxt = Survey::MIGRATIONS[@response_set.survey.access_code]
        
        
        Severity: Minor
        Found in app/controllers/surveyor_controller.rb - About 1 hr to fix

          Function precheckCampaign has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            var precheckCampaign = function(event){
              var disabled = $('#campaign_precheck').attr('disabled');
              if (disabled == "disabled"){ console.log("disabled");
                return;
              }
          Severity: Minor
          Found in app/assets/javascripts/campaign.js - About 1 hr to fix

            Method kitten_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def kitten_value value
                case value
                when Array
                  safe_join(value.map {|v| kitten_value v}, ', ')
                when DataKitten::Agent
            Severity: Minor
            Found in app/helpers/application_helper.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 answers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def answers(question)
                # returns result of dependency method, or an array of hashes based on input type
                # hash is usually a single key=> value assignment
            
                if type(question) == "yesno"
            Severity: Minor
            Found in lib/flow.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 start has 28 lines of code (exceeds 25 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 1 hr to fix

              Method request_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def request_data
                  @dataset ||= DataKitten::Dataset.new(access_url: url) rescue nil
              
                  if @dataset && @dataset.supported? && dataset_field(:data_title)
                    self.data = {
              Severity: Minor
              Found in app/models/kitten_data.rb - About 1 hr to fix

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

                  def compute_autocompleted
                    if autocompletable?
                      if question.pick == 'none'
                        return data_value == auto_value
                      end
                Severity: Minor
                Found in app/models/response.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 self.update(dataset, request, jurisdiction, user)
                
                    # Finds a migrated survey if there is one
                    survey = Survey.newest_survey_for_access_code Survey::migrate_access_code(jurisdiction)
                    return {success: false, errors: ['Jurisdiction not found']} if !survey
                Severity: Minor
                Found in app/models/certificate_generator.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 determine_user has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  def determine_user(response_set, create_user)
                    kitten_data = response_set.kitten_data
                    if kitten_data
                      contacts = kitten_data.contacts_with_email
                      contacts.each do |contact|
                Severity: Minor
                Found in app/models/certificate_generator.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 kitten_value has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def kitten_value value
                    case value
                    when Array
                      safe_join(value.map {|v| kitten_value v}, ', ')
                    when DataKitten::Agent
                Severity: Minor
                Found in app/helpers/application_helper.rb - About 1 hr to fix

                  Method to_hash has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def to_hash(response_set, responses_pre = nil)
                  
                      responses_pre = response_set.responses.all unless responses_pre
                  
                      if ['==', '!='].include?(operator) && string_value == ""
                  Severity: Minor
                  Found in app/models/dependency_condition.rb - About 1 hr to fix

                    Method licence_from_ref has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def licence_from_ref(licence_type)
                        ref = value_for(licence_type, :reference_identifier)
                        case ref
                        when nil, "na"
                          {
                    Severity: Minor
                    Found in app/models/response_set.rb - About 1 hr to fix

                      Method dependency has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

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

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

                          def link_header_params(datasets)
                            links = {first: nil}
                            links[:last] = datasets.total_pages if datasets.total_pages > 1
                            links[:next] = datasets.next_page unless datasets.last_page?
                            unless datasets.first_page?
                        Severity: Minor
                        Found in app/controllers/datasets_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 set_license has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def set_license
                            return if @fields["dataLicence"]
                            return unless data[:licenses].any?
                        
                            @fields["publisherRights"] = "yes"
                        Severity: Minor
                        Found in app/models/kitten_data.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 answer has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          def answer(question, answer, key, index, dependencies, questions)
                        Severity: Minor
                        Found in app/helpers/flowchart_helper.rb - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language