exhaustive icon indicating copy to clipboard operation
exhaustive copied to clipboard

Check exhaustiveness of switch statements of enum-like constants in Go source code.

Results 19 exhaustive issues
Sort by recently updated
recently updated
newest added

Fix #35 In some cases `switch` by enum is too verbose and can be simplified by using `map`. WIth this PR `exhaustive` validates map keys as well. ```go type Enum...

There are places when we need to convert enum to some different value (enum or string, for example). Go's `map` is less verbose than `switch` and is more suitable for...

Inspired from #35. There are certain structs whose fields you'd want to initialize exhaustively, i.e. whose fields should all be explicitly populated, even if with zero values. Being able to...

It is unclear to me at this point what effect the upcoming go1.18 type parameter change will have on this analyzer. We may need to define the analyzer's behavior when...

```go type M int const ( A M = iota B ) func quux(v M) { switch v { case M(A): } } ``` For the program above, exhaustive currently...

e.g. time.Duration The current definition of enum used by exhaustive considers time.Second, time.Millisecond, etc. as enum members of the enum type time.Duration. It’s not unheard of for code to switch...

There is alternative approach how to deal with enums in Go. Example: https://github.com/ThreeDotsLabs/wild-workouts-go-ddd-example/blob/master/internal/trainer/domain/hour/availability.go Article with motivation: https://threedots.tech/post/safer-enums-in-go/. The idea is to use struct with private field and package level variables....

Most code I have written and seen using reflect.Kind etc rarely is ever exhaustive when dealing with reflected types, so I find myself always having to add `//nolint:exhaustive`. Would be...

Add `directiveSet` bitset data structure and `directive` enum with stricter parsing to not recognize comments like `//exhaustive:enforce-none` as valid directives. Also return errors on invalid directives or combinations thereof. Resolves...