app/controllers/officing/results_controller.rb
Method build_results
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def build_results
@results = []
params[:questions].each_pair do |question_id, results|
question = @poll.questions.find(question_id)
- Read upRead up
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
Line is too long. [132/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
partial_result = ::Poll::PartialResult.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
- Exclude checks
Line is too long. [107/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
where(booth_assignment_id: index_params[:booth_assignment_id]).
- Exclude checks
Line is too long. [105/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
officer_assignments.final.find_by(id: results_params[:officer_assignment_id])
- Exclude checks
Line is too long. [109/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
@partial_results = ::Poll::PartialResult.where(officer_assignment_id: @officer_assignments.map(&:id))
- Exclude checks
Line is too long. [115/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
- Exclude checks
Line is too long. [105/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
@booth_assignment = ::Poll::BoothAssignment.includes(:booth).find(index_params[:booth_assignment_id])
- Exclude checks
Line is too long. [109/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
@recounts = ::Poll::Recount.where(booth_assignment_id: @booth_assignment.id, date: index_params[:date])
- Exclude checks