discourse/discourse

View on GitHub

Showing 1,565 of 1,870 total issues

Avoid too many return statements within this method.
Open

    return if previous_text.gsub(/(\s){2,}/, '\1') != quoted_text.gsub(/(\s){2,}/, '\1')
Severity: Major
Found in lib/cooked_post_processor.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return false if stat.likes_received < SiteSetting.tl2_requires_likes_received
    Severity: Major
    Found in lib/promotion.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return false unless membership
      Severity: Major
      Found in lib/guardian.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return false if group.visibility_level == Group.visibility_levels[:staff]
        Severity: Major
        Found in lib/guardian.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return false if stat.likes_given < SiteSetting.tl2_requires_likes_given
          Severity: Major
          Found in lib/promotion.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return true if is_admin?
            Severity: Major
            Found in lib/guardian.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return unless Guardian.new.can_see_topic?(topic)
              Severity: Major
              Found in lib/oneboxer.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return if !post || post.hidden || !allowed_post_types.include?(post.post_type)
                Severity: Major
                Found in lib/oneboxer.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                      return if topic.private_message?
                  Severity: Major
                  Found in lib/oneboxer.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                        return { errors: [I18n.t('not_found')] } if obj.is_a?(HasErrors) && obj.not_found
                    Severity: Major
                    Found in lib/json_error.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return @upload unless @upload.save
                      Severity: Major
                      Found in lib/upload_creator.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                            return true if skip_validations?
                        Severity: Major
                        Found in lib/post_creator.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return false
                          Severity: Major
                          Found in lib/post_creator.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                  return false
                            Severity: Major
                            Found in lib/post_creator.rb - About 30 mins to fix

                              Function pluralize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                              I18n.pluralize = function(translation, scope, options) {
                                if (typeof translation !== "object") return translation;
                              
                                options = this.prepareOptions(options);
                                var count = options.count.toString();
                              Severity: Minor
                              Found in app/assets/javascripts/locales/i18n.js - About 25 mins 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 publish has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def self.publish(type, id)
                                    users = get_users(type, id)
                                    serialized_users = users.map { |u| BasicUserSerializer.new(u, root: false) }
                                    message = { users: serialized_users, time: Time.now.to_i }
                                    messagebus_channel = get_messagebus_channel(type, id)
                              Severity: Minor
                              Found in plugins/discourse-presence/plugin.rb - About 25 mins 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 track_like has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def track_like
                                    post_topic_id = @post.topic_id
                                    return unless valid_topic?(post_topic_id)
                              
                                    post_liked = PostAction.find_by(

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

                                  def get_groups(group_names)
                                    groups = []
                              
                                    if group_names
                                      group_names = group_names.split(';')
                              Severity: Minor
                              Found in app/jobs/regular/bulk_invite.rb - About 25 mins 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 voters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def voters(post_id, poll_name, user, opts = {})
                                      post = Post.find_by(id: post_id)
                                      raise Discourse::InvalidParameters.new("post_id is invalid") unless post
                              
                                      poll = Poll.find_by(post_id: post_id, name: poll_name)
                              Severity: Minor
                              Found in plugins/poll/plugin.rb - About 25 mins 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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def execute(args)
                                    return unless SiteSetting.auto_handle_queued_age.to_i > 0
                              
                                    Reviewable
                                      .where(status: Reviewable.statuses[:pending])
                              Severity: Minor
                              Found in app/jobs/scheduled/auto_queue_handler.rb - About 25 mins 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