False positive of duplicate lines for PHP Symfony Attributes


SonarCloud marks a lot of duplicate lines for attributes. For instance describing Api Controllers.

Is there a way to exclude these lines?

        path: '/v1/infocontroller/{id}',
        name: 'info',
        requirements: ["id"=>"\d+"],
        methods: ['GET']
    #[OA\Get(operationId: 'getInfo')]
        name: 'id',
        description: 'The id',
        in: 'path',
        required: true,
        schema: new OA\Schema(type: 'integer', minimum: 1, example: 1)
        response: Response::HTTP_OK,
        description: 'Returns the info',
        content: new OA\JsonContent(
            ref: new DOCA\Model(type: InfoModel::class))
        response: Response::HTTP_NOT_FOUND,
        description: 'Info not found'

Arjan Vermunt

Hello @ArieGato and welcome on Community!

Sorry for the late reply, we are investigating your issue and will come back to you soon.


Hello @ArieGato,

From my understanding, this duplicate line detection is working as expected, as you have very similar/identical lines of codes in different files, which describe your Api Controllers.
Is that correct?

I checked, and currently, it is impossible to exclude a specific set of lines in SonarCloud.
It is only possible to exclude files or even packages; you can do this by adding this property to your scanner configuration:


Analysis Scope | SonarCloud (“Scope of duplication detection” chapter)

I hope that help.

Edit: After an internal discussion, we decided it would make sense to globally exclude the PHP attribute group from the duplicate mechanism.

This has been integrated on our side and should be available soon on SonarCloud.

Thnx @rudy.regazzoni,

I can’t wait for the fix. Sorry for the late reaction.

Kind regards,