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
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'
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
- Read upRead up
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
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]
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;
}
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
- Read upRead up
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"
- Read upRead up
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
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 = {
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
- Read upRead up
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
- Read upRead up
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|
- Read upRead up
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
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 == ""
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"
{
Method dependency
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def dependency(question, answer, key, index, dependencies, questions)
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?
- Read upRead up
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"
- Read upRead up
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)