PHPCSStandards / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
786 stars 47 forks source link

Introduce Sonarqube Generic Format Report #400

Open iVegas opened 3 months ago

iVegas commented 3 months ago

Is your feature request related to a problem?

I want to provide a code quality report to the Sonarqube instance.

Describe the solution you'd like

I want to be able to choose a report type for code quality check that is compatible with the Sonarqube generic report format.

Additional context (optional)

See https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/importing-external-issues/generic-issue-import-format/

jrfnl commented 3 months ago

@iVegas Thank you for your interest in contributing to PHP_CodeSniffer.

There have been requests for this before. I suggest you read the previous discussion about this and take note of the reasons why this was not accepted so far.

https://github.com/squizlabs/PHP_CodeSniffer/pull/2451

More than anything, I would like to point out that custom reports can already be provided via an external standard since PHPCS 3.3.0: https://github.com/squizlabs/PHP_CodeSniffer/pull/1948. That would very much be the preferred route as that means the maintenance burden would not fall on the maintainers of PHPCS.

iVegas commented 3 months ago

So, if I create a project that will implement the expected Report class in a separate composer package, is there a way phpcs will pick definitions of the new Report class as an additional report option?

UPD: I see the linked PR. As I understand, the approach you are proposing to declare the custom Report implementation is through autoloader, which will initiate the custom code standard. Can we update the https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Reporting page to describe how to set to use the custom report format for phpcs call?

jrfnl commented 3 months ago

Can we update the https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Reporting page to describe how to set to use the custom report format for phpcs call?

@iVegas That sounds like a good idea! Would you like to create a text proposal ? We can then fine-tune it together before I update the page.