Showing 714 of 1,025 total issues
Function validateResourceFields
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function validateResourceFields(is_new_file, resource_name, is_managed) {
// check if sharing rights are defined
if (!($(document.getElementById('sharing_scope_0')).checked) &&
!($(document.getElementById('sharing_scope_2')).checked) &&
!($(document.getElementById('sharing_scope_4')).checked))
Method cytoscape_node_elements
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def cytoscape_node_elements nodes
cytoscape_node_elements = []
nodes.each do |node|
item_type, item_id = node.split('_')
item = item_type.constantize.find_by_id(item_id)
Method list_samples_and_assay_organisms
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def list_samples_and_assay_organisms attribute, assay_samples, assay_organisms, html_options={}, none_text="Not Specified"
result= "<p class='#{html_options[:class]}' id='#{html_options[:id]}'> <b>#{attribute}</b>: "
result +="<span class='none_text'>#{none_text}</span>" if assay_samples.blank? and assay_organisms.blank?
Method update
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def update
data_file_ids = (params[:sample_data_file_ids].nil? ? [] : params[:sample_data_file_ids].reject(&:blank?)) || []
model_ids = (params[:sample_model_ids].nil? ? [] : params[:sample_model_ids].reject(&:blank?)) || []
sop_ids = (params[:sample_sop_ids].nil? ? [] : params[:sample_sop_ids].reject(&:blank?)) || []
@sample.attributes = params[:sample]
Method paginate_after_fetch
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def paginate_after_fetch(collection, *args)
options=args.pop unless args.nil?
options ||= {}
reorder = options[:reorder].nil? ? true : options[:reorder]
Function updateEvents
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function updateEvents() {
event_text = '<ul class="related_asset_list">'
for (var i = 0; i < events_array.length; i++) {
var event = events_array[i];
var title = event[0];
Function onTouchEnd
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var onTouchEnd = function(e){
slider.viewport.unbind('touchmove', onTouchMove);
var orig = e.originalEvent;
var value = 0;
// record end x, y positions
Function getViewportHeight
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var getViewportHeight = function(){
var height = 0;
// first determine which children (slides) should be used in our height calculation
var children = $();
// if mode is not "vertical" and adaptiveHeight is false, include all children
Method set_attributes_with_sharing
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def set_attributes_with_sharing sharing, projects
# if no data about sharing is given, it should be some user (not the owner!)
# who is editing the asset - no need to do anything with policy / permissions: return success
self.tap do |policy|
if sharing
Method set_parameters_for_sharing_form
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def set_parameters_for_sharing_form object=nil
object ||= eval "@#{controller_name.singularize}"
policy = nil
policy_type = ""
Method new_object_based_on_existing_one
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def new_object_based_on_existing_one
@existing_assay = Assay.find(params[:id])
@assay = @existing_assay.clone_with_associations
params[:data_file_ids]=@existing_assay.data_file_masters.collect{|d|"#{d.id},None"}
params[:related_publication_ids]= @existing_assay.related_publications.collect{|p| "#{p.id},None"}
Method update
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def update
if params[:workflow]
[:contributor_id, :contributor_type, :original_filename, :content_type, :content_blob_id, :created_at, :updated_at, :last_used_at].each do |column_name|
params[:workflow].delete(column_name)
end
Method create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create
if handle_upload_data
@workflow = Workflow.new params[:workflow]
@workflow.policy.set_attributes_with_sharing params[:sharing], @workflow.projects
Method add
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def add
if request.post?
if params[:id]=="drag_search" #needs to create the SavedSearch resource first
saved_search = SavedSearch.new(:user_id => current_user.id, :search_query => params[:search_query], :search_type => params[:search_type],:include_external_search=>params[:include_external_search]=="1")
if SavedSearch.find_by_user_id_and_search_query_and_search_type_and_include_external_search(current_user,params[:search_query],params[:search_type],params[:include_external_search]=="1").nil? && saved_search.save
Method generate_triples
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def generate_triples subject, method, property,uri_or_literal,transformation,collection_transform,rdf_graph
resource = subject.rdf_resource
transform = transformation.strip unless transformation.nil?
collection_transform = collection_transform.strip unless collection_transform.nil?
items = subject.send(method)
Method create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create
compound = params[:compound]
compound_name = compound[:title]
unless compound_name.blank?
Method extract_as_table
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def extract_as_table treatments_heading_row, sample_col, treatments_first_col,treatments_last_col,sheet
table = []
sheet_name = sheet.attributes["name"]
cells = sheet.find("//ss:sheet[@name='#{sheet_name}']/ss:rows/ss:row/ss:cell[@row >= '#{(treatments_heading_row).to_s}' and (@column = '#{sample_col.to_s}' or (@column>='#{treatments_first_col.to_s}' and @column<='#{treatments_last_col.to_s}'))]")
Method populate_db
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def populate_db data
assay = nil
assay_json = data["assay"]
Method paginate
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def paginate(*args)
options=args.pop unless args.nil?
options ||= {}
default_page = options[:default_page] || @default_page
Function EventCache
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
var EventCache = function(){
var listEvents = [];
return {
listEvents : listEvents,
add : function(node, sEventName, fHandler){
- 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"