discourse/discourse

View on GitHub

Showing 1,669 of 1,992 total issues

Method process_internal has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    def process_internal
      handle_bounce if is_bounce?
      raise NoSenderDetectedError if @from_email.blank?
      raise FromReplyByAddressError if is_from_reply_by_email_address?
      raise ScreenedEmailError if ScreenedEmail.should_block?(@from_email)
Severity: Minor
Found in lib/email/receiver.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 application_helper.rb has 406 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'current_user'
require 'canonical_url'

module ApplicationHelper
  include CurrentUser
Severity: Minor
Found in app/helpers/application_helper.rb - About 5 hrs to fix

    File 006_badges.rb has 404 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'badge_queries'
    
    BadgeGrouping.seed do |g|
      g.id = BadgeGrouping::GettingStarted
      g.name = "Getting Started"
    Severity: Minor
    Found in db/fixtures/006_badges.rb - About 5 hrs to fix

      Method save_custom_fields has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

        def save_custom_fields(force = false)
          if force || !custom_fields_clean?
            dup = @custom_fields.dup
            array_fields = {}
      
      
      Severity: Minor
      Found in app/models/concerns/has_custom_fields.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 plugin.rb has 397 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      register_asset "stylesheets/common/poll.scss"
      register_asset "stylesheets/common/poll-ui-builder.scss"
      register_asset "stylesheets/desktop/poll.scss", :desktop
      register_asset "stylesheets/mobile/poll.scss", :mobile
      register_asset "stylesheets/mobile/poll-ui-builder.scss", :mobile
      Severity: Minor
      Found in plugins/poll/plugin.rb - About 5 hrs to fix

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

        class PostAlerter
          def self.post_created(post, opts = {})
            PostAlerter.new(opts).after_save_post(post, true)
            post
          end
        Severity: Minor
        Found in app/services/post_alerter.rb - About 5 hrs to fix

          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 send has 136 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

              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 create has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
              Open

                def create
                  unless params[:second_factor_token].blank?
                    RateLimiter.new(nil, "second-factor-min-#{request.remote_ip}", 3, 1.minute).performed!
                  end
              
              
              Severity: Minor
              Found in app/controllers/session_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 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

              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 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 post_serializer.rb has 385 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

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

                class TopicUser < ActiveRecord::Base
                  belongs_to :user
                  belongs_to :topic
                
                  # used for serialization
                Severity: Minor
                Found in app/models/topic_user.rb - About 5 hrs to fix

                  Class AdminDashboardData has 39 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 password_reset has 128 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def password_reset
                        expires_now
                    
                        token = params[:token]
                    
                    
                    Severity: Major
                    Found in app/controllers/users_controller.rb - About 5 hrs to fix

                      File user_serializer.rb has 379 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 initialize has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def initialize(to, opts = nil)
                              @to = to
                              @opts = opts || {}
                        
                              @template_args = {
                        Severity: Minor
                        Found in lib/email/message_builder.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

                        Severity
                        Category
                        Status
                        Source
                        Language