Showing 5,431 of 5,433 total issues
Complex method Submission#next_requests_via_submission (58.5) Open
def next_requests_via_submission(request) # rubocop:todo Metrics/CyclomaticComplexity
raise "Request #{request.id} is not part of submission #{id}" unless request.submission_id == id
# Pick out the siblings of the request, so we can work out where it is in the list, and all of
# the requests in the subsequent request type, so that we can tie them up. We order by ID
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method SubmissionSerializer::construct! (57.8) Open
def self.construct!(hash) # rubocop:todo Metrics/CyclomaticComplexity
st = {}
STRAIGHT_CLONE.each { |key| st[key.to_sym] = hash[key.to_sym] }
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
File studies_controller.rb
has 310 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rexml/document'
# rubocop:todo Metrics/ClassLength
class StudiesController < ApplicationController
# WARNING! This filter bypasses security mechanisms in rails 4 and mimics rails 2 behviour.
Method process
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def process # rubocop:todo Metrics/CyclomaticComplexity
# Store the details of the successful submissions so the user can be presented with a summary
@submission_ids = []
@completed_submissions = {}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$("#report_fail_user_code").bind("keydown", function (e) {
/* We don't take tab index into account here */
var ENTER = 13,
TAB = 9,
code;
- 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 103.
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
$("#labwhere_reception_user_code").bind("keydown", function (e) {
/* We don't take tab index into account here */
var ENTER = 13,
TAB = 9,
code;
- 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 103.
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
Complex method StudyReport::StudyDetails#progress_report_on_all_assets (56.7) Open
def progress_report_on_all_assets # rubocop:todo Metrics/AbcSize
yield(progress_report_header)
each_stock_well_id_in_study_in_batches do |asset_ids|
# eager loading of well_attribute , can only be done on wells ...
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Api::EndpointHandler::instance_action (56.7) Open
def instance_action(action, http_method) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
send(
http_method,
%r{/([\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12})(?:/([^/]+(?:/[^/]+)*))?},
file_attached: false,
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method namespace#record_loader (56.1) Open
namespace :record_loader do
desc 'Automatically generate TubeRackPurpose through TubeRackPurposeLoader'
task tube_rack_purpose: :environment do
RecordLoader::TubeRackPurposeLoader.new.create!
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method namespace(benchmark)::task#plate_transfer (56.0) Open
task plate_transfer: :environment do
$stdout.puts 'Preparing'
stock = Purpose.find_by(name: 'Shear').create!
sample = Sample.find_or_create_by(name: 'test_sample')
stock.wells.each do |w|
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Class SubmissionCreator
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Submission::SubmissionCreator < Submission::PresenterSkeleton # rubocop:todo Metrics/ClassLength
SubmissionsCreaterError = Class.new(StandardError)
IncorrectParamsException = Class.new(SubmissionsCreaterError)
InvalidInputException = Class.new(SubmissionsCreaterError)
Complex method Accession::Sample#to_xml (55.8) Open
def to_xml # rubocop:todo Metrics/AbcSize
tag_groups = tags.by_group
xml = Builder::XmlMarkup.new
xml.instruct!
xml.SAMPLE_SET(XML_NAMESPACE) do
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Tasks::CherrypickHandler#setup_input_params_for_pass_through (55.6) Open
def setup_input_params_for_pass_through # rubocop:todo Metrics/AbcSize
@robot_id = params[:robot_id]
@robot = Robot.find(@robot_id)
@plate_type = params[:plate_type]
if params[:nano_grams_per_micro_litre]
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Api::Base::render_class_for_model (55.4) Open
def render_class_for_model(model) # rubocop:todo Metrics/CyclomaticComplexity
render_class = Class.new(self)
# NOTE: It's quite annoying that you don't have any access to the inheritable class attributes from
# within the Class.new block above, so we have to do a separate instance_eval to get it to work.
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method PlatesController#create_sample_tubes (55.2) Open
def create_sample_tubes # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
barcode_printer = BarcodePrinter.find(params[:plates][:barcode_printer])
barcode_array = params[:plates][:source_plates].scan(/\w+/)
plates = Plate.with_barcode(barcode_array)
study = Study.find(params[:plates][:study])
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Api::Base::to_hash (55.1) Open
def to_hash(object) # rubocop:todo Metrics/CyclomaticComplexity
# If the object is nil we get a chance to use the 'default' object that was specified. By
# default the "default" object is nil, but you can override it for associations through the
# with_association(:name, :if_nil_use => :some_method).
object ||= default_object
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Api::SampleIO::with_association#sample_metadata (54.9) Open
with_association(:sample_metadata) do
map_attribute_to_json_attribute(:organism)
map_attribute_to_json_attribute(:cohort)
map_attribute_to_json_attribute(:country_of_origin)
map_attribute_to_json_attribute(:geographical_region)
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Class Well
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Well < Receptacle # rubocop:todo Metrics/ClassLength
include Api::WellIO::Extensions
include ModelExtensions::Well
include Cherrypick::VolumeByNanoGrams
include Cherrypick::VolumeByNanoGramsPerMicroLitre
Complex method Admin::UsersController#grant_user_role (53.7) Open
def grant_user_role # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
if request.xhr?
if params[:role]
authorizable_object =
if params[:role][:authorizable_type] == 'Project'
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method AssetsController#lookup (53.6) Open
def lookup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
if params[:asset] && params[:asset][:barcode]
@assets = Labware.with_barcode(params[:asset][:barcode]).limit(50).page(params[:page])
case @assets.size
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool