app/services/group_export_service.rb
Method import
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.import(filename_or_url, reset_keys: false)
group_ids = []
migrate_ids = {}
if URI.parse(filename_or_url).class == URI::Generic
- 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 import
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.import(filename_or_url, reset_keys: false)
group_ids = []
migrate_ids = {}
if URI.parse(filename_or_url).class == URI::Generic
File group_export_service.rb
has 292 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
class GroupExportService
RELATIONS = %w[
all_users
all_events
all_notifications
Method export_direct_threads
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.export_direct_threads(group_id)
group = Group.find(group_id)
group_ids = Group.find(group_id).id_and_subgroup_ids
author_ids = Membership.where(group_id: group_ids).pluck(:user_id).uniq
discussion_ids = Discussion.where(group_id: nil, author_id: author_ids).pluck(:id)
Method export
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.export(groups, group_name)
filename = export_filename_for(group_name)
ids = Hash.new { |hash, key| hash[key] = [] }
File.open(filename, 'w') do |file|
groups.each do |group|