felipebz / zpa

Parser and static code analysis tool for PL/SQL and Oracle SQL.
https://zpa.felipebz.com
GNU Lesser General Public License v3.0
216 stars 78 forks source link

Offer proper support for commercial editions of SonarQube #133

Closed felipebz closed 3 years ago

felipebz commented 5 years ago

From time to time, I receive requests from SonarSource customers that want to use ZPA on a commercial edition of SonarQube and hit some issue (e.g. #103 and #131). Currently, it's necessary to choose between SonarPLSQL (the SonarSource's plugin) and ZPA setting the properties sonar.plsql.file.suffixes (for SonarPLSQL) or sonar.zpa.file.suffixes (for ZPA) accordingly. It's not possible to analyze the same file with both plugins at the same time.

This happens because ZPA declares a language called "plsqlopen", register the same file types as the SonarPLSQL plugin and always save metrics for the analyzed files.

I always believed that SonarQube didn't allow that two plugins analyze the same file but according to Pierre-Yves Nicolas (a SonarSource employee) it should be possible to support this scenario:

You can create your own plugin and deploy it on a server which already has sonar-plsql-plugin.jar. However, it should not declare the plsql language and the same file extensions as sonar-plsql-plugin.jar. It can still analyze the plsql files and raise issues on them. There are some open source community plugins which do that for java (example).

As can be seen in the given example, the sonar-checkstyle plugin can analyze the same Java files analyzed by the SonarJava analyzer because it's reading the files indexed by SonarJava:

https://github.com/checkstyle/sonar-checkstyle/blob/69ca51477e6abfb6be295ff5a54d77867a4ce340/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSensor.java#L35-L38

Considering this, to offer "proper support" for commercial editions of SonarQube, i.e. execute ZPA and SonarPLSQL side-by-side in the same file, some things come to my mind:

https://github.com/felipebz/zpa/blob/432c08ff6fccbfe818a0465913b1a3c50bf29c0c/sonar-plsql-open-plugin/src/main/kotlin/org/sonar/plsqlopen/PlSqlSquidSensor.kt#L57

To be honest, the last point is an impeditive for me and I don't plan to move forward with this issue by myself.

snoopyhzy commented 4 years ago

I do a sql plugin that has same problem. I plan to try getting all Input File and filter suffixes by myself.I think it will not confict

snoopyhzy commented 4 years ago

I test it..it check language suffixes on start not scan.....