app/lib/json_resolver.rb

Summary

Maintainability
A
1 hr
Test Coverage

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 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 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

There are no issues that match your filters.

Category
Status