Skip to content

Commit

Permalink
Fix error when there are nil headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Dantemss committed Dec 18, 2024
1 parent ab2c96a commit 8b48e89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/routines/exercises/tag/assessments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ def exec(filename:, book_uuid:)
post_indices = nil
record_failures do |failures|
ProcessSpreadsheet.call(filename: filename, headers: :downcase) do |headers, row, row_index|
uuid_index ||= headers.index { |header| header.include?('uuid') }
uuid_index ||= headers.index { |header| header&.include?('uuid') }
raise ArgumentError, 'Could not find page UUID column' if uuid_index.nil?

pre_indices ||= headers.filter_map.with_index do |header, index|
index if header.include?('pre')
index if header&.include?('pre')
end
raise ArgumentError, 'Could not find pre-section columns' if pre_indices.empty?

post_indices ||= headers.filter_map.with_index do |header, index|
index if header.include?('post')
index if header&.include?('post')
end
raise ArgumentError, 'Could not find post-section columns' if post_indices.empty?

Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/exercises/tag.rake
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ namespace :exercises do
csv << [ 'Exercise UID', 'Tags...' ]

ProcessSpreadsheet.call(filename: args[:filename], headers: :downcase) do |headers, row, index|
chapter_index ||= headers.index { |header| header.include? 'chapter' }
chapter_index ||= headers.index { |header| header&.include? 'chapter' }
raise ArgumentError, 'Could not find Chapter column' if chapter_index.nil?

Check warning on line 93 in lib/tasks/exercises/tag.rake

View check run for this annotation

Codecov / codecov/patch

lib/tasks/exercises/tag.rake#L91-L93

Added lines #L91 - L93 were not covered by tests

exercise_id_index ||= headers.index do |header|
header.include?('assessment') || header.include?('exercise')
header&.include?('assessment') || header&.include?('exercise')

Check warning on line 96 in lib/tasks/exercises/tag.rake

View check run for this annotation

Codecov / codecov/patch

lib/tasks/exercises/tag.rake#L95-L96

Added lines #L95 - L96 were not covered by tests
end
raise ArgumentError, 'Could not find Assessment ID column' if exercise_id_index.nil?

Check warning on line 98 in lib/tasks/exercises/tag.rake

View check run for this annotation

Codecov / codecov/patch

lib/tasks/exercises/tag.rake#L98

Added line #L98 was not covered by tests

Expand Down

0 comments on commit 8b48e89

Please sign in to comment.