From d95fa7537c2bdaf7e6d100db58474adf7f514876 Mon Sep 17 00:00:00 2001 From: RafsanNeloy Date: Sat, 28 Mar 2026 15:48:49 +0600 Subject: [PATCH] removed unused variables, dead code and fixing typos Signed-off-by: RafsanNeloy --- BrainPortal/app/controllers/application_controller.rb | 2 -- BrainPortal/app/controllers/bourreaux_controller.rb | 3 --- BrainPortal/app/controllers/noc_controller.rb | 1 - BrainPortal/app/controllers/tools_controller.rb | 4 ++-- BrainPortal/app/controllers/userfiles_controller.rb | 2 +- BrainPortal/app/models/custom_filter.rb | 2 +- BrainPortal/app/models/group.rb | 2 +- BrainPortal/app/models/local_data_provider.rb | 2 +- BrainPortal/app/models/message.rb | 4 ++-- BrainPortal/app/models/portal_task.rb | 2 +- .../userfiles/file_collection/file_collection.rb | 2 +- .../cbrain-plugins-base/userfiles/single_file/single_file.rb | 2 +- 12 files changed, 11 insertions(+), 17 deletions(-) mode change 100644 => 100755 BrainPortal/app/controllers/application_controller.rb mode change 100644 => 100755 BrainPortal/app/controllers/bourreaux_controller.rb mode change 100644 => 100755 BrainPortal/app/controllers/noc_controller.rb mode change 100644 => 100755 BrainPortal/app/controllers/tools_controller.rb mode change 100644 => 100755 BrainPortal/app/controllers/userfiles_controller.rb mode change 100644 => 100755 BrainPortal/app/models/custom_filter.rb mode change 100644 => 100755 BrainPortal/app/models/group.rb mode change 100644 => 100755 BrainPortal/app/models/local_data_provider.rb mode change 100644 => 100755 BrainPortal/app/models/message.rb mode change 100644 => 100755 BrainPortal/app/models/portal_task.rb mode change 100644 => 100755 BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/file_collection/file_collection.rb mode change 100644 => 100755 BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/single_file/single_file.rb diff --git a/BrainPortal/app/controllers/application_controller.rb b/BrainPortal/app/controllers/application_controller.rb old mode 100644 new mode 100755 index e7e4cdd92..ae9ad3a04 --- a/BrainPortal/app/controllers/application_controller.rb +++ b/BrainPortal/app/controllers/application_controller.rb @@ -186,8 +186,6 @@ def check_password_reset #:nodoc: # # "User: tsmith from example.com (256.0.0.9) using FireChrome 99.9" def log_user_info #:nodoc: - reqenv = request.env || {} - # Short username for the message login = current_user ? current_user.login : "(none)" diff --git a/BrainPortal/app/controllers/bourreaux_controller.rb b/BrainPortal/app/controllers/bourreaux_controller.rb old mode 100644 new mode 100755 index c44ef70db..7cfa06f52 --- a/BrainPortal/app/controllers/bourreaux_controller.rb +++ b/BrainPortal/app/controllers/bourreaux_controller.rb @@ -476,9 +476,6 @@ def rr_disk_usage date_filtering["relative_from"] ||= 50.years.to_i.to_s date_filtering["relative_to"] ||= 1.week.to_i.to_s - accessed_after = date_filtering["relative_from"].to_i.seconds.ago - accessed_before = date_filtering["relative_to"].to_i.seconds.ago - # Used only relative value for determine_date_range_start_end --> harcode the 4 first values. (accessed_after,accessed_before) = determine_date_range_start_end(false , false, Time.now, Time.now , date_filtering["relative_from"], date_filtering["relative_to"]) diff --git a/BrainPortal/app/controllers/noc_controller.rb b/BrainPortal/app/controllers/noc_controller.rb old mode 100644 new mode 100755 index 51759ef2d..f8f140a2e --- a/BrainPortal/app/controllers/noc_controller.rb +++ b/BrainPortal/app/controllers/noc_controller.rb @@ -328,7 +328,6 @@ def gather_info(since_when) #:nodoc: # Show IP address def fetch_ip_address - reqenv = request.env || {} @ip_address ||= cbrain_request_remote_ip rescue 'UnknownIP' end diff --git a/BrainPortal/app/controllers/tools_controller.rb b/BrainPortal/app/controllers/tools_controller.rb old mode 100644 new mode 100755 index 4ac37fec3..87710d596 --- a/BrainPortal/app/controllers/tools_controller.rb +++ b/BrainPortal/app/controllers/tools_controller.rb @@ -61,7 +61,7 @@ def tool_config_select #:nodoc: @bourreaux = Bourreau.find_all_accessible_by_user(current_user).where( :id => bourreau_ids) # All accessible tc for this tool on accessible bourreaux bourreaux_ids = @bourreaux.map(&:id) - @tool_configs = ToolConfig.find_all_accessible_by_user(current_user).where(:tool_id => tool_id, :bourreau_id => bourreau_ids) + @tool_configs = ToolConfig.find_all_accessible_by_user(current_user).where(:tool_id => tool_id, :bourreau_id => bourreaux_ids) # Reduce list of bourreaux, bourreaux need at least one config available bourreaux_ids = @tool_configs.map(&:bourreau_id) @bourreaux = @bourreaux.where(:id => bourreaux_ids).all @@ -70,7 +70,7 @@ def tool_config_select #:nodoc: selected_by_default = current_user.meta["pref_bourreau_id"] @tool_config = @tool_configs.where(:bourreau_id => selected_by_default).last if ( bourreaux_ids.include?(selected_by_default) && - @bourreaux.detect? { |b| b.id == selected_by_default && b.online? } + @bourreaux.any? { |b| b.id == selected_by_default && b.online? } ) respond_to do |format| diff --git a/BrainPortal/app/controllers/userfiles_controller.rb b/BrainPortal/app/controllers/userfiles_controller.rb old mode 100644 new mode 100755 index 5120a9673..6e68e8c73 --- a/BrainPortal/app/controllers/userfiles_controller.rb +++ b/BrainPortal/app/controllers/userfiles_controller.rb @@ -1590,7 +1590,7 @@ def extract_from_archive(archive_file_name, file_type = nil, attributes = {}) #: u.name = file_name if u.save u.cache_copy_from_local_file("#{workdir}/#{file_name}") - u.size = File.size(file_name) + u.size = File.size("#{workdir}/#{file_name}") u.save else status = :failed diff --git a/BrainPortal/app/models/custom_filter.rb b/BrainPortal/app/models/custom_filter.rb old mode 100644 new mode 100755 index c35a20e07..900e48043 --- a/BrainPortal/app/models/custom_filter.rb +++ b/BrainPortal/app/models/custom_filter.rb @@ -186,7 +186,7 @@ def scope_date(scope) relative_to = self.data_relative_to table_name = self.target_filtered_table() - scope = add_time_condition_to_scope(scope, table_name, + add_time_condition_to_scope(scope, table_name, mode_is_absolute_from, mode_is_absolute_to, absolute_from, absolute_to, relative_from, relative_to, diff --git a/BrainPortal/app/models/group.rb b/BrainPortal/app/models/group.rb old mode 100644 new mode 100755 index 218e65567..f5a9a23ca --- a/BrainPortal/app/models/group.rb +++ b/BrainPortal/app/models/group.rb @@ -171,7 +171,7 @@ def reassign_models_to_owner_group #:nodoc: .select { |a| a.macro == :has_many } .map { |a| a.name } .reject { |a| a == :resource_usage } # we never modify the resource usage records - objlist = group_has_many_model_list.inject([]) { |list,modsym| list += self.send(modsym).to_a } + objlist = group_has_many_model_list.inject([]) { |list,modsym| list + self.send(modsym).to_a } user_id_to_own_group_id = {} # to cache lookups objlist.each do |obj| next if obj.is_a?(ResourceUsage) # again, just to be sure diff --git a/BrainPortal/app/models/local_data_provider.rb b/BrainPortal/app/models/local_data_provider.rb old mode 100644 new mode 100755 index 2691818ce..41aa588ce --- a/BrainPortal/app/models/local_data_provider.rb +++ b/BrainPortal/app/models/local_data_provider.rb @@ -119,7 +119,7 @@ def impl_provider_list_all(user = nil, browse_path = nil) #:nodoc: next unless stat # In case the file has been deleted # Adjust type - type = type = stat.ftype.to_sym + type = stat.ftype.to_sym type = :regular if type == :file next if type != :regular && type != :directory && type != :symlink diff --git a/BrainPortal/app/models/message.rb b/BrainPortal/app/models/message.rb old mode 100644 new mode 100755 index 6bf05c252..628f8d847 --- a/BrainPortal/app/models/message.rb +++ b/BrainPortal/app/models/message.rb @@ -261,7 +261,7 @@ def self.send_internal_error_message(destination, header, exception, request_par # will return # 'abcde name def' def render_attr(attr) - return sefl.attr unless %w[description variable_text header].include?(attr.to_s) + return self[attr] unless %w[description variable_text header].include?(attr.to_s) if self.message_type == 'communication' self[attr] || '' else @@ -330,7 +330,7 @@ def self.find_users_for_destination(destination, options={}) #:nodoc: # Get a unique list of all users from all these groups groups.compact! - allusers = groups.inject([]) { |flat,group| flat |= group.users } + allusers = groups.inject([]) { |flat,group| flat | group.users } allusers.reject! { |u| u.account_locked? } if ! options[:include_locked_users] # Select the list of users in list of groups; a special case is made diff --git a/BrainPortal/app/models/portal_task.rb b/BrainPortal/app/models/portal_task.rb old mode 100644 new mode 100755 index 102f17234..ec76e4193 --- a/BrainPortal/app/models/portal_task.rb +++ b/BrainPortal/app/models/portal_task.rb @@ -619,7 +619,7 @@ def clear #:nodoc: end def count #:nodoc: - inject(0) { |c| c += 1 } + inject(0) { |c, _| c + 1 } end def delete(paramspath) #:nodoc: diff --git a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/file_collection/file_collection.rb b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/file_collection/file_collection.rb old mode 100644 new mode 100755 index dd6ed2e4c..45f22066f --- a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/file_collection/file_collection.rb +++ b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/file_collection/file_collection.rb @@ -97,7 +97,7 @@ def set_size! def merge_collections(userfiles) # Check for collision - full_names = userfiles.inject([]){|list, file| list += file.list_files.map(&:name)} + full_names = userfiles.inject([]){|list, file| list + file.list_files.map(&:name)} unless full_names.uniq.size == full_names.size return :collision diff --git a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/single_file/single_file.rb b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/single_file/single_file.rb old mode 100644 new mode 100755 index 7615e1854..4103c542d --- a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/single_file/single_file.rb +++ b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/single_file/single_file.rb @@ -41,7 +41,7 @@ def pretty_type #:nodoc: # Forces calculation and setting of the size attribute. def set_size! - self.size = self.list_files.inject(0){ |total, file_entry| total += file_entry.size } + self.size = self.list_files.inject(0){ |total, file_entry| total + file_entry.size } self.save! true