Showing 714 of 1,025 total issues
Method authorized_associations_for_action?
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def authorized_associations_for_action?
result = true
if self.class.respond_to?(:associations_and_actions_to_be_enforced)
self.class.associations_and_actions_to_be_enforced.keys.each do |association|
if self.respond_to?(association)
- 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 extract_species_and_reaction_names
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def extract_species_and_reaction_names doc
species = []
reactions = []
species_names_node = doc.find_first("//speciesNames")
species_names_node.children.each do |child|
- 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
Function tab_on_click
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function tab_on_click(scale_title, resource_type, resource_ids, actions_partial_disable){
var click_tab = document.getElementsByClassName(scale_title + '_' + resource_type)[0];
click_tab.onclick = function(){
deactivate_previous_tab(this);
click_tab.parentElement.className = 'tabberactive';
Method list_item_visibility
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def list_item_visibility item,css_class="visibility_icon"
title = ""
html = ""
policy = item.policy
Method summarize_permissions
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def summarize_permissions creators=[User.current_user.try(:person)], asset_managers = [], contributor=User.current_user.try(:person)
#build the hash containing contributor_type as key and the people in these groups as value,exception:'Public' holds the access_type as the value
people_in_group = {'Person' => [], 'FavouriteGroup' => [], 'WorkGroup' => [], 'Project' => [], 'Institution' => [], 'WhiteList' => [], 'BlackList' => [],'Network' => [], 'Public' => 0}
#the result return: a hash contain the access_type as key, and array of people as value
grouped_people_by_access_type = {}
Method matching_data_files
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def matching_data_files params_only=false
results = {}
if Seek::Config.solr_enabled && is_jws_supported?
Method model_scales_list
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def model_scales_list model, list_item
scales = model.scales
if scales.empty?
text_or_not_specified("")
else
Method create_from_existing
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create_from_existing
studied_factor_ids = []
new_studied_factors = []
#retrieve the selected FSes
Method index
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def index
if (params[:discipline_id])
@discipline=Discipline.find(params[:discipline_id])
#FIXME: strips out the disciplines that don't match
@people=Person.where(["disciplines.id=?",@discipline.id]).includes(:disciplines)
Method builder
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def builder
saved_file=params[:saved_file]
error=nil
supported=false
begin
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create
content = params[:annotation_content].strip
if !content.blank?
worksheet = @content_blob.worksheets.select {|w| w.sheet_number == params[:annotation_sheet_id].to_i}.first
Method handle_download_zip
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def handle_download_zip asset
#get the list of filename and filepath, {:filename => filepath}
files_to_download = {}
#store content_type for the case of 1 file
content_type = nil
Method create_from_existing
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create_from_existing
experimental_condition_ids = []
new_experimental_conditions = []
#retrieve the selected FSes
params.each do |key, value|
Method add_breadcrumbs
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def add_breadcrumbs
#Home
add_breadcrumb "Home", :root_path
#process for nested attributes
if controller_name == 'studied_factors'
Function select_cells
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function select_cells(startCol, startRow, endCol, endRow, sheetNumber) {
var minRow = startRow;
var minCol = startCol;
var maxRow = endRow;
var maxCol = endCol;
Method authorized_list
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def authorized_list all_items, attribute, sort=true, max_length=75, count_hidden_items=false
items = all_items.select &:can_view?
if Seek::Config.is_virtualliver
title_only_items = (all_items - items).select &:title_is_public?
else
Method preview_permissions
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def preview_permissions
policy = sharing_params_to_policy
current_person = User.current_user.try(:person)
contributor_person = (params['is_new_file'] == 'false') ? User.find_by_id(params['contributor_id'].to_i).try(:person) : current_person
creators = (params["creators"].blank? ? [] : ActiveSupport::JSON.decode(params["creators"])).uniq
Method existing_specimens
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def existing_specimens
specimens_of_strains = []
strains = []
specimens_with_default_strain =[]
if params[:strain_ids]
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create
if handle_upload_data
@model = Model.new(params[:model])
@model.policy.set_attributes_with_sharing params[:sharing], @model.projects
Method resource_in_tab
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def resource_in_tab
resource_type = params[:resource_type]
view_type = params[:view_type]
scale_title = params[:scale_title] || ''