2

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?

Elye
  • 53,639
  • 54
  • 212
  • 474

2 Answers2

1

It can be suppressed by annotating the code with @Suppress("EmptyClassBlock") (Described here)

Here’s the list of rule ids, one of which has to be passed an an argument to the annotation (EmptyClassBlock in your case).

s1m0nw1
  • 76,759
  • 17
  • 167
  • 196
0

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.

Mauin
  • 483
  • 3
  • 12