-
-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Describe the bug
The scores boolean field exists in both the database migration and the Ecto schema for DealtCard, but is never read, written, or referenced anywhere in the codebase. The field appears to have been intended to cache whether a dealt card scored in a round, but was never implemented. Instead, scoring is calculated dynamically every time via vote counting.
To Reproduce
Steps to reproduce the behavior:
- Open lib/copi/cornucopia/dealt_card.ex and find field :scores, :boolean
- Open priv/repo/migrations/20210522185023_create_dealt_cards.exs and find add :scores, :boolean
- Search the entire codebase for any usage of scores in lib/ or test/
- No results found the field is never used anywhere
Expected behavior
Either the scores field should be populated when a card scores and used in scoring logic, or it should be removed from both the schema and database via a new migration if it was intentionally abandoned.
EvidenceThe field is defined in the migration:
# priv/repo/migrations/20210522185023_create_dealt_cards.exs add :scores, :boolean
However, searching the entire codebase confirms it is never read, written, queried, or referenced anywhere in lib/ or test/.
Instead, scoring is calculated dynamically every time via vote counting in cornucopia.ex:
def scoring_cards(cards, number_of_players) do
Enum.filter(cards, fn card ->
card.played_in_round != nil &&
Enum.count(card.votes) > (number_of_players - 1) / 2
end)
end
Additional context
Affected files:
lib/copi/cornucopia/dealt_card.ex
priv/repo/migrations/20210522185023_create_dealt_cards.exs
Are you going to work on fixing this?
- Yes
- No