Showing 337 of 433 total issues
Method decode_attached_part
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def decode_attached_part(part, parent_mail)
if get_content_type(part) == 'message/rfc822'
# An email attached as text
part.rfc822_attachment = mail_from_raw_email(part.body)
if part.rfc822_attachment.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 upload_response
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upload_response
AlaveteliLocalization.with_locale(locale) do
@info_request = InfoRequest.not_embargoed.find_by_url_title!(params[:url_title])
@reason_params = {
Method render_new_compose
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render_new_compose
params[:info_request] = {} unless params[:info_request]
# Reconstruct the params
# first the public body (by URL name or id)
Class AttachmentsController
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class AttachmentsController < ApplicationController
include FragmentCachable
include InfoRequestHelper
include PublicTokenable
Method create
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
set_last_request(@info_request)
if params[:last_info_request_event_id].to_i != @info_request.
last_event_id_needing_description
Method initialize_query
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize_query(options)
#raise options.to_yaml
self.runtime += Benchmark.realtime {
offset = options[:offset] || 0
Method signchangeemail
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def signchangeemail
# "authenticated?" has done the redirect to signin page for us
return unless authenticated? || ask_to_login(
web: _('To change your email address used on {{site_name}}',
site_name: site_name),
Method create
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def create
if @post_redirect.present?
@user_signin =
User.authenticate_from_form(user_signin_params,
@post_redirect.reason_params[:user_name])
- 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 public_bodies
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.public_bodies
per_graph = 10
minimum_requests = AlaveteliConfiguration.minimum_requests_for_statistics
# Make sure minimum_requests is > 0 to avoid division-by-zero
minimum_requests = [minimum_requests, 1].max
Method destroy_and_rebuild_index
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.destroy_and_rebuild_index(model_classes, verbose = false, terms = true, values = true, texts = true, safe_rebuild = true)
#raise "when rebuilding all, please call as first and only thing done in process / task" if not ActsAsXapian.writable_db.nil?
prepare_environment
update_existing = !(terms == true && values == true && texts == true)
Method set_profile_photo
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_profile_photo
# check they are logged in (the upload photo option is anyway only available when logged in)
unless authenticated?
flash[:error] = _("You need to be logged in to change your profile photo.")
redirect_to frontpage_url
Method load_file
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.load_file(file_name)
is_gz = file_name.include?(".gz")
file_name_db = is_gz ? file_name.gsub(".gz", "") : file_name
modified = File.stat(file_name).mtime
- 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 who_can_followup_to
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def who_can_followup_to(skip_message = nil)
ret = []
done = {}
if skip_message
if (email = OutgoingMailer.email_for_followup(self, skip_message))
- 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 each
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def each(&_block)
to_enum(:each) unless block_given?
yield prepare_dashboard_metrics
- 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 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 = []