We are using PHP and Sonar is reporting PHP attributes as uncovered code. To be specific this is an attribute used to describe OpenAPI spec that is then generated based on the attributes.
I know you can exclude rules, but how do we make Sonar ignore only parts of a file coverage?
How can we exclude them from being detected as untested code?
Version: Sonarqube Server Community Version v10.7 (96327)
Deployment: Docker on AWS ECS
Example of the attributes:
#[OA\Post(
operationId: 'post-filter-view',
description: 'xxxxx',
summary: 'Filter View',
tags: ['Filter'],
parameters: [
new OA\Parameter(
name: 'type',
in: 'path',
required: true,
schema: new OA\Schema(type: 'string', enum: ['xxx', 'xxx'])
),
#new OA\Parameter(ref: './Parameters.yaml#/page'),
#new OA\Parameter(ref: './Parameters.yaml#/page_size'),
],
requestBody: new OA\RequestBody(
description: 'Applied filters',
content: new OA\MediaType(
mediaType: 'application/json',
schema: new OA\Schema(
type: 'array',
items: new OA\Items(ref: '#/components/schemas/AppliedFilter')
)
)
),
responses: [
new OA\Response(
response: 200,
description: 'OK',
content: new OA\MediaType(
mediaType: 'application/json',
schema: new OA\Schema(
type: 'array',
items: new OA\Items(
anyOf: [
]
)
)
)
),
]
)]