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
213 stars 78 forks source link

Variable substitution #71

Closed jgarec closed 5 years ago

jgarec commented 6 years ago

Hi,

Note sure it's an issue but i need to know how to deal with variable substituion. Our scripts contain some substitution like this :

CREATE OR REPLACE PACKAGE BODY &&OWN_USER..MY_PKG AS
[...]

Sonar-scanner fails with the following message :

ERROR: Parse error at line 1 column 36:
  -->  CREATE OR REPLACE PACKAGE           ..MY_PKG AS

If i use double quotes around the variable, it's ok in this case but i'm not sure it works in all case :

CREATE OR REPLACE PACKAGE BODY "&&OWN_USER.".MY_PKG AS
[...]
jgarec commented 6 years ago

sonarcloud plsql plugin accepts substitution without adding double quotes.

felipebz commented 6 years ago

Hi @jgarec.

It's a hard problem because these variable substitutions can appear anywhere... I'm not sure how this can be fixed. In the version 2.1 the plugin was "improved" to just ignore completely the parsing failures and not interrupt the analysis of the whole file. You can read more about this in https://github.com/felipebz/sonar-plsql/wiki/Error-recovery

The drawback of this approach is that the code inside the package won't be analyzed and won't register any issue in SonarQube.

I don't know what SonarSouce is doing on its plugin. Is it able to identify issues inside this package?