discourse/discourse

View on GitHub

Showing 2,973 of 3,784 total issues

Function afterRefresh has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    afterRefresh($preview) {
      const topic = this.get("model.topic");
      const linkLookup = this.linkLookup;

      if (!topic || !linkLookup) {
Severity: Minor
Found in app/assets/javascripts/discourse/app/controllers/composer.js - About 1 hr to fix

    Function move has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      move(category, direction) {
        let otherCategory;
    
        if (direction === -1) {
          // First category above current one

      Function init has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        init() {
          this._super(...arguments);
      
          const connector = this.connector;
          this.set("layoutName", connector.templateName);
      Severity: Minor
      Found in app/assets/javascripts/discourse/app/components/plugin-connector.js - About 1 hr to fix

        Function deleteUnused has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            deleteUnused() {
              ajax("/tags/unused", { type: "GET" })
                .then(result => {
                  const displayN = 20;
                  const tags = result["tags"];
        Severity: Minor
        Found in app/assets/javascripts/discourse/app/controllers/tags-index.js - About 1 hr to fix

          Function link has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static link() {
              return class extends Tag {
                constructor() {
                  super("a", "", "", true);
                }
          Severity: Minor
          Found in app/assets/javascripts/discourse/app/lib/to-markdown.js - About 1 hr to fix

            Function default has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function(page) {
              return DiscourseRoute.extend({
                renderTemplate() {
                  this.render("static");
                },
            Severity: Minor
            Found in app/assets/javascripts/discourse/app/lib/static-route-builder.js - About 1 hr to fix

              Method execute has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def execute(args)
                    return unless SiteSetting.migrate_to_new_scheme
              
                    # clean up failed uploads
                    Upload.where("created_at < ?", 1.hour.ago)
              Severity: Minor
              Found in app/jobs/scheduled/migrate_upload_scheme.rb - About 1 hr to fix

                Method valid_numbers? has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def valid_numbers?(poll)
                      return true if poll["type"] != "number"
                
                      valid = true
                
                
                Severity: Minor
                Found in plugins/poll/lib/polls_validator.rb - About 1 hr to fix

                  Method send_invite has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def send_invite(invite)
                        email = invite[:email]
                        groups = get_groups(invite[:groups])
                        topic = get_topic(invite[:topic_id])
                  
                  
                  Severity: Minor
                  Found in app/jobs/regular/bulk_invite.rb - About 1 hr to fix

                    Method publish_unread has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.publish_unread(post)
                        return unless post.topic.regular?
                        # TODO at high scale we are going to have to defer this,
                        #   perhaps cut down to users that are around in the last 7 days as well
                    
                    
                    Severity: Minor
                    Found in app/models/topic_tracking_state.rb - About 1 hr to fix

                      Method execute has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def execute(args)
                          raise Discourse::InvalidParameters.new(:user_ids) unless args[:user_ids].present?
                      
                          args[:user_ids].each do |u|
                            user_stat = UserStat.find_by(user_id: u)
                      Severity: Minor
                      Found in app/jobs/regular/truncate_user_flag_stats.rb - About 1 hr to fix

                        Method update_featured_ranks! has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.update_featured_ranks!(user_id = nil)
                            query = <<~SQL
                              WITH featured_tl_badge AS -- Find the best trust level badge for each user
                              (
                                SELECT user_id, max(badge_id) as badge_id
                        Severity: Minor
                        Found in app/models/user_badge.rb - About 1 hr to fix

                          Method penalty_counts has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def penalty_counts
                              args = {
                                user_id: @user.id,
                                system_user_id: Discourse.system_user.id,
                                silence_user: UserHistory.actions[:silence_user],
                          Severity: Minor
                          Found in app/models/trust_level3_requirements.rb - About 1 hr to fix

                            Method hide! has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def hide!(post_action_type_id, reason = nil)
                                return if hidden?
                            
                                reason ||= hidden_at ?
                                  Post.hidden_reasons[:flag_threshold_reached_again] :
                            Severity: Minor
                            Found in app/models/post.rb - About 1 hr to fix

                              Method perform_approve_post has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def perform_approve_post(performed_by, args)
                                  created_post = nil
                              
                                  creator = PostCreator.new(created_by, create_options.merge(
                                    skip_validations: true,
                              Severity: Minor
                              Found in app/models/reviewable_queued_post.rb - About 1 hr to fix

                                Method create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def create
                                    # capture current user for block later on
                                    me = current_user
                                
                                    # 50 characters ought to be enough for the upload type
                                Severity: Minor
                                Found in app/controllers/uploads_controller.rb - About 1 hr to fix

                                  Method similar_to has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    def self.similar_to(title, raw, user = nil)
                                      return [] if title.blank?
                                      raw = raw.presence || ""
                                  
                                      search_data = "#{title} #{raw[0...MAX_SIMILAR_BODY_LENGTH]}".strip
                                  Severity: Minor
                                  Found in app/models/topic.rb - About 1 hr to fix

                                    Method set_category has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      def set_category
                                        parts = params.require(:category_slug_path_with_id).split('/')
                                    
                                        if !parts.empty? && parts.last =~ /\A\d+\Z/
                                          id = parts.pop.to_i
                                    Severity: Minor
                                    Found in app/controllers/list_controller.rb - About 1 hr to fix

                                      Method show has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        def show(for_card: false)
                                          return redirect_to path('/login') if SiteSetting.hide_user_profiles_from_public && !current_user
                                      
                                          @user = fetch_user_from_params(
                                            include_inactive: current_user.try(:staff?) || (current_user && SiteSetting.show_inactive_accounts)
                                      Severity: Minor
                                      Found in app/controllers/users_controller.rb - About 1 hr to fix

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

                                          def index
                                            params.require(:username)
                                            params.permit(:filter, :offset, :acting_username, :limit)
                                        
                                            user = fetch_user_from_params(include_inactive: current_user.try(:staff?) || (current_user && SiteSetting.show_inactive_accounts))
                                        Severity: Minor
                                        Found in app/controllers/user_actions_controller.rb - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language