discourse/discourse

View on GitHub

Showing 2,973 of 3,784 total issues

Method add has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.add(topic_id, ip, user_id = nil, at = nil, skip_redis = false)
    # Only store a view once per day per thing per (user || ip)
    at ||= Date.today
    redis_key = +"view:#{topic_id}:#{at}"
    if user_id
Severity: Minor
Found in app/models/topic_view_item.rb - About 1 hr to fix

    Method add has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.add(user_profile_id, ip, user_id = nil, at = nil, skip_redis = false)
        at ||= Time.zone.now
        redis_key = +"user-profile-view:#{user_profile_id}:#{at.to_date}"
        if user_id
          return if user_id < 1
    Severity: Minor
    Found in app/models/user_profile_view.rb - About 1 hr to fix

      Method process_translation has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def process_translation
          errors = []
          javascript_cache || build_javascript_cache
          js_compiler = ThemeJavascriptCompiler.new(theme_id, self.theme.name)
          begin
      Severity: Minor
      Found in app/models/theme_field.rb - About 1 hr to fix

        Method json_for has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.json_for(guardian)
        
            if guardian.anonymous? && SiteSetting.login_required
              return {
                periods: TopTopic.periods.map(&:to_s),
        Severity: Minor
        Found in app/models/site.rb - About 1 hr to fix

          Method category_moderators has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def category_moderators
              allowed_cats = Guardian.new(@user).allowed_category_ids
              return [] if allowed_cats.blank?
              cats_with_mods = Category.where.not(reviewable_by_group_id: nil).pluck(:id)
              category_ids = cats_with_mods & allowed_cats
          Severity: Minor
          Found in app/models/about.rb - About 1 hr to fix

            Method database_config has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.database_config
                hash = { "adapter" => "postgresql" }
            
                %w{
                  pool
            Severity: Minor
            Found in app/models/global_setting.rb - About 1 hr to fix

              Method changed_to_category has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def changed_to_category(new_category)
                  return true if new_category.blank? || Category.exists?(topic_id: id)
                  return false if new_category.id == SiteSetting.uncategorized_category_id && !SiteSetting.allow_uncategorized_topics
              
                  Topic.transaction do
              Severity: Minor
              Found in app/models/topic.rb - About 1 hr to fix

                Method email_login_info has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def email_login_info
                    token = params[:token]
                    matched_token = EmailToken.confirmable(token)
                    user = matched_token&.user
                
                
                Severity: Minor
                Found in app/controllers/session_controller.rb - About 1 hr to fix

                  Method log_action! has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.log_action!(hash)
                      required_parameters = [:action_type, :user_id, :acting_user_id]
                  
                      required_parameters << :target_post_id
                      required_parameters << :target_topic_id
                  Severity: Minor
                  Found in app/models/user_action.rb - About 1 hr to fix

                    Method thumbnail_info has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def thumbnail_info(enqueue_if_missing: false, extra_sizes: [])
                        return nil unless original = image_upload
                        return nil unless original.read_attribute(:width) && original.read_attribute(:height)
                    
                        infos = []
                    Severity: Minor
                    Found in app/models/topic.rb - About 1 hr to fix

                      Method client_side_setup_data has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def client_side_setup_data
                          service_worker_url = Rails.env.development? ? 'service-worker.js' : Rails.application.assets_manifest.assets['service-worker.js']
                      
                          setup_data = {
                            cdn: Rails.configuration.action_controller.asset_host,
                      Severity: Minor
                      Found in app/helpers/application_helper.rb - About 1 hr to fix

                        Method index has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def index
                            overridden = params[:overridden] == 'true'
                            extras = {}
                        
                            query = params[:q] || ""
                        Severity: Minor
                        Found in app/controllers/admin/site_texts_controller.rb - About 1 hr to fix

                          Method penalty_history has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def penalty_history
                          
                              # We don't delete any history, we merely remove the action type
                              # with a removed type. It can still be viewed in the logs but
                              # will not affect TL3 promotions.
                          Severity: Minor
                          Found in app/controllers/admin/users_controller.rb - About 1 hr to fix

                            Method send_notification has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def self.send_notification(user, subscription, message)
                                begin
                                  Webpush.payload_send(
                                    endpoint: subscription["endpoint"],
                                    message: message.to_json,
                            Severity: Minor
                            Found in app/services/push_notification_pusher.rb - About 1 hr to fix

                              Method actions_summary has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def actions_summary
                                  result = []
                                  can_see_post = scope.can_see_post?(object)
                              
                                  PostActionType.types.except(:bookmark).each do |sym, id|
                              Severity: Minor
                              Found in app/serializers/post_serializer.rb - About 1 hr to fix

                                Method scrub has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    def self.scrub(html, strip_diacritics: false)
                                      return +"" if html.blank?
                                
                                      document = Nokogiri::HTML5("<div>#{html}</div>", nil, Encoding::UTF_8.to_s)
                                
                                
                                Severity: Minor
                                Found in app/services/search_indexer.rb - About 1 hr to fix

                                  Method perform has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    def perform
                                      result = DestroyResult.new
                                  
                                      if @post.blank?
                                        result.not_found = true
                                  Severity: Minor
                                  Found in lib/post_action_destroyer.rb - About 1 hr to fix

                                    Method load_setting has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      def load_setting(name_arg, opts = {})
                                        name = name_arg.to_sym
                                    
                                        if opts[:textarea]
                                          @textareas[name] = opts[:textarea]
                                    Severity: Minor
                                    Found in lib/site_settings/type_supervisor.rb - About 1 hr to fix

                                      Method list_missing_post_uploads has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        def list_missing_post_uploads
                                          log "Listing missing post uploads..."
                                      
                                          missing = Post.find_missing_uploads(include_local_upload: false) do |post, _, _, sha1|
                                            next if sha1.blank?
                                      Severity: Minor
                                      Found in lib/s3_inventory.rb - About 1 hr to fix

                                        Method create_message_creator has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                          def create_message_creator
                                            title = I18n.t(
                                              "post_action_types.#{@post_action_name}.email_title",
                                              title: @post.topic.title,
                                              locale: SiteSetting.default_locale
                                        Severity: Minor
                                        Found in lib/post_action_creator.rb - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language