Dashboard shows false violation for Metric "Avoid empty catch blocks".
Release | Yes/No |
---|---|
8.3.x |
RDBMS | Yes/No |
---|---|
CSS |
Possible reasons
For SAP/ABAP:
Case 1 artifact has no 'catch' block in the code but is reported as violationg the quality rule: looking at the right tab
Source code violation highlights over two part Declaration and Implementation.
For the default view , you can only see Declaration part highlighted (In Red) which may not contain CATCH Block,
To Check the violation, you need to observe Implementation part (Click next below code view section).
Case 2 artifact has actions between the 'catch' and the 'endtry' but is reported as violationg the quality rule: Investigating the source code
if the source code looks like:
CATCH: cx_a,cx_b,cx_c INTO lcx_exept. RAISE EXCEPTION TYPE zcx_x EXPORTING textid = zcx_x=>no_name.
This is equivalent to
CATCH cx_a. CATCH cx_b. CATCH cx_c INTO lcx_exept. RAISE EXCEPTION TYPE zcx_x EXPORTING textid = zcx_x=>no_name.
Which means that only the last CATCH has actions between the 'catch' and the 'endtry'. Hence, there is 2 violations because of 2 empty catch block
For .Net and C/C++:
- The block is considered as NOT empty for C# (and C/C++) if it contains at least one of the following elements:
* IF
* ELSE
* FOREACH
* WHILE
* SWITCH
* DO
* FOR
* TRY
* CASE
* DEFAULT
* IDENTIFIER
* THROW
* RETURN
Reference webcall:28993