Showing 41 of 41 total issues

Method find_next has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def find_next
    pf = params[:filter]
    begin
      f = Review.filter(pf)
    rescue => e # most likely filter doesn’t exist
Severity: Minor
Found in app/controllers/reviews_controller.rb - About 45 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_question_stat_counts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def get_question_stat_counts(questions = nil)
    filter = {}

    if questions
      questions = [questions] unless questions.is_a?(Array)
Severity: Minor
Found in app/helpers/questions_helper.rb - About 45 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 copy_to has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def copy_to
    def abort(msg)
      flash[:error] = msg
      redirect_to @question
    end
Severity: Minor
Found in app/controllers/questions_controller.rb - About 45 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 is_complete_helper_real has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def is_complete_helper_real
    return false, "nicht freigegeben" if !released?
    return false, "keine Antworten" if answers.size == 0
    # note: matrix_validate? is false if there is more than one answers.
    # Thus it’s enough to ensure that the first answer is correct rather
Severity: Minor
Found in app/models/question.rb - About 45 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

Function getUniqId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function getUniqId(q, a) {
  var qid = (typeof q === 'object' ? q.id : q);
  if(qid === undefined || qid === null) {
    throwWithAlert('invalid question id', "question=" + q + "  qid=" + qid);
  }
Severity: Minor
Found in app/assets/javascripts/hitme.js - 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 copy_assoc_objects has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def copy_assoc_objects(question)
    objs = []
    objs += @question.answers if params[:copy_answers] == "1"
    objs += @question.hints if params[:copy_hints] == "1"

Severity: Minor
Found in app/controllers/questions_controller.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

Function renderStarred has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function renderStarred(question) {
  c = "";
  c += '<div class="star">';

  if(window.loggedIn) {
Severity: Minor
Found in app/assets/javascripts/hitme.js - 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 embed_video_str has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def embed_video_str(opts, width=240, height=240, freezeframe="#t=0.5")
    s = "<video width=\"%s\", height=\"%s\" controls=\"controls\" preload=\"metadata\"><source src=\"%s\" type=\"video/mp4\"></video>"
    return nil if opts['video_file_link'].nil? || opts['width'].nil? || opts['height'].nil?
    url = opts['video_file_link'] + freezeframe
    w = opts['width'].nil? || opts['width'] > width ? width.to_s : opts['width'].to_s
Severity: Minor
Found in app/lib/json_resolver.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 toggle_attr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def toggle_attr(attr)
    raise "attr must be symbol" unless attr.is_a?(Symbol)
    name = attr.to_s.humanize
    # skip before_save callbacks to keep the user signed in (avoid re-
    # generating remember_token)
Severity: Minor
Found in app/controllers/users_controller.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 method.
Open

    return true, ""
Severity: Major
Found in app/models/question.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return false, "Unerreichbar, da das Elter eine andere Zielgruppe als diese Frage hat." unless QuestionReachability.new(self).any_reachable?
    Severity: Major
    Found in app/models/question.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return false, "Elter nicht freigegeben" if parent && !parent.released?
      Severity: Major
      Found in app/models/question.rb - About 30 mins to fix

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

          def self.resolve_efficiently(question_ids, root_count, current_user, qs_data = [])
            question_ids.map.with_index do |q, idx|
              # maximum depth of 5 questions. However, avoid going too deep for
              # later questions. For example, the last question never will
              # present a subquestion, regardless if it has one. Therefore, no
        Severity: Minor
        Found in app/lib/json_resolver.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 dot_region_siblings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def dot_region_siblings(may_omit)
            return "" unless parent.respond_to?(:questions)
        
            limit = may_omit ? 6 : -1
            qs = siblings.includes(:answers, :parent).limit(limit).to_a
        Severity: Minor
        Found in app/models/question.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 raw_to_percentage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def raw_to_percentage(raw_data_array)
            size = raw_data_array[:right].size
        
            percent_correct = []
            percent_skipped = []
        Severity: Minor
        Found in app/helpers/stats_helper.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 render_correctness has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def render_correctness(answer)
            c = answer.is_a?(Answer) ? answer.correct? : answer
            txt = c ? '✔ richtig' : '✘ falsch'
            cls = c ? 'success' : 'error'
           %|<em class="alert-#{cls}">#{txt}</em>|.html_safe
        Severity: Minor
        Found in app/helpers/answers_helper.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 json_for_answer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def json_for_answer(a)
            key = generate_cache_key(a.id)
        
            cache = Rails.cache.read(key)
            return cache if cache
        Severity: Minor
        Found in app/lib/json_resolver.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            user = User.find_by_nick(params[:session][:nick])
            if user && user.authenticate(params[:session][:password])
              session[:remember_me] = params[:session][:remember_me] == "1"
              sign_in user
        Severity: Minor
        Found in app/controllers/sessions_controller.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_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_user
            @user = User.find(params[:id]) rescue nil
        
            unless @user
              logger.warn "get_user failed with id=#{params[:id]}"
        Severity: Minor
        Found in app/controllers/users_controller.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 insert_stat_in_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def insert_stat_in_hash(stat, hash, time = Time.now)
            # group by running week
            weeks_ago = weeks_ago(stat.created_at, time)
            return if hash[:right][weeks_ago].nil?
            if stat.skipped?
        Severity: Minor
        Found in app/helpers/stats_helper.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