Avoid FirstOrDefault without subsequent OrderBy
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 0
- Forks
- 1
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 7
Description
FirstOrDefault without OrderBy leads to non-deterministic choosing of data and can silently hide corrupted data if there's multiple elements and we only expect one. Prefer SingleOrDefault when there should only be one result and never use FirstOrDefault without an immediately following OrderBy
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the repository for FirstOrDefault usages and inspect the surrounding queries to determine whether each result is expected to be unique or ordered. Replace cases according to the issue's rule, then verify that every remaining FirstOrDefault has an immediately preceding OrderBy and that uniqueness expectations use SingleOrDefault.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100