Only use public types in the signatures of exported formatter functions
- Dominant language
- Go
- Stars
- 2.7k
- Forks
- 280
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 2
Description
### 🤔 What's the problem you've observed?
When extending a formatter (like the example [emoji formatter](https://github.com/cucumber/godog/blob/main/_examples/custom-formatter/emoji.go)), you can use the `formatter.Storage` methods to get back results
you need. However, a lot of these methods have signatures that rely on internal types. This can make it difficult to use these public methods.
For example, if i have formatter `f`, that is extending the `godog.ProgressFmt`, then i have access to this function:
```
f.Storage.MustGetPickleStepResultsByStatus
```
With this, I can easily get all failed steps, all passed steps, etc....
Except this function takes as its parameter `models.StepResultStatus`, and I do not have access to `models`. So if I want to get all passed steps, i have to know that `models.Passed` is roughly equivalent to `0` and pass `0` in directly.
This may be me misunderstanding how this function is intended to be used, though.
### ✨ Do you have a proposal for making it better?
My naive suggestion is to move models out of the internal directory, or at least adjust any of the base formatter functions to only use public types in their signatures.
Contributor guide
Research direction
Start with the formatter.Storage methods used by the custom formatter example in _examples/custom-formatter/emoji.go, especially MustGetPickleStepResultsByStatus. Trace the exported formatter signatures and the internal models.StepResultStatus type, then determine which public type should be exposed. Done means formatter extensions can use these methods without importing internal models or relying on numeric values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, developer-experience
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100