Hi sonar community,
This feels like bug or it can be a misconfiguration issue.
We are working in php and a we have a long mapping declaration which sonarcloud detect:
- as duplicated block of code.
- comment as duplicated lines (but are new in reality)
Of course following data is fake. But in reality we have a declaration of almost 100 mapped object inside. and that variable is declared as duplicated code to itself…
public function getResourceMap()
{
$mapping = [
'map_object_1' => [
'model' => '\App\Models\map_object_1',
'transformer' => '\App\Transformers\Smart\MapObjectOne'
],
// a lot of mapping isn't it?
// those 2 commented lines are declared as duplicated line
...
'map_object_100' => [
'model' => '\App\Models\map_object_100',
'transformer' => '\App\Transformers\Smart\MapObjectHundred'
],
];
// Fill endpoints for all routes.
$endpointBaseUri = request()->route()->getPrefix();
foreach ($mapping as $key => &$data) {
// Define endpoint url
$data['endpoint'] = url('/') . '/' . $endpointBaseUri . '/' . $key;
// Define resource used for mapping
$data['resource'] = $key;
}
return $mapping;
}
Is it a bug?