File tree Expand file tree Collapse file tree
.codeql/custom-queries/09-cryptographic-security Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 * @problem.severity warning
99 * @tags maintainability
1010 * error-handling
11+ * @autofix
1112 */
1213
1314import java
1415
16+ import semmle.code.java.Autofix
17+
1518from CatchClause cc
1619where
17- // Il blocco catch è vuoto (non contiene statement)
1820 cc .getBlock ( ) .getNumStmt ( ) = 0 and
19-
20- // Oppure contiene solo commenti (blocco con solo whitespace/commenti)
2121 not exists ( Stmt s | s .getParent ( ) = cc .getBlock ( ) ) and
22-
23- // Esclude catch di InterruptedException (spesso legittimo lasciarli vuoti)
2422 not cc .getVariable ( ) .getType ( ) .( RefType ) .hasQualifiedName ( "java.lang" , "InterruptedException" )
25-
26- select cc , "Blocco catch vuoto - potrebbe nascondere errori importanti"
23+ select cc , "Blocco catch vuoto - potrebbe nascondere errori importanti" ,
24+ Autofix :: insertAfter ( cc . getBlock ( ) , "System.err.println(\"Exception caught: \" + " + cc . getVariable ( ) . getName ( ) + ");" )
2725
You can’t perform that action at this time.
0 commit comments