Make approach to defining enums consistent across the project
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 912
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
#654 introduces the enum type Ecosystem implemented differently to other enums (e.g. analysis.Mode and staticanalysis.Task and analysisrun.DynamicPhase)
We should develop a consistent approach to how we define enums:
Some areas that should be covered:
- should the base type be string vs numeric
- how do we handle lists of enums
- how do enums interact with flags
- how do enums handle serialization (JSON)
Both:
- require String()
Numeric based enums:
- can use
iota - can consume as little as 8bits (byte)
- very fast to compare equality
encoding.TextMarshalerandencoding.TextUnmarshalerneeded to supportflag.TextVarand json serialization- requires strings to be specified for marshaling and unmarshaling (although an array of strings may make this easier)
String based enums:
- consume 128 bits per enum
- simpler String() function and serialization
- equality is more costly (at minimum two comparisons, maximum the size of the shortest string)
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
Compare the enum definitions introduced by #654 for Ecosystem with analysis.Mode, staticanalysis.Task, and analysisrun.DynamicPhase. Review how each handles strings, lists, flags, JSON serialization, and String(), then agree on a single documented approach covering numeric versus string bases and required marshaling behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100