theodi/open-data-certificate

View on GitHub

Showing 581 of 581 total issues

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

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

          if ($(this).val().length > 0) {
            $(this).parent().children().has('input[type="radio"]')[0].children[0].checked = true;
          }
      Severity: Minor
      Found in app/assets/javascripts/surveyor_all.js and 1 other location - About 55 mins to fix
      app/assets/javascripts/surveyor_all.js on lines 47..49

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

      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

          if (textValue.length > 0) {
            $(this).parent().children().has('input[type="checkbox"]')[0].children[0].checked = true;
          }
      Severity: Minor
      Found in app/assets/javascripts/surveyor_all.js and 1 other location - About 55 mins to fix
      app/assets/javascripts/surveyor_all.js on lines 53..55

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

      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

          subsetTypeahead.element.typeahead([{
            hint: false, minLength: 3,
            name:'organisations-'+(new Date-0),
            header: '<h3>Organisations</h3>',
            template: '<p class="">{{ value }}</p>',
      Severity: Minor
      Found in app/assets/javascripts/campaign.js and 1 other location - About 50 mins to fix
      app/assets/javascripts/campaign.js on lines 71..78

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

      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

          }, {
            hint: false, minLength: 3,
            name:'tags-'+(new Date-0),
            header: '<h3>Tags</h3>',
            template: '<p class="">{{ value }}</p>',
      Severity: Minor
      Found in app/assets/javascripts/campaign.js and 1 other location - About 50 mins to fix
      app/assets/javascripts/campaign.js on lines 64..71

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

      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

      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

          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

              Severity
              Category
              Status
              Source
              Language