Showing 277 of 434 total issues
Method add_correspondence
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def add_correspondence
json = ActiveSupport::JSON.decode(params[:correspondence_json])
attachments = params[:attachments]
direction = json["direction"]
- 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 expand_and_normalize_parts
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def expand_and_normalize_parts(part, parent_mail)
if part.multipart?
Mail::PartsList.new(part.parts.each { |sub_part| expand_and_normalize_parts(sub_part, parent_mail) })
else
part_filename = get_part_file_name(part)
- 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 list
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list
long_cache
@tag = params[:tag] || 'all'
@tag = @tag.upcase if @tag.scan(/./mu).size == 1
Method new
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new
if params[:comment]
# TODO: this check should theoretically be a validation rule in the model
@existing_comment = Comment.find_existing(@info_request.id, params[:comment][:body])
else
Method create_fixtures
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_fixtures(fixtures_directory, fixture_set_names, class_names = {}, config = ActiveRecord::Base)
fixture_set_names = Array(fixture_set_names).map(&:to_s)
class_names = ClassCache.new class_names, config
# FIXME: Apparently JK uses this.
Method results
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def results
# If they've already pulled out the results, just return them.
return cached_results unless cached_results.nil?
docs = []
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 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 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 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 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 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 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 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 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 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"