Sonarqube duplicated blocks of code between POJOs

2019-02-15 09:33发布

问题:

There are two POJOs Market and MarketDTO in two packages.

Market is a mapping object for JSON response from remote service.

MarketDTO is a response object which will be exposed via our service.

There are some data massage from Market->MarketDTO. They have some common fields and both have unique fields as well. There are 3 common fields such as id, name and status.

However, Sonarqube indicates their getters and setters as duplicated blocks of codes to be removed. Is this actually bad code or I should just mark it as false positive?

回答1:

I'd say your choices are to extract a common ancestor class from Market and MarketDTO, or mark the duplicated blocks issues Won't Fix. (They're not really false positives, are they?)