discourse/discourse

View on GitHub

Showing 1,539 of 1,848 total issues

Avoid too many return statements within this method.
Open

    return false if groups.present?
Severity: Major
Found in lib/guardian.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 false if stat.topic_reply_count < SiteSetting.tl2_requires_topic_reply_count
      Severity: Major
      Found in lib/promotion.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

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

          Avoid too many return statements within this method.
          Open

              return true if user.badges.where(name: title, allow_title: true).exists?
          Severity: Major
          Found in lib/guardian.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 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 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

                      Method parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def self.parse(line)
                      
                            result = new
                            _, result.time, result.ip_address, result.url, result.user_agent,
                              result.route, result.status, result.bytes_sent, result.referer,
                      Severity: Minor
                      Found in plugins/discourse-nginx-performance-report/lib/log_analyzer.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 generate_html has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def generate_html(text, opts = {})
                        output = "<p><span"
                        output += " data-date=\"#{opts[:date]}\"" if opts[:date]
                        output += " data-time=\"#{opts[:time]}\"" if opts[:time]
                        output += " class=\"discourse-local-date\""
                      Severity: Minor
                      Found in plugins/discourse-local-dates/spec/lib/pretty_text_spec.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 get_screened_url_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def get_screened_url_fields(screened_url)
                            screened_url_array = []
                      
                            HEADER_ATTRS_FOR['screened_url'].each do |attr|
                              data =
                      Severity: Minor
                      Found in app/jobs/regular/export_csv_file.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(_)
                            return if SiteSetting.invalidate_inactive_admin_email_after_days == 0
                      
                            User.human_users
                              .where(admin: true)
                      Severity: Minor
                      Found in app/jobs/scheduled/invalidate_inactive_admins.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 get_header has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def get_header
                            if @entity == 'user_list'
                              header_array = HEADER_ATTRS_FOR['user_list'] + HEADER_ATTRS_FOR['user_stats'] + HEADER_ATTRS_FOR['user_profile']
                              header_array.concat(HEADER_ATTRS_FOR['user_sso']) if SiteSetting.enable_sso
                              user_custom_fields = UserField.all
                      Severity: Minor
                      Found in app/jobs/regular/export_csv_file.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 download has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def download(src)
                            downloaded = nil
                      
                            begin
                              retries ||= 3
                      Severity: Minor
                      Found in app/jobs/regular/pull_hotlinked_images.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

                      Method user_list_export has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def user_list_export
                            return enum_for(:user_list_export) unless block_given?
                      
                            user_field_ids = UserField.pluck(:id)
                      
                      
                      Severity: Minor
                      Found in app/jobs/regular/export_csv_file.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)
                            raise Discourse::InvalidParameters.new(:user_id) unless args[:user_id].present?
                            raise Discourse::InvalidParameters.new(:message_type) unless args[:message_type].present?
                      
                            user = User.find_by(id: args[:user_id])
                      Severity: Minor
                      Found in app/jobs/regular/send_system_message.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