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
211 stars 77 forks source link

ZPA PLSQL plugin - is unable to pickup Quality Profile automatically when scanning .pb files #162

Closed csrvsk closed 2 years ago

csrvsk commented 2 years ago

Hi, I am using SonarQube command line to scan the project which consists of .pb files. For which I have added ZPA -PLSQL open source plugin. When I ran the scan, project is created in Sonar dashboard but the results are empty and the reason it is unable to pickup the quality profile for the type of files. Initially I thought the reason was, since ZPA plugin is not native in Community Edition of SQ. But surprisingly when I rans the scan on a project which is consisting of .sql files which are defined by default with this plugin, SonarQube was able to pickup Quality Profile for .sql files.

Please let me know if there is a workaround without using Sonar GUI.

felipebz commented 2 years ago

Hi,

You can use the property sonar.zpa.file.suffixes (File Suffixes) on "Administration" > "Z PL/SQL Analyzer" to set what file extensions should by analyzed by the plugin.

By default, it analyses files with the extension sql, pkg, pks and pkb, but you're free to change them and add any extension you need.

csrvsk commented 2 years ago

yeah i tried that but it is not picking up .pb files. But it is for .sql files. as i can see only 4 types of default extensions are there by default.

image

felipebz commented 2 years ago

That's weird, it should work. You can try to re-run the analysis passing the option -X to SonarScanner to enable more logs. It'll show something like this:

(...)
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: **/*.min.*, **/jquery.js, **/*.Designer.cs
DEBUG: 'src\file1.sql' indexed with language 'plsqlopen'
DEBUG: 'src\file2.pb' indexed with language 'plsqlopen'
INFO: 2 files indexed
(...)

As shown in the example, the .pb file was correctly indexed with the language "plsqlopen", which means it'll analyzed by this plugin.

csrvsk commented 2 years ago

Hi, I am wondering if there is way to recompile the plugin source code in such way that it makes .pb files as default along with the extension sql, pkg, pks and pkb.

please advice accordingly. The reason I am asking for this is I want to make this possible without using sonar GUI. Hope you understand my concern.

felipebz commented 2 years ago

If you don't want to set this parameter on SonarQube UI, you can pass the property to the SonarScanner:

sonar-scanner -Dsonar.zpa.file.suffixes=sql,pkg,pks,pkb,pb ...

csrvsk commented 2 years ago

INFO: Load global settings INFO: Load global settings (done) | time=187ms INFO: Server id: 691572F1-AYC9s4rbyczHRo3DzoM4 INFO: User cache: C:\Users\ShivaKumar.Vardhamaa.sonar\cache INFO: Load/download plugins INFO: Load plugins index INFO: Load plugins index (done) | time=92ms INFO: Load/download plugins (done) | time=710ms INFO: Process project properties INFO: Process project properties (done) | time=10ms INFO: Execute project builders INFO: Execute project builders (done) | time=1ms INFO: Project key: V12_AP_PS INFO: Base dir: C:\cm32\ERP_SVN\Standard\V12\AP\PS INFO: Working dir: C:\cm32\ERP_SVN\Standard\V12\AP\PS.scannerwork INFO: Load project settings for component key: 'V12_AP_PS' INFO: Load project settings for component key: 'V12_AP_PS' (done) | time=96ms INFO: Load quality profiles INFO: Load quality profiles (done) | time=4452ms INFO: Load active rules INFO: Load active rules (done) | time=7385ms INFO: Indexing files... INFO: Project configuration: INFO: 74 files indexed INFO: ------------- Run sensors on module V12_AP_PS INFO: Load metrics repository INFO: Load metrics repository (done) | time=133ms INFO: Sensor C# Project Type Information [csharp] INFO: Sensor C# Project Type Information [csharp] (done) | time=3ms INFO: Sensor C# Analysis Log [csharp] INFO: Sensor C# Analysis Log [csharp] (done) | time=18ms INFO: Sensor C# Properties [csharp] INFO: Sensor C# Properties [csharp] (done) | time=1ms INFO: Sensor HTML [web] INFO: Sensor HTML [web] (done) | time=4ms INFO: Sensor Text Sensor [text] INFO: 0 source files to be analyzed INFO: 0/0 source files have been analyzed INFO: Sensor Text Sensor [text] (done) | time=6ms

csrvsk commented 2 years ago

I tried the command before and it didn't work

csrvsk commented 2 years ago

Hi, I am wondering if there is way to recompile the plugin source code in such way that it makes .pb files as default along with the extension sql, pkg, pks and pkb.

please let me know

felipebz commented 2 years ago

You need to pass -X flag to sonar-scanner to show the debug output, which contains the info I mentioned on a previous comment.

Hi, I am wondering if there is way to recompile the plugin source code in such way that it makes .pb files as default along with the extension sql, pkg, pks and pkb.

Sure, the default values are defined on the PlSqlPlugin class: https://github.com/felipebz/zpa/blob/c1e29f5f679a588d3290c0a426e970e16efa7db5/sonar-zpa-plugin/src/main/kotlin/org/sonar/plsqlopen/PlSqlPlugin.kt#L41

You could change it and recompile the project, but I'm confident that it won't fix the root cause of your problem. It's the same thing as setting this value using the SonarQube UI or setting the property on the analysis.