Showing 420 of 433 total issues
Class RequestFilter
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class RequestFilter
extend ActiveModel::Naming
include ActiveModel::Conversion
attr_accessor :filter, :order, :search
File wizard.js
has 283 lines of code (exceeds 250 allowed). Consider refactoring. Open
(function($) {
var RefusalWizard = function(target, options) {
this.$el = $(target);
var defaults = {
Method authenticate
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def authenticate
if AlaveteliConfiguration.skip_admin_auth
session[:using_admin] = 1
nil
elsif session[:using_admin].nil? || session[:admin_name].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
Consider simplifying this complex logical expression. Open
if feature_enabled? :alaveteli_pro
# Accessing alaveteli professional
if user && (user.is_pro_admin? || user.is_pro?)
can :access, :alaveteli_pro
end
Class Storage
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Storage
def initialize(klass, association, setter: :data=, getter: :data,
condition: nil)
@klass = klass
@association = association
Method alert_overdue_requests
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.alert_overdue_requests
info_requests = InfoRequest.where("described_state = 'waiting_response'
AND awaiting_description = ?
AND user_id is not null
AND use_notifications = ?
Method upload_response
has a Cognitive Complexity of 19 (exceeds 5 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 = {
- 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 a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def self.start(opt={})
opt = DEFAULTS.dup.merge(opt)
Thread.new do
prev = Hash.new(0)
- 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 alert_tracks
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.alert_tracks
done_something = false
now = Time.zone.now
one_week_ago = now - 7.days
User.where(["last_daily_track_email < ?", now - 1.day ]).find_each do |user|
Class MailServerLog
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class MailServerLog < ApplicationRecord
# `serialize` needs to be called before all other ActiveRecord code.
# See http://stackoverflow.com/a/15610692/387558
serialize :delivery_status, DeliveryStatusSerializer
File link_to_helper.rb
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
module LinkToHelper
# Links to various models
# Requests
def request_url(info_request, options = {})
Method new
has a Cognitive Complexity of 18 (exceeds 5 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
- 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 18 (exceeds 5 allowed). Consider refactoring. Open
def update
@pretoken_redirect = PostRedirect.find_by(token: @pretoken) if @pretoken
if @password_change_user
@password_change_user.password = params[:password_change_user][:password]
- 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_profile_photo
has a Cognitive Complexity of 18 (exceeds 5 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
- 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 other_country_message
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def other_country_message
flash.keep
text = ""
site_country_code = AlaveteliConfiguration.iso_country_code.downcase
- 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 _destroy_and_rebuild_index_safely
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self._destroy_and_rebuild_index_safely(model_classes, verbose, terms, values, texts)
batch_size = 1000
model_classes.each do |model_class|
model_class_count = model_class.count
0.step(model_class_count, batch_size) do |i|
- 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 a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def show
long_cache
@page = get_search_page_from_params
requests_per_page = 25
- 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_csv_from_file
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, available_locales = [])
errors = []
notes = []
begin
ActiveRecord::Base.transaction do
Method body_request_events
has 60 lines of code (exceeds 25 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
Class FoiAttachment
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class FoiAttachment < ApplicationRecord
include Rails.application.routes.url_helpers
include LinkToHelper
include MessageProminence