Search code examples
androidkotlingsondetekt

EmptyClassBlock lint complaint on Json TypeToken


I have a piece of kotlin code as below,

gson.fromJson<Map<String, JsonElement>>(data, 
   object : TypeToken<Map<String, JsonElement>>() {}.type)

Detekt doesn't like it and complaint EmptyClassBlock - [<UnknownName>]

Is there any way I could resolve that?


Solution

  • This exact case was removed from the EmptyClassBlock rule in this PR: https://github.com/arturbosch/detekt/pull/665

    It should be available in the latest detekt release (RC6-2) already. After updating detekt you shouldn't need to manually @Suppress these cases (objects of abstract classes) anymore.