Merge pull request #5135 from adangel/issue-5132-plsql-tomkytesdespair

[plsql] Fix TomKytesDespair for more complex exception handlers
This commit is contained in:
Juan Martín Sotuyo Dodero
2024-07-26 08:11:15 -03:00
committed by GitHub
3 changed files with 27 additions and 1 deletions

View File

@ -15,6 +15,8 @@ This is a {{ site.pmd.release_type }} release.
### 🚀 New and noteworthy ### 🚀 New and noteworthy
### 🐛 Fixed Issues ### 🐛 Fixed Issues
* plsql-bestpractices
* [#5132](https://github.com/pmd/pmd/issues/5132): \[plsql] TomKytesDespair - exception for more complex exception handler
### 🚨 API Changes ### 🚨 API Changes
* pmd-jsp * pmd-jsp

View File

@ -24,7 +24,9 @@ Rules which enforce generally accepted best practices.
<property name="xpath"> <property name="xpath">
<value> <value>
<![CDATA[ <![CDATA[
//ExceptionHandler[QualifiedName/@Image='OTHERS' and upper-case(Statement/UnlabelledStatement/Expression/@Image)='NULL'] //ExceptionHandler[QualifiedName/@Image='OTHERS']
[count(Statement)=1]
[Statement/UnlabelledStatement/Expression/PrimaryPrefix/Literal/NullLiteral]
]]> ]]>
</value> </value>
</property> </property>

View File

@ -98,4 +98,26 @@ END update_planned_hrs;
/ /
]]></code> ]]></code>
</test-code> </test-code>
<test-code>
<description>#5132 [plsql] TomKytesDespair - exception for more complex exception handler</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
create or replace procedure x
is
v_cursor number;
begin
v_cursor := DBMS_SQL.open_cursor;
dbms_output.put_line('Blah');
exception
WHEN OTHERS THEN
IF DBMS_SQL.is_open(v_cursor) THEN
DBMS_SQL.close_cursor(v_cursor);
END IF;
DBMS_OUTPUT.Put_Line('Blah');
DBMS_OUTPUT.Put_Line(SQLERRM);
end;
/
]]></code>
</test-code>
</test-data> </test-data>