Showing 90 of 436 total issues
Method xapian_index
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
def xapian_index(terms = true, values = true, texts = true)
# if we have a conditional function for indexing, call it and destroy object if failed
if self.class.xapian_options.include?(:if)
if_value = xapian_value(self.class.xapian_options[:if], :boolean)
unless if_value
Similar blocks of code found in 2 locations. Consider refactoring. Open
RSpec.describe AlaveteliFeatures::Helpers do
let(:instance) { Class.new { include AlaveteliFeatures::Helpers }.new }
let(:test_backend) { Flipper.new(Flipper::Adapters::Memory.new) }
around do |example|
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 114.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
RSpec.describe AlaveteliFeatures::Helpers do
let(:instance) { Class.new { include AlaveteliFeatures::Helpers }.new }
let(:test_backend) { Flipper.new(Flipper::Adapters::Memory.new) }
around do |example|
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 114.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function setUpCorrespondenceCollapsing
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
var setUpCorrespondenceCollapsing = function(){
$('.js-collapsable').each(function(){
var $collapsable = $(this);
var $triggers = $(this).find('.js-collapsable-trigger');
var $correspondenceHeader = $(this).find('.correspondence__header');
Method index
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
# Tasks to do
@requires_admin_requests = InfoRequest.
find_in_state('requires_admin').
not_embargoed
Method add_correspondence
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_correspondence
json = ActiveSupport::JSON.decode(params[:correspondence_json])
attachments = params[:attachments]
direction = json["direction"]
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 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|
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
Method alert_comment_on_request
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.alert_comment_on_request
# We only check comments made in the last month - this means if the
# cron jobs broke for more than a month events would be lost, but no
# matter. I suspect the performance gain will be needed (with an index on updated_at)
Method show
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
long_cache
@page = get_search_page_from_params
requests_per_page = 25
Method get_attachment_text_one_file
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_attachment_text_one_file(content_type, body, charset = 'utf-8')
# NOTE: re. charset: TMail always tries to convert email bodies
# to UTF8 by default, so normally it should already be that.
text = ''
# TODO: - tell all these command line tools to return utf-8
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)
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 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 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.alert_expiring
expiring_info_requests =
InfoRequest.
embargo_expiring.
where(use_notifications: false).
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 69.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76