Giter Site home page Giter Site logo

felipebz / zpa Goto Github PK

View Code? Open in Web Editor NEW
207.0 17.0 77.0 4.63 MB

Parser and static source code analyzer for PL/SQL and Oracle SQL.

Home Page: https://felipezorzo.com.br/zpa/

License: GNU Lesser General Public License v3.0

Java 0.19% PLSQL 32.56% HTML 2.67% Kotlin 63.93% Standard ML 0.60% Smarty 0.06%
sonarqube oracle-sql plsql analysis sql-analyzer static-analysis parser oracle-forms plsql-parser plsql-analyzer

zpa's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zpa's Issues

Various parsing errors in SQL, PL/SQL and SQLPlus commands

Hi,

I'm trying to use the plug-in and get parsing errors:
ERROR: Parse error at line 43 column 31:

31: sp_orders_archive_log_cleanup;
32:
33: procedure sp_orders_archive_file_cleanup;
34:
35: end PKG_ORDERS_ARCHIVE;
36:
37:
38: create or replace package body PKG_ORDERS_ARCHIVE as
39:
40: procedure write_to_log(iText in varchar)
41: is
42: pragma autonomous_transaction;
--> vSystimestamp timestamp(3) := systimestamp;
...

and on another file which has some grants :
ERROR: Parse error at line 1 column 0:

--> grant execute on proc_name to schema_name;

P.S I did not understand which rule-set this plugin implements (In example - https://www.salvis.com/blog/plsql-cop-for-sonarqube/ is implementing http://www.trivadis.com/sites/default/files/downloads/PLSQL_and_SQL_Coding_Guidelines_2_0_HiRes.pdf, but that plug in is not open source as far as I could see nor is it compatible with SonarQube >=5.2 which is why I can't use it)

Thanks,
Mor

Custom rules: Two issues for one item

Hi,

First of all: Thank you for this great work!

I've created a plugin with custom rules according to your Wiki page. My plugin is almost identical with the template project (I only changed the table name 'user' -> 'user_objects'). Unfortunately there are two issues displayed for one item:

custom

I'm using SonarQube 6.5.

How can I resolve this issue? Thank you!

BULK is not a reserved keyword

Hi,
According to oracle PLSQL (link), bulk is not a reserved keyword. i.e. it can be used as an identifier but it is not recommended.

As of today in this project 'BULK' is a reserved keyword, and it fails to parse any PLSQL statements with BULK as an identifier.

Example:

DECLARE
bulk NUMBER;
BEGIN
NULL;
END;

Changing 'bulk' as non-reserved keyword doesn't help as it breaks the build for regular select statement. Like in unit test for

select 1 bulk collect into var from dual

here, it is considering 'bulk' as an alias identifier name and fails to parse this query. Having said that even the below statements are possible and perfectly valid according to oracle.

select 1 bulk bulk collect into var from dual
select 1 bulk into var from dual

I agree having 'bulk' in source code as an identifier is not 'correct' and it is a very bad practice. But even someone might've named a column 'BULK' and the usage of that column in any unit would fail to parse. Like,
l_table_abc.bulk := 'some bulk data';

Any ideas on how to go with it?

Parse error at line 1

Hello,

I'm not sure why but this plugin can't parse any of our SQL's. For example:

ERROR: Parse error at line 1 column 30:

--> CREATE OR REPLACE EDITIONABLE FUNCTION "MADMIN"."CLOB_LENGTHB" (
2: p_clob in clob
3: ) return number is
4: l_pos number := 1;
5: l_size number := 0;
6: begin
7: while ( l_pos <= dbms_lob.getlength

Probably this is a configuration question?

Variable substitution

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
[...]

Documentation for custom checks

The plugin has extension points to allow the creation of custom checks. This should be documented in the wiki and a sample project should be added to the source code.

Sonar start issue

Hi Felipe,

When I try to use your plugin , I have an error and sonar shutdown.
I use Sonar 4.5.5 and the H2 database by default.

--> Wrapper Started as Console
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.

2015.12.18 11:02:35 INFO app[o.s.p.m.JavaProcessLauncher] Launch process[search]: C:\Program Files\Java\jdk1.7.0_71\jre\bin\java -Djava.awt.headless=true -Xmx256m -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=C:\sonarqube\sonarqube-4.5.5\temp -cp ./lib/common/;./lib/search/ org.sonar.search.SearchServer C:\Users\XXXX\AppData\Local\Temp\sq-process2540276144334383058properties
2015.12.18 11:02:37 WARN sea[o.s.p.ProcessEntryPoint] Starting search
2015.12.18 11:02:37 INFO sea[o.s.s.SearchServer] Starting ES[sonarqube] on port: 9001
2015.12.18 11:02:38 INFO sea[o.elasticsearch.node] [sonar-1450432954446] version[1.1.2], pid[10968], build[e511f7b/2014-05-22T12:27:39Z]
2015.12.18 11:02:38 INFO sea[o.elasticsearch.node] [sonar-1450432954446] initializing ...
2015.12.18 11:02:38 INFO sea[o.e.plugins] [sonar-1450432954446] loaded [], sites []
2015.12.18 11:02:43 INFO sea[o.elasticsearch.node] [sonar-1450432954446] initialized
2015.12.18 11:02:43 INFO sea[o.elasticsearch.node] [sonar-1450432954446] starting ...
2015.12.18 11:02:44 INFO sea[o.e.transport] [sonar-1450432954446] bound_address {inet[/0.0.0.0:9001]}, publish_address {inet[/XXXX:9001]}
2015.12.18 11:02:47 INFO sea[o.e.cluster.service] [sonar-1450432954446] new_master [sonar-1450432954446][g2RdKKnlTQeMgDgsT31TjA][XXXX][inet[/XXXX:9001]]{rack_id=sonar-1450432954446}, reason: zen-disco-join (elected_as_master)
2015.12.18 11:02:47 INFO sea[o.e.discovery] [sonar-1450432954446] sonarqube/g2RdKKnlTQeMgDgsT31TjA
2015.12.18 11:02:51 INFO sea[o.e.gateway] [sonar-1450432954446] recovered [2] indices into cluster_state
2015.12.18 11:02:51 INFO sea[o.elasticsearch.node] [sonar-1450432954446] started
2015.12.18 11:03:01 INFO app[o.s.p.m.Monitor] Process[search] is up
2015.12.18 11:03:01 INFO app[o.s.p.m.JavaProcessLauncher] Launch process[web]: C:\Program Files\Java\jdk1.7.0_71\jre\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false -Djruby.compile.invokedynamic=false -Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=C:\sonarqube\sonarqube-4.5.5\temp -cp ./lib/common/;./lib/server/ org.sonar.server.app.WebServer C:\Users\XXXX\AppData\Local\Temp\sq-process7024729147455243545properties
2015.12.18 11:03:03 WARN web[o.s.p.ProcessEntryPoint] Starting web
2015.12.18 11:03:03 INFO web[o.s.s.app.Webapp] Webapp directory: C:\sonarqube\sonarqube-4.5.5\web
2015.12.18 11:03:07 INFO web[o.e.plugins] [sonar-1450432954446] loaded [], sites []
2015.12.18 11:03:09 INFO web[o.s.s.p.ServerImpl] SonarQube Server / 4.5.5 / cc8a9472c671598fb3158b51b15863448a477a50
2015.12.18 11:03:11 INFO web[o.s.s.d.EmbeddedDatabase] Starting embedded database on port 9092 with url jdbc:h2:tcp://localhost:9092/sonar
2015.12.18 11:03:11 INFO web[o.s.s.d.EmbeddedDatabase] Embedded database started. Data stored in: C:\sonarqube\sonarqube-4.5.5\data
2015.12.18 11:03:11 INFO web[o.s.c.p.Database] Create JDBC datasource for jdbc:h2:tcp://localhost:9092/sonar
2015.12.18 11:03:12 WARN web[o.s.s.d.DatabaseChecker] H2 database should be used for evaluation purpose only
2015.12.18 11:03:18 INFO web[o.s.s.p.DefaultServerFileSystem] SonarQube home: C:\sonarqube\sonarqube-4.5.5
2015.12.18 11:03:19 INFO web[org.sonar.INFO] Install plugins...
2015.12.18 11:03:19 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin JavaScript / 2.9 / bbdf49ebe00a6424800074ecd9f3073345b50c51
2015.12.18 11:03:20 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin Findbugs / 3.3 / e1a76544ee6aed765106e7e2bb64072adf63ccaf
2015.12.18 11:03:20 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin JSON / 1.2 / 0
2015.12.18 11:03:21 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin Web / 2.4 / 61c14c00da36f77d18c019ad2bd7942708e99c13
2015.12.18 11:03:21 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin XML / 1.4 / eabc7d2152576a7229cf42c312ddb4a194c6b06d
2015.12.18 11:03:21 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin English Pack / 4.5.5 / cc8a9472c671598fb3158b51b15863448a477a50
2015.12.18 11:03:21 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin Duplications / 4.5.5 / cc8a9472c671598fb3158b51b15863448a477a50
2015.12.18 11:03:21 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin PL/SQL / 1.0-SNAPSHOT / 0
2015.12.18 11:03:22 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin Java / 3.8 / f2c074c2c553fdf41f41f8af0fcfcbb5465a777a
2015.12.18 11:03:22 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin Core / 4.5.5 / cc8a9472c671598fb3158b51b15863448a477a50
2015.12.18 11:03:22 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin Database Cleaner / 4.5.5 / cc8a9472c671598fb3158b51b15863448a477a50
2015.12.18 11:03:22 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin Email notifications / 4.5.5 / cc8a9472c671598fb3158b51b15863448a477a50
2015.12.18 11:03:22 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin CSS / 1.5 / 2b041b7feef1292d91ebbed82fcd7bc76f088961
2015.12.18 11:03:23 INFO web[o.s.s.p.ServerPluginJarsInstaller] Deploy plugin Design / 4.5.5 / cc8a9472c671598fb3158b51b15863448a477a50
2015.12.18 11:03:23 INFO web[org.sonar.INFO] Install plugins done: 3615 ms
2015.12.18 11:03:24 INFO web[o.s.s.p.RailsAppsDeployer] Deploy Ruby on Rails applications
2015.12.18 11:03:25 INFO web[o.s.j.s.AbstractDatabaseConnector] Initializing Hibernate
2015.12.18 11:03:31 INFO web[o.s.s.p.UpdateCenterClient] Update center: http://update.sonarsource.org/update-center.properties (no proxy)
2015.12.18 11:03:31 INFO web[org.sonar.INFO] Code colorizer, supported languages: java,web
2015.12.18 11:03:35 INFO web[o.s.s.n.NotificationService] Notification service started (delay 60 sec.)
2015.12.18 11:03:35 INFO web[o.s.s.s.IndexSynchronizer] Starting DB to Index synchronization
2015.12.18 11:03:36 INFO web[o.s.s.s.BaseIndex] Index rules:rules has last update of Fri Dec 18 09:54:45 CET 2015
2015.12.18 11:03:37 INFO web[o.s.s.s.BaseIndex] Index rules:activeRules has last update of Tue Oct 06 16:06:11 CEST 2015
2015.12.18 11:03:38 INFO web[o.s.s.s.BaseIndex] Index logs:sonarLogs has last update of Thu Jan 01 01:00:00 CET 1970
2015.12.18 11:03:45 INFO web[o.s.s.s.IndexSynchronizer] Synchronization done in 9779ms...
2015.12.18 11:03:45 INFO web[org.sonar.INFO] Deploy GWT plugins...
2015.12.18 11:03:45 INFO web[org.sonar.INFO] Deploy GWT plugins done: 0 ms
2015.12.18 11:03:45 INFO web[org.sonar.INFO] Load metrics...
2015.12.18 11:03:46 INFO web[o.s.s.s.RegisterMetrics] Cleaning quality gate conditions
2015.12.18 11:03:46 INFO web[org.sonar.INFO] Load metrics done: 1456 ms
2015.12.18 11:03:46 INFO web[o.s.s.s.RegisterDebtModel] Register technical debt model...
2015.12.18 11:03:46 INFO web[o.s.s.s.RegisterDebtModel] Register technical debt model done: 47 ms
2015.12.18 11:03:46 INFO web[org.sonar.INFO] Register rules...
2015.12.18 11:03:52 INFO web[org.sonar.INFO] Register rules done: 5341 ms
2015.12.18 11:03:52 INFO web[o.s.s.n.NotificationService] Notification service stopped
2015.12.18 11:03:52 INFO web[o.s.s.d.EmbeddedDatabase] Embedded database stopped
2015.12.18 11:03:52 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener
java.lang.IllegalStateException: One of HTML description or Markdown description must be defined for rule [repository=plsql, key=ComparisonWithBoolean]
at org.sonar.api.server.rule.RulesDefinition$NewRule.validate(RulesDefinition.java:765) ~[sonar-plugin-api-4.5.5.jar:na]
at org.sonar.api.server.rule.RulesDefinition$NewRule.access$900(RulesDefinition.java:569) ~[sonar-plugin-api-4.5.5.jar:na]
at org.sonar.api.server.rule.RulesDefinition$RepositoryImpl.(RulesDefinition.java:508) ~[sonar-plugin-api-4.5.5.jar:na]
at org.sonar.api.server.rule.RulesDefinition$RepositoryImpl.(RulesDefinition.java:498) ~[sonar-plugin-api-4.5.5.jar:na]
at org.sonar.api.server.rule.RulesDefinition$Context.registerRepository(RulesDefinition.java:392) ~[sonar-plugin-api-4.5.5.jar:na]
at org.sonar.api.server.rule.RulesDefinition$Context.access$500(RulesDefinition.java:359) ~[sonar-plugin-api-4.5.5.jar:na]
at org.sonar.api.server.rule.RulesDefinition$NewRepositoryImpl.done(RulesDefinition.java:477) ~[sonar-plugin-api-4.5.5.jar:na]
at org.sonar.plsqlopen.PlSqlRuleRepository.define(PlSqlRuleRepository.java:35) ~[na:na]
at org.sonar.server.rule.RuleDefinitionsLoader.load(RuleDefinitionsLoader.java:51) ~[sonar-server-4.5.5.jar:na]
at org.sonar.server.rule.RegisterRules.start(RegisterRules.java:97) ~[sonar-server-4.5.5.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_71]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_71]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.behaviors.Stored.start(Stored.java:110) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1015) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1008) ~[picocontainer-2.14.3.jar:na]
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:766) ~[picocontainer-2.14.3.jar:na]
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) ~[sonar-plugin-api-4.5.5.jar:na]
at org.sonar.server.platform.ServerComponents$1.doPrivileged(ServerComponents.java:590) ~[sonar-server-4.5.5.jar:na]
at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:43) ~[sonar-server-4.5.5.jar:na]
at org.sonar.server.platform.ServerComponents.executeStartupTasks(ServerComponents.java:586) ~[sonar-server-4.5.5.jar:na]
at org.sonar.server.platform.Platform.executeStartupTasks(Platform.java:126) ~[sonar-server-4.5.5.jar:na]
at org.sonar.server.platform.Platform.startLevel34Containers(Platform.java:122) ~[sonar-server-4.5.5.jar:na]
at org.sonar.server.platform.Platform.doStart(Platform.java:81) ~[sonar-server-4.5.5.jar:na]
at org.sonar.server.platform.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43) ~[sonar-server-4.5.5.jar:na]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) [tomcat-embed-core-7.0.54.jar:7.0.54]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) [tomcat-embed-core-7.0.54.jar:7.0.54]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.54.jar:7.0.54]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) [tomcat-embed-core-7.0.54.jar:7.0.54]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) [tomcat-embed-core-7.0.54.jar:7.0.54]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]
2015.12.18 11:03:54 INFO web[jruby.rack] jruby 1.7.9 (ruby-1.8.7p370) 2013-12-06 87b108a on Java HotSpot(TM) 64-Bit Server VM 1.7.0_71-b14 [Windows 8.1-amd64]
2015.12.18 11:03:54 INFO web[jruby.rack] using a shared (threadsafe!) runtime
2015.12.18 11:04:31 ERROR web[jruby.rack] initialization failed
org.jruby.rack.RackInitializationException: java.lang.NullPointerException
at org.jruby.rack.RackInitializationException.wrap(RackInitializationException.java:31) ~[jruby-rack-1.1.13.2.jar:na]
at org.jruby.rack.RackApplicationFactoryDecorator.init(RackApplicationFactoryDecorator.java:98) ~[jruby-rack-1.1.13.2.jar:na]
at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:50) ~[jruby-rack-1.1.13.2.jar:na]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) [tomcat-embed-core-7.0.54.jar:7.0.54]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) [tomcat-embed-core-7.0.54.jar:7.0.54]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.54.jar:7.0.54]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) [tomcat-embed-core-7.0.54.jar:7.0.54]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) [tomcat-embed-core-7.0.54.jar:7.0.54]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]
Caused by: java.lang.NullPointerException: null
at org.sonar.server.ui.JRubyFacade.get(JRubyFacade.java:84) ~[sonar-server-4.5.5.jar:na]
at org.sonar.server.ui.JRubyFacade.getDatabase(JRubyFacade.java:238) ~[sonar-server-4.5.5.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_71]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_71]
at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:440) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:304) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:52) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.RootNode.interpret(RootNode.java:129) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:95) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:184) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyKernel.evalCommon(RubyKernel.java:1156) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyKernel.eval(RubyKernel.java:1114) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyKernel$INVOKER$s$0$3$eval.call(RubyKernel$INVOKER$s$0$3$eval.gen) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:180) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:296) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.FCallManyArgsNode.interpret(FCallManyArgsNode.java:60) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.IfNode.interpret(IfNode.java:118) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:139) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:182) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:139) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:182) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.AttrAssignOneArgNode.interpret(AttrAssignOneArgNode.java:33) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.IfNode.interpret(IfNode.java:116) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:139) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:182) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.VCallNode.interpret(VCallNode.java:88) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:161) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:190) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyClass.finvoke(RubyClass.java:527) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyBasicObject.send(RubyBasicObject.java:2590) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyKernel.send(RubyKernel.java:2223) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyKernel$INVOKER$s$send.call(RubyKernel$INVOKER$s$send.gen) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:350) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:161) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:190) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:316) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:145) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:154) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallNoArgBlockNode.interpret(CallNoArgBlockNode.java:64) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.RootNode.interpret(RootNode.java:129) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_ROOT(ASTInterpreter.java:121) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.Ruby.runInterpreter(Ruby.java:838) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.Ruby.loadFile(Ruby.java:2727) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.load.ExternalScript.load(ExternalScript.java:66) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.load.LoadService.load(LoadService.java:359) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyKernel.loadCommon(RubyKernel.java:1107) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyKernel.load(RubyKernel.java:1094) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.RubyKernel$INVOKER$s$0$1$load.call(RubyKernel$INVOKER$s$0$1$load.gen) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:210) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:206) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:139) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:182) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:139) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:182) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.ast.RootNode.interpret(RootNode.java:129) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.evaluator.ASTInterpreter.INTERPRET_ROOT(ASTInterpreter.java:121) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.Ruby.evalScriptlet(Ruby.java:419) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.Ruby.evalScriptlet(Ruby.java:396) ~[jruby-complete-1.7.9.jar:na]
at org.jruby.rack.rails.RailsRackApplicationFactory.createApplicationObject(RailsRackApplicationFactory.java:22) ~[jruby-rack-1.1.13.2.jar:na]
at org.jruby.rack.DefaultRackApplicationFactory$1.create(DefaultRackApplicationFactory.java:98) ~[jruby-rack-1.1.13.2.jar:na]
at org.jruby.rack.DefaultRackApplicationFactory$RackApplicationImpl.init(DefaultRackApplicationFactory.java:420) ~[jruby-rack-1.1.13.2.jar:na]
at org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:111) ~[jruby-rack-1.1.13.2.jar:na]
at org.jruby.rack.SharedRackApplicationFactory.doInit(SharedRackApplicationFactory.java:31) ~[jruby-rack-1.1.13.2.jar:na]
at org.jruby.rack.RackApplicationFactoryDecorator.init(RackApplicationFactoryDecorator.java:94) ~[jruby-rack-1.1.13.2.jar:na]
... 10 common frames omitted
2015.12.18 11:04:31 ERROR web[o.a.c.c.StandardContext] Error listenerStart
2015.12.18 11:04:31 ERROR web[o.a.c.c.StandardContext] Context [] startup failed due to previous errors
2015.12.18 11:04:31 ERROR web[o.a.c.l.WebappClassLoader] The web application [] appears to have started a thread named [JRubyJIT-1] but has failed to stop it. This is very likely to create a memory leak.
2015.12.18 11:04:31 ERROR web[o.a.c.l.WebappClassLoader] The web application [] appears to have started a thread named [JRubyJIT-2] but has failed to stop it. This is very likely to create a memory leak.
2015.12.18 11:04:32 INFO web[o.s.s.app.Logging] Web server is started
2015.12.18 11:04:32 INFO web[o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2015.12.18 11:04:32 WARN web[o.s.p.ProcessEntryPoint] Fail to start web
java.lang.IllegalStateException: Webapp did not start
at org.sonar.server.app.EmbeddedTomcat.isReady(EmbeddedTomcat.java:83) ~[sonar-server-4.5.5.jar:na]
at org.sonar.server.app.WebServer.isReady(WebServer.java:45) [sonar-server-4.5.5.jar:na]
at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:80) ~[sonar-process-4.5.5.jar:na]
at org.sonar.server.app.WebServer.main(WebServer.java:65) [sonar-server-4.5.5.jar:na]
2015.12.18 11:04:33 INFO web[o.s.s.app.Logging] Web server is stopped
2015.12.18 11:04:33 INFO sea[o.s.p.StopWatcher] Stopping process
2015.12.18 11:04:33 INFO sea[o.elasticsearch.node] [sonar-1450432954446] stopping ...
2015.12.18 11:04:33 INFO app[o.s.p.m.TerminatorThread] Process[search] is stopping
2015.12.18 11:04:34 INFO sea[o.elasticsearch.node] [sonar-1450432954446] stopped
2015.12.18 11:04:34 INFO sea[o.elasticsearch.node] [sonar-1450432954446] closing ...
2015.12.18 11:04:34 INFO sea[o.elasticsearch.node] [sonar-1450432954446] closed
2015.12.18 11:04:34 INFO app[o.s.p.m.TerminatorThread] Process[search] is stopped
<-- Wrapper Stopped

Thanks you for your help

Source code not detected in multi-module Maven project

Hey Felipe,

First of all, I'd like to thank you for your work! 👍

I have a multi-module Maven project where one of them is fully composed by SQL. Another one is only composed by Java.

After putting my SonarQube analysing the Java part, I wanted to do the same for SQL and I've adopted your plugin for it.

The Java analysis works properly whereas the SQL does not. Am I missing any configuration? Should I explicitly tell your SQL Sonar plugin where to look for the SQL sources?

Regards.

Release 2.0.0

The snapshot is very stable and contains many improvements over the version 1.0. No one should be using 1.0 at this point. There's not reason to delay the release much longer.

Just to have a milestone, let's release 2.0.0 when #10 is closed.

Rule plsql:SameBranch should check only consecutive branches

Considering this code:

if foo.type = 1 then
  do_a_thing();
elsif check_value(foo) then
  go_another_thing();
elsif foo.type = 3 then
  do_a_thing(); -- Issue reported here
end if;

Now, let's suppose that a developer fixed this issue changing the code to this:

if foo.type in (1, 3) then
  do_a_thing();
elsif check_value(foo) then
  go_another_thing();
end if;

Then we have a behavior change and probably a bug, much harded to track. In the original code, when foo.type = 3 the do_a_thing() procedure is only executed when check_value(foo) is false. In the new code, it is executed always.

The safest option to avoid this problem is make the rule only report an issue when the two branches are consecutive, lile:

if foo.type = 1 then
  do_a_thing();
elsif foo.type = 3 then
  do_a_thing(); -- Issue reported here
elsif check_value(foo) then
  go_another_thing();
end if;

Parsing error

Hi, felipebz (thanks for the plugin)

I'm trying to use the plug-in and get parsing errors:

INFO: 3 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for plsqlopen: Sonar way
INFO: Sensor PlsqlSquidSensor [plsqlopen]
INFO: 2 source files to be analyzed
ERROR: Unable to parse file: D:/RevisionPar/GEM y SALUDFAM/PLSQL_GEM/PCK_GEM_SERVICIOS.pck
ERROR: Parse error at line 6809 column 53:

6803: 3200);
6804: lv_tipo_servicio CHAR;
6805: lv_codificacion CHAR;
6806:
6807: BEGIN
6808: SELECT REPLACE(RTRIM(XMLAGG(XMLELEMENT(e, prestacion, ',')
--> .EXTRACT('//text()') ORDER BY lvl DESC),
6810: ','),
6811: ',',
6812: ',') PATH
6813: INTO prestaciones
6814: FROM (SELECT ROWNUM lvl, nmeventoreportado, prestacion
6815: FROM (SELECT nmeventoreportado,

INFO: 2/2 source files have been analyzed
INFO: Sensor PlsqlSquidSensor [plsqlopen] (done) | time=488ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=0ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=16ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
INFO: Calculating CPD for 1 file
INFO: CPD calculation finished
INFO: Analysis report generated in 188ms, dir size=722 KB
INFO: Analysis reports compressed in 31ms, zip size=70 KB
INFO: Analysis report uploaded in 78ms
INFO: ANALYSIS SUCCESSFUL, you can browse https: ...
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https ...
INFO: Task total time: 1.719 s

Colud you help me, please?

Code smell not detected

I'm trying to test this plugin with the following source code:

-- dead-code.sql
begin
  raise my_error;
  log('finished'); -- esse código nunca será executado
end;

This code was extracted from one of the plugin's rules and is classified as code smell, but Sonar does not detect it. Sonar scanner reports que following warn message:

WARN: Missing blame information for the following files:
WARN:   * /sonar-examples/projects/languages/plsql/plsql-sonar-runner/src/dead-code.sql

This test was ran with...

  1. sonarqube 6.0
  2. sonar-scanner 2.6.1

Parsing with space between relation operators

There is this weird thing i found with relation operators. Space inside a 'greater than equal to' operator or any double symbol relational operator is still valid and works fine with oracle. :|

For example,
select 'hello' from dual where 1 > = 1 is still valid and will work as a code but our parser would fail.

I am not sure whether this has to be fixed, but sharing the info.

Support type as column name in ANCHORED_DATATYPE

Hi,

we have tables with column name 'type' which leads to parsing errors when used in type definitions like:

create procedure test as
v_blah tab.name%type;
begin
  null;
end;

I think the problem is in the definition of the MEMBER_EXPRESSION which explicitly disallows the usage of the 'type' keyword. But simply removing it leads to a lot of problems in other places

b.rule(MEMBER_EXPRESSION).is(
                MULTIPLE_VALUE_EXPRESSION,
                b.zeroOrMore(
                        b.firstOf(DOT, MOD, REMOTE),
                        b.nextNot(ROWTYPE),
  --->                b.nextNot(TYPE),
                        b.firstOf(
                                IDENTIFIER_NAME,
                                COUNT,
                                ROWCOUNT,
                                BULK_ROWCOUNT,
                                FIRST,
                                LAST,
                                LIMIT,
                                NEXT,
                                PRIOR,
                                EXISTS,
                                FOUND,
                                NOTFOUND,
                                ISOPEN,
                                DELETE)
                        )).skipIfOneChild();

image

So in need some advice to fix this issue ;)

Thanks.

Bye Peter

Duplicated lines

Hi,

First of all, thx for this plugin.
We are currently testing this plugin for sonar integration and it sounds good.

I'm able to fill some of the metrics (bugs ; code smells ; coverage ; unit tests). Is this plugin able to detect duplicate code ? I read Unit tests and ITs to find examples and it seems that it only checks that duplication is zero.
assertThat(getMeasureAsDouble(PROJECT_KEY, "duplicated_lines")).isZero();

Do you have an example which gives a non zero metric for duplication ?

BR

Custom Rule: Not a valid line offset for pointer

Hi!

I've implemented a very simple custom rule based on snapshot version 2.2.0 (with version 2.1.0 this rule works):

@Override
public void init() {
    subscribeTo(GenericTokenType.EOF);
}

@Override
public void visitNode(AstNode node) {
    if (!node.getPreviousAstNode().is(PlSqlGrammar.EXECUTE_PLSQL_BUFFER)) {
        addIssue(node, "There must be a slash at the end of file");
    }
}

This is the test file content:

create or replace package body Test is

end Test;

When I execute an analysis with SonarQube scanner I get the following exception:

ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: 12 is not a valid line offset for pointer. File plsql/Test.pkb has 9 character(s) at line 3
    at org.sonar.api.internal.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:312)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:246)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:262)
    at org.sonar.plsqlopen.squid.PlSqlAstScanner.newLocation(PlSqlAstScanner.java:189)
    at org.sonar.plsqlopen.squid.PlSqlAstScanner.saveIssues(PlSqlAstScanner.java:172)
    at org.sonar.plsqlopen.squid.PlSqlAstScanner.scanFile(PlSqlAstScanner.java:142)
    at org.sonar.plsqlopen.PlSqlSquidSensor.execute(PlSqlSquidSensor.java:101)
    at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
    at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:302)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:297)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:271)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
    at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Do I have to change my rule for version 2.2.0 or do you intend to change the relevant source code?

Thank you!

surefire xml unit test report

Hi,

I'm using the plugin to get sonar quality gates measures on my code but I'm running unit tests with the utplsql maven plugin that gives me surefire reports with the test results, can this test results be incorporated into sonar using your plugin and the sonar.junit.reportsPath=target/surfire-reports? I have been trying to add them with no success.

Thanks

Parsing file with maven placeholders

We are currently installing our sources with Liquibase via Maven.
In some of our files ( grants, synonyms mostly) we use palceholders so we can dynamicly change the statement.

Now in Jenkins when analyzing the sources, we get errors like this:

[Build develop] ERROR: Parse error at line 1 column 27:
[Build develop] 
[Build develop]   -->  grant all on <table> to ${project_user};

Is there a way to work around this ?

Regards,

Kim

False positive in ColumnsShouldHaveTableName

This check should not report an issue if the selected value is a known variable in the current scope.

DECLARE
  MY_VAR NUMBER;
BEGIN
  INSERT INTO TAB (FOO, BAR, BAZ)
    (SELECT OTHER.FOO,
            MY_VAR, -- an issue is reported here
            OTHER.BAZ 
       FROM OTHER, OTHER2);
END;

This change can create some false negatives: if there's a column MY_VAR in the table OTHER or OTHER2, the issue wouldn't be reported.

But currently we don't have any information about the table structure, so we should try to avoid false positives with the information we know.

procedure definition in .pkb and .pks are counted as code duplication

Hi,

when creating a procedure definition in a PL/SQL package the signature needs to be defined in the package specification(.pks) and in the package body(.pkb).

It seems like this is counted as code duplication which does not seem correct to me since it can't be avoided.
Is there anything we can do about that?

Thanks!

parse error on semicolon character

Hi,

When I try to analyse our plsql codebase with scanner, it gives us error on ";" character. If I remove all ";" characters from source code the scan completes without any problem but in this case plugin doesn't catch any error.

Steps to reproduce:

  • Install Sonarqube 5.6.4
  • Download sonar-plsql-open-plugin\target\sonar-plsql-open-plugin-1.0-SNAPSHOT.jar file and add to SONARQUBE_HOME/extensions/plugins directory and restart sonar. I checked also /updatecenter to verify installation.
  • create a sonar-project.properties with config sonar.language=plsqlopen
  • install sonar-scanner-2.8
  • run sonar-scanner on plsql code and it gives error:
ERROR: Unable to parse file: /home/kodgemisi/PLSQL/EXAMPLE.sql
ERROR: Parse error at line 2 column 7:
1: DROP MATERIALIZED VIEW EXAMPLE.EXAMPLE;
-->  CREATE MATERIALIZED VIEW EXAMPLE.EXAMPLE

How can I resolve this issue?

Release new version to address compatibility with SonarQube 7.3

Trying to reproduce #77, I found out that SonarQube >=7.3 isn't executing the custom rules with the version 2.1.0 of this plugin.

This happens because SQ 7.3 is more strict about the annotations used to indicate what classes should be loaded in the SonarQube Scanner side. It now ignores the @BatchSide annotation in the CustomPlSqlRulesDefinition class (here) and the custom rules aren't loaded anymore.

This was already fixed in master, replacing the @BatchSide by the @ScannerSide annotation (source).

The options are:

  • Since 2.1.0 is compatible with SQ 5.6, try to release a 2.1.1 version with the @BatchSide (SQ 5.6) and @ScannerSide (SQ 6.0+). Need to check if the new annotation won't cause any problem with SQ 5.6.
  • Release version 2.2.0 based in 7013f58, compatible only with SQ 6.7+.

Possible false positive for Rule InsertWithoutColumns

Hi,

we often use code like

insert into sometable values rec_sometable;

where rec_sometable is defined as sometable%rowtype;

I think in this cases it's ok to not list every single column in the insert statement because it's strong typed.

What do you think about that?

PS: Bonus Use-Case:

for r_t in (select * from mytable where a=1) loop
    begin
        r_t.b := 7;
        insert into mytable values r_t;
    end;
end loop;

... probably harder to track ....

Thx! Bye Peter

Documentation for Oracle Forms metadata support

Since 0c5425c the plugin supports a "metadata" file, specified in the sonar.plsql.forms.metadata parameter, See a sample here: https://github.com/felipebz/sonar-plsql/blob/master/plsql-frontend/src/test/resources/metadata/metadata.json

With this information, is possible to create checks to validate indirect references to Oracle Forms objects, like: https://github.com/felipebz/sonar-plsql/blob/master/plsql-checks/src/main/java/org/sonar/plsqlopen/checks/InvalidReferenceToObjectCheck.java

The format of the metadata file should be documented and a sample project could be added to the source code.

Add parameter to rule UnusedVariable to ignore certain methods

Hi,

we use certain methods in PL/SQL packages as kind of public API for a calling program. These have the same signature in all packages. Like:

function on_message_result
    (
        p_msg_id        in  integer,
        p_msg_result    in  integer
    )
    return integer
    as
    begin
        ...;
    end;

Often not all of the paramters are actually used and so lead to warning in Sonar.

I would like to add a parameter to this rule which allows to specify a list of method names for which this rule should be ignored. What you think of that?

Otherwise I would implement that as custom rule on our side.

Thanks!

Bye, Peter

License

Hi,

Could you please help me on the below

  1. Is it Opensource?
  2. Can we use this plugin with SonarQube Community Edition.
  3. If use this with community edition do we face any legal issues with sonarqube team.

Thanks in advance.

Thanks
TK

Incorrect handling of order by in queries using set operators

Test case:

select 1 value from dual
union
select 2 from dual
order by value

This query is parsed as:

(select 1 value from dual)
union
(select 2 from dual
order by value)

image

But it is equivalent to:

(select 1 value from dual
union
select 2 from dual)
order by value

The parser should be fixed to avoid false positives in coding rules.

Add OVERRIDING MEMBER FUNCTION in CREATE TYPE BODY syntax

This code should be parsed without errors:

CREATE TYPE student_typ UNDER person_typ (
   dept_id NUMBER,
   major VARCHAR2(30),
   OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2)
   NOT FINAL;
/
CREATE TYPE BODY student_typ AS
 OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2 IS
 BEGIN
    RETURN 'Major: ' || major ;
 END;
END;
/

(originally reported on #8)

Fix parsing errors of PL/JSON project

Add support for 'any' Syntax

possible Test in WhereClauseTest.java

    @Test
    public void matchesAny() {
    	assertThat(p).matches("where data = any (select 1,2,3 from dual)");
    }

I guess it should be some kind of new Expression in PlSqlGrammar.java but I was not able to figure it out myself ...

Add TABLESPACE clause to CREATE TABLE sentence

Hello,

¿Could it be possible add the TABLESPACE clause as the next example?
CREATE TABLE hr.admin_emp
(
         empno    NUMBER(5) PRIMARY KEY,
         ename    VARCHAR2(15) NOT NULL,
         ssn          NUMBER(9) ENCRYPT,
         job          VARCHAR2(10),
         mgr         NUMBER(5),
         hiredate  DATE DEFAULT (sysdate),
         photo      BLOB,
         sal           NUMBER(7,2),
         hrly_rate NUMBER(7,2) GENERATED ALWAYS AS (sal/2080),
         comm     NUMBER(7,2),
         deptno   NUMBER(3) NOT NULL CONSTRAINT admin_dept_fkey REFERENCES hr.departments (department_id)
)
TABLESPACE admin_tbs;

Thank you,
Best regards.
Julio Renedo

Parse Issue

Hi Felipe,

I'm trying to use your plugin on a set of sql files.

When i'm launching sonar-scanner i've "ERROR: Unable to parse file" on every file.

I'm using Sonar 5.6 and last build of your plugin (sonar-plsql-open-plugin-1.0-SNAPSHOT.jar)

i've tried to launch the scanner using -X but there are no debug messages.

Some logs:
(I've masked some file and tables names)

....
INFO: Sensor PHPUnit Sensor (done) | time=2ms
INFO: Sensor PlSqlSquidSensor
INFO: 78 source files to be analyzed
ERROR: Unable to parse file: /SQL/etl_00_.sql
ERROR: Parse error at line 1 column 0:

--> TRUNCATE .CONI_T;
2: TRUNCATE .JOIPRC;
3: TRUNCATE .PCASX;
4: TRUNCATE .PCBRI;
5: TRUNCATE .POL;
6: TRUNCATE .POLRIZZO;

ERROR: Unable to parse file: /SQL/etl_01_.sql
ERROR: Parse error at line 1 column 0:

--> TRUNCATE .CON;
2: TRUNCATE .JOIC;
3: TRUNCATE .PCASX;
4: TRUNCATE .PCBI;
5: TRUNCATE .POL;
6: TRUNCATE .POLIZZO;

ERROR: Unable to parse file: /SQL/etl_02_.sql
ERROR: Parse error at line 1 column 0:

--> UPDATE <masked>.<masked> AS SOG
2: JOIN <masked>.PSSI<masked>S_CB AS
3: SET

.....

TY for your help.

Allow "REF" to be used as Column Name

We have several tables with columns named "ref" which is working, but the sonar-plsql parser throws a parsing error.

Testcase aded to CreateViewTest.java:

    @Test
    public void matchesDecodeWithRefColumn() {
    	assertThat(p).matches("create or replace view foo as select decode(bp.ref,null,sp.name1,bp.name1) p_name1 from bp, sp;");
    }

produces

org.sonar.sslr.tests.ParsingResultComparisonFailure: Rule 'CREATE_VIEW' should match:
create or replace view foo as select decode(bp.ref,null,sp.name1,bp.name1) p_name1 from bp, sp;
Parse error at line 1 column 47:

  -->  create or replace view foo as select decode(bp.ref,null,sp.name1,bp.name1) p_name1 from bp, sp;EOF

	at org.sonar.sslr.tests.ParserAssert.matches(ParserAssert.java:72)
	at org.sonar.plugins.plsqlopen.api.units.CreateViewTest.matchesDecodeWithRefColumn(CreateViewTest.java:132)

I tried marking org.sonar.plugins.plsqlopen.api.PlSqlKeyword.REF as non reserved keyword which resolves above error but let's fail

org.sonar.plugins.plsqlopen.api.declarations.VariableDeclarationTest.matchesRefObjectDeclaration()

I tried to look into that but was not able to resolve that failing test, Any suggestions or feddback would be very welcome.

Thanks,
bye Peter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.