In our application there are inner classes defined to create and destroy local variables. But I want to exclude these inner classes from sonar code duplication violations as all inner classes will have same kind of blocks it.
Unfortunately, this is not possible. This is real code duplication, which means you should be able to refactor this into a single place.