Method global_activity
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
def global_activity
members = current_organization.members
@active_members = members.active
@total_hours = num_movements = 0
Method global_activity
has 38 lines of code (exceeds 25 allowed). Consider refactoring.
def global_activity
members = current_organization.members
@active_members = members.active
@total_hours = num_movements = 0
Method create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
def create
authorize User
email = user_params[:email]
@user = User.find_or_initialize_by(email: email) do |u|
Identical blocks of code found in 2 locations. Consider refactoring.
def call(organization_id, csv_data)
data = csv_data.read
errors = []
CSV.parse(data, headers: false) do |data_row|
Identical blocks of code found in 2 locations. Consider refactoring.
def call(organization_id, csv_data)
data = csv_data.read
errors = []
CSV.parse(data, headers: false) do |data_row|
Method find_account
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def find_account(id, type, organization_id, errors, direction)
Method update
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def update
@user = User.find(params[:id])
authorize @user unless @user == current_user
if @user.update(user_params)
Method ensure_url
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def ensure_url
return if web.blank? || URI.parse(web).is_a?(URI::HTTP)
rescue
errors.add(:web, :url_format_invalid)
else
Similar blocks of code found in 3 locations. Consider refactoring.
collection_action :import_csv, method: :post do
errors = TransferImporter.call(params[:dump][:organization_id], params[:dump][:file])
flash[:error] = errors.join("<br/>").html_safe if errors.present?
redirect_to action: :index
Similar blocks of code found in 3 locations. Consider refactoring.
collection_action :import_csv, method: :post do
errors = UserImporter.call(params[:dump][:organization_id], params[:dump][:file])
flash[:error] = errors.join("<br/>").html_safe if errors.present?
redirect_to action: :index
Similar blocks of code found in 3 locations. Consider refactoring.
collection_action :import_csv, method: :post do
errors = PostImporter.call(params[:dump][:organization_id], params[:dump][:file])
flash[:error] = errors.join("<br/>").html_safe if errors.present?
redirect_to action: :index
Method find_account
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def find_account(id, type, organization_id, errors, direction)
acc = if type.downcase == 'organization'
Organization.find(organization_id).account
else
Member.find_by(member_uid: id, organization_id: organization_id)&.account