discourse/discourse

View on GitHub

Showing 2,996 of 3,817 total issues

Function submit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    submit() {
      if (!this.formSubmitted) {
        this.set("formSubmitted", true);

        Permalink.create({
Severity: Minor
Found in app/assets/javascripts/admin/components/permalink-form.js - About 1 hr to fix

    Function _hydrate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _hydrate(type, obj, root) {
        if (!obj) {
          throw new Error("Can't hydrate " + type + " of `null`");
        }
    
    
    Severity: Minor
    Found in app/assets/javascripts/discourse/app/models/store.js - About 1 hr to fix

      Function prependMore has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        prependMore() {
          // Make sure we can append more posts
          if (!this.canPrependMore) {
            return Promise.resolve();
          }
      Severity: Minor
      Found in app/assets/javascripts/discourse/app/models/post-stream.js - About 1 hr to fix

        Function loadDraft has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function loadDraft(store, opts) {
          let promise = Promise.resolve();
        
          opts = opts || {};
        
        
        Severity: Minor
        Found in app/assets/javascripts/discourse/app/controllers/composer.js - About 1 hr to fix

          Function content has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            content: computed("member.owner", function() {
              const items = [
                {
                  id: "removeMember",
                  name: I18n.t("groups.members.remove_member"),

            Function _getMultilineContents has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _getMultilineContents(lines, head, hval, hlen, tail, tlen, opts) {
                let operation = OP.NONE;
            
                const applyEmptyLines = opts && opts.applyEmptyLines;
            
            
            Severity: Minor
            Found in app/assets/javascripts/discourse/app/components/d-editor.js - About 1 hr to fix

              Function setSearchedTermValueForCategory has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                setSearchedTermValueForCategory() {
                  const match = this.filterBlocks(REGEXP_CATEGORY_PREFIX);
                  if (match.length !== 0) {
                    const existingInput = this.get("searchedTerms.category");
                    const subcategories = match[0]

                Function calcHeight has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function calcHeight() {
                  // estimate 270 px for keyboard
                  let withoutKeyboard = window.innerHeight - 270;
                  const min = 270;
                
                
                Severity: Minor
                Found in app/assets/javascripts/discourse/app/lib/safari-hacks.js - About 1 hr to fix

                  Method bot_commands has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def bot_commands(hint = true)
                        raw =
                          if match_data = match_trigger?("#{self.class.dice_trigger} (\\d+)d(\\d+)")
                            DiscourseNarrativeBot::Dice.roll(match_data[1].to_i, match_data[2].to_i)
                          elsif match_trigger?(self.class.quote_trigger)

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

                        def execute(args)
                          if SiteSetting.must_approve_users && SiteSetting.pending_users_reminder_delay >= 0
                            query = AdminUserIndexQuery.new(query: 'pending', stats: false).find_users_query # default order is: users.created_at DESC
                            if SiteSetting.pending_users_reminder_delay > 0
                              query = query.where('users.created_at < ?', SiteSetting.pending_users_reminder_delay.hours.ago)
                    Severity: Minor
                    Found in app/jobs/scheduled/pending_users_reminder.rb - About 1 hr to fix

                      Method get_base_user_array has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def get_base_user_array(user)
                            [
                              user.id,
                              escape_comma(user.name),
                              user.username,
                      Severity: Minor
                      Found in app/jobs/regular/export_csv_file.rb - About 1 hr to fix

                        Method update_theme_color_schemes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def update_theme_color_schemes(theme, schemes)
                            missing_scheme_names = Hash[*theme.color_schemes.pluck(:name, :id).flatten]
                            ordered_schemes = []
                        
                            schemes&.each do |name, colors|
                        Severity: Minor
                        Found in app/models/remote_theme.rb - About 1 hr to fix

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

                            def self.add(opts)
                              user_id, host, referer = nil
                              current_user = opts[:current_user]
                          
                              username = opts[:username]
                          Severity: Minor
                          Found in app/models/incoming_link.rb - About 1 hr to fix

                            Method categories has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def categories
                                @categories ||= begin
                                  categories = Category
                                    .includes(:uploaded_logo, :uploaded_background, :tags, :tag_groups)
                                    .secured(@guardian)
                            Severity: Minor
                            Found in app/models/site.rb - About 1 hr to fix

                              Method update_stats has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def self.update_stats
                                  topics_with_post_count = Topic
                                    .select("topics.category_id, COUNT(*) topic_count, SUM(topics.posts_count) post_count")
                                    .where("topics.id NOT IN (select cc.topic_id from categories cc WHERE topic_id IS NOT NULL)")
                                    .group("topics.category_id")
                              Severity: Minor
                              Found in app/models/category.rb - About 1 hr to fix

                                Method invite_group has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def invite_group(user, group)
                                    TopicAllowedGroup.create!(topic_id: id, group_id: group.id)
                                
                                    last_post = posts.order('post_number desc').where('not hidden AND posts.deleted_at IS NULL').first
                                    if last_post
                                Severity: Minor
                                Found in app/models/topic.rb - About 1 hr to fix

                                  Method remove_member has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    def remove_member
                                      group = Group.find_by(id: params[:id])
                                      raise Discourse::NotFound unless group
                                      group.public_exit ? ensure_logged_in : guardian.ensure_can_edit!(group)
                                  
                                  
                                  Severity: Minor
                                  Found in app/controllers/groups_controller.rb - About 1 hr to fix

                                    Method matched_uploads has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      def self.matched_uploads(node)
                                        upload_path = Discourse.store.upload_path
                                        base_url = Discourse.base_url.sub(/https?:\/\//, "(https?://)")
                                    
                                        regexps = [
                                    Severity: Minor
                                    Found in app/services/inline_uploads.rb - About 1 hr to fix

                                      Method import_topics has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          def import_topics
                                            return if @topics.blank?
                                      
                                            puts "Importing topics...", ''
                                      
                                      
                                      Severity: Minor
                                      Found in lib/import_export/importer.rb - About 1 hr to fix

                                        Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                          def run
                                            Rails.logger.debug("Updating upload security in topic #{@topic.id}")
                                            posts_owning_uploads.each do |post|
                                              Post.transaction do
                                                Rails.logger.debug("Updating upload security in topic #{@topic.id} - post #{post.id}")
                                        Severity: Minor
                                        Found in lib/topic_upload_security_manager.rb - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language