discourse/discourse

View on GitHub

Showing 1,565 of 1,870 total issues

Class Search has 41 methods (exceeds 20 allowed). Consider refactoring.
Open

class Search
  DIACRITICS ||= /([\u0300-\u036f]|[\u1AB0-\u1AFF]|[\u1DC0-\u1DFF]|[\u20D0-\u20FF])/

  cattr_accessor :preloaded_topic_custom_fields
  self.preloaded_topic_custom_fields = Set.new
Severity: Minor
Found in lib/search.rb - About 5 hrs to fix

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

        def self.update(post, polls)
          ::Poll.transaction do
            has_changed = false
            edit_window = SiteSetting.poll_edit_window_mins
    
    
    Severity: Minor
    Found in plugins/poll/lib/polls_updater.rb - About 5 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method ensure_entry_for has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.ensure_entry_for(post, link, parsed)
        url = link.url
        internal = false
        topic_id = nil
        post_number = nil
    Severity: Minor
    Found in app/models/topic_link.rb - About 5 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method find_missing_uploads has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.find_missing_uploads(include_local_upload: true)
        missing_uploads = []
        missing_post_uploads = {}
        count = 0
    
    
    Severity: Minor
    Found in app/models/post.rb - About 5 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method set_or_create_timer has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_or_create_timer(status_type, time, by_user: nil, based_on_last_post: false, category_id: SiteSetting.uncategorized_category_id)
        return delete_topic_timer(status_type, by_user: by_user) if time.blank?
    
        public_topic_timer = !!TopicTimer.public_types[status_type]
        topic_timer_options = { topic: self, public_type: public_topic_timer }
    Severity: Minor
    Found in app/models/topic.rb - About 5 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    File post_serializer.rb has 392 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class PostSerializer < BasicPostSerializer
    
      # To pass in additional information we might need
      INSTANCE_VARS ||= [
        :topic_view,
    Severity: Minor
    Found in app/serializers/post_serializer.rb - About 5 hrs to fix

      Method send has 135 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def send
            bypass_disable = BYPASS_DISABLE_TYPES.include?(@email_type.to_s)
      
            if SiteSetting.disable_emails == "yes" && !bypass_disable
              return
      Severity: Major
      Found in lib/email/sender.rb - About 5 hrs to fix

        Class Reviewable has 40 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Reviewable < ActiveRecord::Base
          class UpdateConflict < StandardError; end
        
          class InvalidAction < StandardError
            def initialize(action_id, klass)
        Severity: Minor
        Found in app/models/reviewable.rb - About 5 hrs to fix

          File user_serializer.rb has 387 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class UserSerializer < BasicUserSerializer
          
            attr_accessor :omit_stats,
                          :topic_post_count
          
          
          Severity: Minor
          Found in app/serializers/user_serializer.rb - About 5 hrs to fix

            Method show_in_site has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
            Open

              def show_in_site(hostname)
            
                username = params[:username].to_s
                return render_blank unless user = User.find_by(username_lower: username.downcase)
            
            
            Severity: Minor
            Found in app/controllers/user_avatars_controller.rb - About 5 hrs to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method tag_topic_by_names has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.tag_topic_by_names(topic, guardian, tag_names_arg, append: false)
                if guardian.can_tag?(topic)
                  tag_names = DiscourseTagging.tags_for_saving(tag_names_arg, guardian) || []
            
                  old_tag_names = topic.tags.pluck(:name) || []
            Severity: Minor
            Found in lib/discourse_tagging.rb - About 5 hrs to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method build_short_edit_script has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
            Open

              def build_short_edit_script(shortest_path)
                ses = []
                x, y = 1, 1
                px, py = 0, 0
                i = shortest_path.size - 1
            Severity: Minor
            Found in lib/onpdiff.rb - About 5 hrs to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            File topic_user.rb has 383 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require_dependency 'notification_levels'
            
            class TopicUser < ActiveRecord::Base
              belongs_to :user
              belongs_to :topic
            Severity: Minor
            Found in app/models/topic_user.rb - About 5 hrs to fix

              Class UsersController has 39 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Admin::UsersController < Admin::AdminController
              
                before_action :fetch_user, only: [:suspend,
                                                  :unsuspend,
                                                  :log_out,
              Severity: Minor
              Found in app/controllers/admin/users_controller.rb - About 5 hrs to fix

                File guardian.rb has 381 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require_dependency 'guardian/category_guardian'
                require_dependency 'guardian/ensure_magic'
                require_dependency 'guardian/post_guardian'
                require_dependency 'guardian/topic_guardian'
                require_dependency 'guardian/user_guardian'
                Severity: Minor
                Found in lib/guardian.rb - About 5 hrs to fix

                  File pretty_text.rb has 380 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'mini_racer'
                  require 'nokogiri'
                  require 'erb'
                  require_dependency 'url_helper'
                  require_dependency 'excerpt_parser'
                  Severity: Minor
                  Found in lib/pretty_text.rb - About 5 hrs to fix

                    Method posts_query has 127 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def posts_query(limit, opts = nil)
                        opts ||= {}
                    
                        posts = Post.where(post_type: Topic.visible_post_types(@guardian.user))
                          .joins(:post_search_data, :topic)
                    Severity: Major
                    Found in lib/search.rb - About 5 hrs to fix

                      Class AdminDashboardData has 38 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class AdminDashboardData
                        include StatsCacheable
                      
                        # kept for backward compatibility
                        GLOBAL_REPORTS ||= []
                      Severity: Minor
                      Found in app/models/admin_dashboard_data.rb - About 5 hrs to fix

                        Method change_external_attributes_and_override has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def change_external_attributes_and_override(sso_record, user)
                            if SiteSetting.sso_overrides_email && user.email != Email.downcase(email)
                              user.email = email
                              user.active = false if require_activation
                            end
                        Severity: Minor
                        Found in app/models/discourse_single_sign_on.rb - About 4 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Method index has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def self.index(obj, force: false)
                            return if @disabled
                        
                            category_name = nil
                            tag_names = nil
                        Severity: Minor
                        Found in app/services/search_indexer.rb - About 4 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Severity
                        Category
                        Status
                        Source
                        Language