codeclimate / test-reporter

Code Climate Test Reporter
MIT License
154 stars 76 forks source link

Make simplecov json formatter more flexible #488

Closed fede-moya closed 2 years ago

fede-moya commented 2 years ago

simplecov_json_formatter's json report now contains an extra key, named groups. This was included on https://github.com/codeclimate-community/simplecov_json_formatter/pull/2 . The current approach for decoding the JSON report into a predefined struct is too rigid due to the use of DisallowUnkownFields().

DisallowUnknownFields causes the Decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination. Godoc

That explains why the test report will fail to decode the new simplecov_json_formatter report, since it has a new key groups which is not declared on the struct.

This DisallowUknownFields() was use as a strategy to detect when the given simplecov report is on legacy format (simplecov < 0.18). I'm changing the strategy to extract the simplecov version from the test report and make a decision about with simplecov formatter to use based on that.