diaspora/diaspora

View on GitHub

Showing 4,424 of 4,489 total issues

File user.rb has 451 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class User < ApplicationRecord
  include AuthenticationToken
  include Connecting
  include Querying
  include SocialActions
Severity: Minor
Found in app/models/user.rb - About 6 hrs to fix

    Assignment Branch Condition size for index is too high. [53.49/20]
    Open

      def index
        conditions = {:recipient_id => current_user.id}
        if params[:type] && types.has_key?(params[:type])
          conditions[:type] = types[params[:type]]
        end

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    File publisher_view.js has 381 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
    
    /*   Copyright (c) 2010-2012, Diaspora Inc.  This file is
     *   licensed under the Affero General Public License version 3 or later.  See
     *   the COPYRIGHT file.
    Severity: Minor
    Found in app/assets/javascripts/app/views/publisher_view.js - About 5 hrs to fix

      Assignment Branch Condition size for legacy_create is too high. [45.93/20]
      Open

        def legacy_create
          photo_params = params.require(:photo).permit(:pending, :set_profile_photo, aspect_ids: [])
          if photo_params[:aspect_ids] == "all"
            photo_params[:aspect_ids] = current_user.aspects.map(&:id)
          elsif photo_params[:aspect_ids].is_a?(Hash)

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Class AccountMigration has 32 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class AccountMigration < ApplicationRecord
        include Diaspora::Federated::Base
      
        belongs_to :old_person, class_name: "Person"
        belongs_to :new_person, class_name: "Person"
      Severity: Minor
      Found in app/models/account_migration.rb - About 4 hrs to fix

        Class Person has 32 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Person < ApplicationRecord
          include Diaspora::Fields::Guid
        
          # NOTE API V1 to be extracted
          acts_as_api
        Severity: Minor
        Found in app/models/person.rb - About 4 hrs to fix

          Assignment Branch Condition size for perform is too high. [40.22/20]
          Open

              def perform
                # Queue users for removal due to inactivity
                if AppConfig.settings.maintenance.remove_old_users.enable?
                  users = User.where("last_seen < ? and locked_at is null and remove_after is null", 
                    Time.now - (AppConfig.settings.maintenance.remove_old_users.after_days.to_i).days)

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Assignment Branch Condition size for new is too high. [39.67/20]
          Open

            def new
              if !params[:modal] && !session[:mobile_view] && request.format.html?
                redirect_to conversations_path
                return
              end

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Assignment Branch Condition size for destroy is too high. [37.7/20]
          Open

            def destroy
              aspect = current_user.aspects.joins(:aspect_memberships).where(aspect_memberships: {id: params[:id]}).first
              contact = current_user.contacts.joins(:aspect_memberships).where(aspect_memberships: {id: params[:id]}).first
          
              raise ActiveRecord::RecordNotFound unless aspect.present? && contact.present?

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Assignment Branch Condition size for mobile_reshare_icon is too high. [36.03/20]
          Open

            def mobile_reshare_icon(post)
              if (post.public? || reshare?(post)) && (user_signed_in? && post.author != current_user.person)
                absolute_root = reshare?(post) ? post.absolute_root : post
          
                if absolute_root && absolute_root.author != current_user.person
          Severity: Minor
          Found in app/helpers/mobile_helper.rb by rubocop

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Assignment Branch Condition size for create is too high. [36.62/20]
          Open

            def create
              emails = inviter_params[:emails].split(",").map(&:strip).uniq
          
              valid_emails, invalid_emails = emails.partition {|email| valid_email?(email) }
          
          

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Assignment Branch Condition size for index is too high. [35.19/20]
          Open

            def index
              if params[:q] && params[:q].length > 1
                params[:q].gsub!("#", "")
                params[:limit] = !params[:limit].blank? ? params[:limit].to_i : 10
                @tags = ActsAsTaggableOn::Tag.autocomplete(params[:q]).limit(params[:limit] - 1)
          Severity: Minor
          Found in app/controllers/tags_controller.rb by rubocop

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Assignment Branch Condition size for index is too high. [35.16/20]
          Open

            def index
              @post_type = :photos
              @person = Person.find_by_guid(params[:person_id])
              authenticate_user! if @person.try(:remote?) && !user_signed_in?
              @presenter = PersonPresenter.new(@person, current_user)

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          File receive.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Diaspora
            module Federation
              module Receive
                extend Diaspora::Logging
          
          
          Severity: Minor
          Found in lib/diaspora/federation/receive.rb - About 3 hrs to fix

            Class AuthorizationsController has 28 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class AuthorizationsController < ApplicationController
                  rescue_from Rack::OAuth2::Server::Authorize::BadRequest do |e|
                    logger.info e.backtrace[0, 10].join("\n")
                    error, _description = e.message.split(" :: ")
                    handle_params_error(error, "The request was malformed: please double check the client id and redirect uri.")
            Severity: Minor
            Found in app/controllers/api/openid_connect/authorizations_controller.rb - About 3 hrs to fix

              Class PostPresenter has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class PostPresenter < BasePresenter
                include PostsHelper
                include MetaDataHelper
              
                attr_accessor :post
              Severity: Minor
              Found in app/presenters/post_presenter.rb - About 3 hrs to fix

                Assignment Branch Condition size for read_all is too high. [34.19/20]
                Open

                  def read_all
                    current_type = types[params[:type]]
                    notifications = Notification.where(recipient_id: current_user.id, unread: true)
                    notifications = notifications.where(type: current_type) if params[:type]
                    notifications.update_all(unread: false)

                This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

                Assignment Branch Condition size for index is too high. [34.29/20]
                Open

                  def index
                    @visibilities = ConversationVisibility.includes(:conversation)
                                                          .order("conversations.updated_at DESC")
                                                          .where(person_id: current_user.person_id)
                                                          .paginate(page: params[:page], per_page: 15)

                This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

                Assignment Branch Condition size for perform is too high. [33.36/20]
                Open

                    def perform
                      return User.none unless valid?
                
                      users = User.arel_table
                      people = Person.arel_table

                This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

                Assignment Branch Condition size for create is too high. [33.38/20]
                Open

                  def create
                    # Contacts autocomplete does not work the same way on mobile and desktop
                    # Mobile returns contact ids array while desktop returns person id
                    # This will have to be removed when mobile autocomplete is ported to Typeahead
                    recipients_param, column = [%i(contact_ids id), %i(person_ids person_id)].find {|param, _| params[param].present? }

                This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

                Severity
                Category
                Status
                Source
                Language