vegantech/sims

View on GitHub
app/controllers/interventions_controller.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method ajax_probe_assignment has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def ajax_probe_assignment
    @intervention = current_student.interventions.find_by_id(params[:intervention_id]) || Intervention.new
    if params[:id] == 'custom'
      @intervention_probe_assignment = @intervention.intervention_probe_assignments.build if @intervention
      if @intervention_probe_assignment and  @intervention_probe_assignment.probe_definition.blank?
Severity: Minor
Found in app/controllers/interventions_controller.rb - About 2 hrs 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 find_intervention has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def find_intervention
    if current_student.blank?
     # alternate entry point
      intervention = Intervention.find(params[:id])
      if intervention && intervention.student && intervention.student.belongs_to_user?(current_user)
Severity: Minor
Found in app/controllers/interventions_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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    if params[:intervention]
      params[:intervention][:participant_user_ids] ||=[]
      params[:intervention][:intervention_probe_assignment] ||= {}
      params[:intervention][:comment_author] = current_user.id
Severity: Minor
Found in app/controllers/interventions_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

There are no issues that match your filters.

Category
Status