Showing 5,431 of 5,433 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
if params[:role]
authorizable_object =
if params[:role][:authorizable_type] == 'project'
Project.find(params[:role][:authorizable_id])
else
- 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 72.
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
Method progress_report_on_all_assets
has 45 lines of code (exceeds 25 allowed). Consider refactoring. 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 ...
Complex method AccessionService#accession_submission_xml (37.5) Open
def accession_submission_xml(submission, accession_number) # rubocop:todo Metrics/AbcSize
xml = Builder::XmlMarkup.new
xml.instruct!
xml.SUBMISSION(
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
- 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 Robot::Verification::Base#validate_barcode_params (37.4) Open
def validate_barcode_params(barcode_hash) # rubocop:todo Metrics/CyclomaticComplexity
return yield('No barcodes specified') if barcode_hash.nil?
if barcode_hash[:batch_barcode].blank? || !Batch.valid_barcode?(barcode_hash[:batch_barcode])
yield('Worksheet barcode invalid')
- 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 Ability::BaseUser#grant_privileges (37.4) Open
def grant_privileges # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
Rails.logger.debug { 'Granting BaseUser privileges' }
can :delete, Comment, { user_id: user.id }
can :create, Comment, commentable_type: %w[Study Sample], commentable: { owners: { id: user.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 SamplesController#create (37.4) Open
def create # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
@sample = Sample.new(params[:sample])
study_id = params[:study_id]
if study_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 Tasks::PlateTransferHandler#find_or_create_target (37.4) Open
def find_or_create_target(task) # rubocop:todo Metrics/AbcSize
return target_plate if target_plate.present?
# We only eager load the request stuff if we actually need it.
batch_requests = @batch.requests.includes(includes_for_plate_creation)
- 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 Submission::AssetSubmissionFinder#find_wells_including_samples_for! (37.3) Open
def find_wells_including_samples_for!(details) # rubocop:todo Metrics/AbcSize
barcodes, well_list = details['barcode'], details['plate well']
errors.add(:spreadsheet, 'You can only specify one plate per asset group') unless barcodes.uniq.one?
barcode = barcodes.first
plate = Plate.find_from_barcode(barcode)
- 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 Accessionable::Sample#xml (37.2) Open
def xml # rubocop:todo Metrics/AbcSize
xml = Builder::XmlMarkup.new
xml.instruct!
xml.SAMPLE_SET('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do
xml.SAMPLE(sample_element_attributes) 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 Transfer::State::TubeState::included (37.2) Open
def self.included(base) # rubocop:todo Metrics/MethodLength
base.class_eval do
scope :in_state,
lambda { |states|
states = Array(states).map(&:to_s)
- 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
Method perform_pick
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform_pick(requests, robot, control_source_plate, workflow_controller) # rubocop:todo Metrics/AbcSize
max_plates = robot.max_beds
raise StandardError, 'The chosen robot has no beds!' if max_plates.zero?
destination_plates = []
Method render_class_for_model
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. 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
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 record_tube_samples
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def record_tube_samples # rubocop:todo Metrics/AbcSize
tube_counter = 0
first_to_last.each do |sheet_row|
row = dynamic_attributes[sheet_row]
build_tube_sample_manifest_asset do |sample_manifest_asset|
- 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 generate_picking_data_hash
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def generate_picking_data_hash(target_barcode, requests: requests_for_destination_plate)
data_objects = {}
source_barcode_to_pick_number = {}
current_pick_size = lambda { data_objects[data_objects.size]['source'].size }
- 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
Complex method AssetsController#show (36.9) Open
def show # rubocop:todo Metrics/CyclomaticComplexity, Metrics/MethodLength
# LEGACY API FOR CGP to allow switch-over
# In future they will use the recpetacles/:id/parent
if request.format.xml?
@asset = Receptacle.include_for_show.find(params[: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
Method process
has 43 lines of code (exceeds 25 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 = {}
Method create_request_chain!
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_request_chain!(request_type_and_multiplier_pairs, source_data_set, multiplexing_assets, &block) # rubocop:todo Metrics/CyclomaticComplexity
raise StandardError, 'No request types specified!' if request_type_and_multiplier_pairs.empty?
request_type, multiplier = request_type_and_multiplier_pairs.shift
Similar blocks of code found in 2 locations. Consider refactoring. Open
const select_all = function () {
var scope = this.dataset.scope || "body";
// find all the enabled, unchecked checkboxes and select them
// fire the change event on them, to allow other js code to pick up that they have changed
$(scope).find('input[type="checkbox"]:enabled:not(:checked)').prop("checked", true).trigger("change");
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
const deselect_all = function () {
var scope = this.dataset.scope || "body";
// find all the enabled, checked checkboxes and deselect them
// fire the change event on them, to allow other js code to pick up that they have changed
$(scope).find('input[type="checkbox"]:enabled:checked').prop("checked", false).trigger("change");
- 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
Complex method RequestClassDeprecator#deprecate_class (36.2) Open
def deprecate_class(request_class_name, options = {}) # rubocop:todo Metrics/AbcSize
state_changes = options.fetch(:state_change, {})
new_request_type = options.fetch(:new_type, transfer_request)
new_class_name = new_request_type.request_class_name
- 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