danmayer / coverband

Ruby production code coverage collection and reporting (line of code usage)
https://github.com/danmayer/coverband
MIT License
2.49k stars 160 forks source link

I18n tracking : manually mark an item as being used #549

Open Systho opened 3 weeks ago

Systho commented 3 weeks ago

Is your feature request related to a problem? Please describe.

I am using i18n-js for expsing a subset of my i18n keys to my javascript code. Those keys are never used by any ruby code but I would like to report from javascript when a key (or a set of keys) are used.

I can easily make an API controller or a Channel for this and send a message from javascript but then I do not know how to tell Coverband to mark it.

According to this file I would be inclined to use Coverband.configuration.translations_tracker.track_key(flat_key) but this does not really feel like a public API

How can I do this ?

Describe the solution you'd like In the best ever world, I wish the railtie would register a (safe) way to notify Coverband that a key has been used. But in a more realistic world, I would love to a have public API available for marking a key as used (and possibly other entrypoint into Coverband )

Describe alternatives you've considered

Additional context

I could easily tune something for my use case, but I thought that I might not be the only one with this need

danmayer commented 4 days ago

I believe you can use the ignore config to match your translation keys...

https://github.com/danmayer/coverband/blob/main/lib/coverband/collectors/abstract_tracker.rb#L130

try adding a string that would be a regex to some keys you want to ignore and let me know if that works @Systho