Showing 338 of 434 total issues
Function stripeForm
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function stripeForm(form, options) {
var that = Object.assign({
stripe: Stripe(AlaveteliPro.stripe_publishable_key),
form: form,
submit: document.getElementById('js-stripe-submit'),
- 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 receive
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def receive(email, raw_email_data, *args)
return if already_received?(email)
defaults = { override_stop_new_responses: false,
rejected_reason: nil,
- 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 get_attachment_text_from_zip_file
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_attachment_text_from_zip_file(zip_file)
text = ""
zip_file.each do |entry|
if entry.file?
filename = entry.to_s
- 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 process_data
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self.process_data(filename, display_header, column_data, overrides, query)
CSV.open(filename, "wb") do |csv|
csv << display_header
find_each_record(query) do |model_instance|
line = []
- 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 attempt_to_find_original_attachment_attributes
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def attempt_to_find_original_attachment_attributes(mail, body:, nested: false)
all_attributes = get_attachment_attributes(mail)
def calculate_hexdigest(body)
# ensure bodies have the same line endings and are encoded the same
- 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 normalize_string_to_utf8
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def normalize_string_to_utf8(s, suggested_character_encoding=nil)
# Make a list of encodings to try:
to_try = []
guessed_encoding = if CharlockHolmes::EncodingDetector.detect(s).blank?
- 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 with_query
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.with_query(query, tag)
like_query = "%#{query}%"
has_first_letter = tag.size == 1
underscore_locale = AlaveteliLocalization.locale
Method start
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.start(opt={})
opt = DEFAULTS.dup.merge(opt)
Thread.new do
prev = Hash.new(0)
Method status_description
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def status_description(info_request, status)
case status
when 'waiting_classification'
_('Awaiting classification')
when 'waiting_response'
Method create
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
begin
@pro_account = current_user.pro_account ||= current_user.build_pro_account
# Ensure previous incomplete subscriptions are cancelled to prevent them
Method update
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
old_title = @info_request.title
old_prominence = @info_request.prominence
old_prominence_reason = @info_request.prominence_reason
old_described_state = @info_request.described_state
Method import_csv
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_csv
@notes = ""
@errors = ""
if request.post?
dry_run_only = params['commit'] != 'Upload'
Method authorise
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authorise
@subscription = current_user.pro_account.subscriptions.
retrieve(params.require(:id))
if !@subscription
Method download_entire_request
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def download_entire_request
AlaveteliLocalization.with_locale(locale) do
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
# Check for access and hide emargoed requests immediately, so that we
# don't leak any info to people who can't access them
- 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 import_values_from_csv_row
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def import_values_from_csv_row(row, line, name, options)
is_new = new_record?
edit_info = if is_new
{ action: "creating new authority",
comment: 'Created from spreadsheet' }
- 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 display_status
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def display_status
if is_incoming_message?
status = calculated_state
return status.nil? ? _("Response") : InfoRequest.get_status_description(status)
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 excerpt
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def excerpt(text, phrase, options = {})
return unless text && phrase
separator = options.fetch(:separator, nil) || ""
case phrase
- 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 words_to_highlight
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def words_to_highlight(opts = {})
default_opts = { include_original: false, regex: false }
opts = default_opts.merge(opts)
# Reject all prefixes other than Z, which we know is reserved for stems
- 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 body_request_events
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def body_request_events
feed_type = params[:feed_type]
if @public_body.id != params[:id].to_i
raise PermissionDenied, "#{@public_body.id} != #{params[:id]}"
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 tnef_attachments
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def tnef_attachments(content)
attachments = []
Dir.mktmpdir do |dir|
IO.popen("tnef -K -C #{dir} 2> /dev/null", "wb") do |f|
f.write(content)
- 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"