discourse/discourse

View on GitHub

Showing 1,782 of 2,040 total issues

Method prepare_lines has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def prepare_lines
    previous_line = nil

    @plaintext.each_line do |text|
      text.chomp!
Severity: Minor
Found in lib/plain_text_to_markdown.rb - About 35 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 validate_each has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(record, attribute, value)
    old_errors = record.errors[attribute].size

    # look for any duplicates at all
    super
Severity: Minor
Found in lib/validators/unique_among_validator.rb - About 35 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 list_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def list_missing(model, prefix)
      connection = ActiveRecord::Base.connection.raw_connection
      connection.exec('CREATE TEMP TABLE verified_ids(val integer PRIMARY KEY)')
      marker = nil
      files = @s3_helper.list(prefix, marker)
Severity: Minor
Found in lib/file_store/s3_store.rb - About 35 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 description has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def description
      time_left =
        if @available_in <= 3
          I18n.t("rate_limiter.short_time")
        elsif @available_in < 1.minute.to_i
Severity: Minor
Found in lib/rate_limiter/limit_exceeded.rb - About 35 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 classify_line_as_code! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def classify_line_as_code!(line, previous_line)
    line.code_block = previous_line.code_block unless previous_line.nil? || previous_line.valid_code_block?
    return unless line.text =~ /^\s{0,3}```/

    if line.code_block.present?
Severity: Minor
Found in lib/plain_text_to_markdown.rb - About 35 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 update_topic_stats has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update_topic_stats
    attrs = { updated_at: Time.now }

    if @post.post_type != Post.types[:whisper]
      attrs[:last_posted_at] = @post.created_at
Severity: Minor
Found in lib/post_creator.rb - About 35 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 create_es6_context has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.create_es6_context
    ctx = MiniRacer::Context.new(timeout: 15000)

    ctx.eval("window = {}; window.devicePixelRatio = 2;") # hack to make code think stuff is retina

Severity: Minor
Found in lib/pretty_text.rb - About 35 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 store_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def store_file(file, path, opts = {})
      path = path.dup

      filename = opts[:filename].presence || File.basename(path)
      # cache file locally when needed
Severity: Minor
Found in lib/file_store/s3_store.rb - About 35 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 remove_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def remove_file(url, _)
      return unless is_relative?(url)
      source = "#{public_dir}#{url}"
      return unless File.exists?(source)
      destination = "#{public_dir}#{url.sub("/uploads/", "/uploads/tombstone/")}"
Severity: Minor
Found in lib/file_store/local_store.rb - About 35 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 merge_lines has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def merge_lines(line, previous_line)
    return line if previous_line.nil? || line.text.blank?
    return line if line.text == SIGNATURE_SEPARATOR || previous_line.text == SIGNATURE_SEPARATOR
    return line unless line.quote_level == previous_line.quote_level && previous_line.text.end_with?(" ")

Severity: Minor
Found in lib/plain_text_to_markdown.rb - About 35 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 update_associated_category_latest_topic has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update_associated_category_latest_topic
    return unless @post.topic && @post.topic.category
    return unless @post.id == @post.topic.category.latest_post_id || (@post.is_first_post? && @post.topic_id == @post.topic.category.latest_topic_id)

    @post.topic.category.update_latest
Severity: Minor
Found in lib/post_destroyer.rb - About 35 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 make_all_links_absolute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.make_all_links_absolute(doc)
    site_uri = nil
    doc.css("a").each do |link|
      href = link["href"].to_s
      begin
Severity: Minor
Found in lib/pretty_text.rb - About 35 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 enqueue_jobs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def enqueue_jobs
    # We need to enqueue jobs after the transaction.
    # Otherwise they might begin before the data has been comitted.
    enqueue_post_alerts unless @opts[:import_mode]
    feature_topic_users unless @opts[:import_mode]
Severity: Minor
Found in lib/post_jobs_enqueuer.rb - About 35 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

Avoid too many return statements within this function.
Open

  return 'other';
Severity: Major
Found in lib/javascripts/locale/cy.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

              return s;
    Severity: Major
    Found in lib/javascripts/messageformat.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return 'many';
      Severity: Major
      Found in lib/javascripts/locale/cy.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                  return s;
        Severity: Major
        Found in lib/javascripts/messageformat.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return 'many';
          Severity: Major
          Found in lib/javascripts/locale/br.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return 'many';
            Severity: Major
            Found in lib/javascripts/locale/ar.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                return 'other';
              Severity: Major
              Found in lib/javascripts/locale/ar.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language