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?
You can’t avoid the creation of duplicate code. But SonarQube will help you find code duplications in the same file, in the same project, or even across multiple projects, so you can clean up your duplications. There are four metrics related to code duplication.
Chapter 4. Working with duplicate code - SonarQube in Action Chapter 4. Working with duplicate code When you start a new project, you have a clean code base with no duplications, unless you copied another project to start with.
SonarQube's issues workflow can help you manage your issues. There are seven different things you can do to an issue (other than fixing it in the code!): Comment, Assign, Confirm, Change Severity, Resolve, Won't Fix, and False Positive. These actions break out into three different categories.
Doing so allows you to remove noise, like the issues and duplications marked on generated code, or the issues from rules that aren't relevant for certain types of files. SonarQube gives you several options for configuring exactly what will be analyzed. You can
You can exclude this in Sonar by going to Administration > General Settings > Analysis Scope > Duplication Exclusions and excluding folders containing your entities - e.g. /entity/
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?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With