oasisprotocol / oasisprotocol/oasis-core
tiny nit: default case for an exhaustive switch should generate a severe log entry (and possibly panic on non-production builds)
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 369
- Forks
- 151
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
Description
Description of the bug
tiny nit re making it harder to introduce errors later.
default case for a switch that is intended to be exhaustive should log and/or panic. i.e., emulate C/C++ -Wswitch -Wswitch-enum behavior
Steps to reproduce
Expected behavior
If a future code change introduces a new enum (what the const CodeXXX is emulating) but forgets to update the String() method for Code values, we would detect it quickly in tests (where hopefully a new high-severity log entry would be noticed) or in a dev environment (panics). Not sure if golang builds permit prod vs debug builds, so panics might be too scary.
Environment
- OS:
- Versions of relevant software and tools:
Additional information
Anything else you think would be useful; including context and suggested fixes.
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
Start at go/tendermint/api/api.go around line 59 and inspect the switch used by Code.String(). Determine how exhaustive enum handling should report an unexpected value, including whether production and non-production builds need different behavior. Done means future unmapped Code values produce the agreed severe log entry or panic behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100