coopdevs/timeoverflow

View on GitHub

Showing 12 of 14 total issues

Method global_activity has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def global_activity
members = current_organization.members
@active_members = members.active
 
@total_hours = num_movements = 0
Severity: Minor
Found in app/controllers/statistics_controller.rb - About 2 hrs to fix

Method global_activity has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def global_activity
members = current_organization.members
@active_members = members.active
 
@total_hours = num_movements = 0
Severity: Minor
Found in app/controllers/statistics_controller.rb - About 1 hr to fix

    Method create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def create
    authorize User
     
    email = user_params[:email]
    @user = User.find_or_initialize_by(email: email) do |u|
    Severity: Minor
    Found in app/controllers/users_controller.rb - About 1 hr to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    def call(organization_id, csv_data)
    data = csv_data.read
    errors = []
     
    CSV.parse(data, headers: false) do |data_row|
    Severity: Major
    Found in app/services/post_importer.rb and 1 other location - About 1 hr to fix
    app/services/transfer_importer.rb on lines 50..68

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    def call(organization_id, csv_data)
    data = csv_data.read
    errors = []
     
    CSV.parse(data, headers: false) do |data_row|
    Severity: Major
    Found in app/services/transfer_importer.rb and 1 other location - About 1 hr to fix
    app/services/post_importer.rb on lines 31..49

    Method find_account has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def find_account(id, type, organization_id, errors, direction)
    Severity: Minor
    Found in app/services/transfer_importer.rb - About 35 mins to fix

      Method update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def update
      @user = User.find(params[:id])
      authorize @user unless @user == current_user
       
      if @user.update(user_params)
      Severity: Minor
      Found in app/controllers/users_controller.rb - About 35 mins to fix

      Method ensure_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def ensure_url
      return if web.blank? || URI.parse(web).is_a?(URI::HTTP)
      rescue
      errors.add(:web, :url_format_invalid)
      else
      Severity: Minor
      Found in app/models/organization.rb - About 35 mins to fix

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      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
      Severity: Minor
      Found in app/admin/transfer.rb and 2 other locations - About 35 mins to fix
      app/admin/post.rb on lines 10..15
      app/admin/user.rb on lines 12..17

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      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
      Severity: Minor
      Found in app/admin/user.rb and 2 other locations - About 35 mins to fix
      app/admin/post.rb on lines 10..15
      app/admin/transfer.rb on lines 14..19

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      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
      Severity: Minor
      Found in app/admin/post.rb and 2 other locations - About 35 mins to fix
      app/admin/transfer.rb on lines 14..19
      app/admin/user.rb on lines 12..17

      Method find_account has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      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
      Severity: Minor
      Found in app/services/transfer_importer.rb - About 25 mins to fix
      Severity
      Category
      Status
      Source
      Language