Affects PMD Version:
6.47.0
Rule:
UnnecessaryBlock
https://pmd.github.io/latest/pmd_rules_ecmascript_codestyle.html#unnecessaryblock
Description:
Same problem as #4054
PMD reports an unnecessary block for the try/catch, but there's no reason why this should be the case. Further, looking into the generate AST by PMD, it seems to be an issue with handling async/await keywords. In fact, without:

and with it, it shows EmptyStatement instead:

Code Sample demonstrating the issue:
async function run(){
try{
await client.connect()
console.log("Successfully connected to the database")
var server = app.listen(8081, function (){
var host = server.address().hostname
var port = server.address().port
console.log("Example app running at https://%s:%s", host, port)
})
}
catch(err){
console.log(err)
await client.close()
}
}
Expected outcome:
PMD reports a violation at line 2 for the try block, but that seems to be a false positive.
Running PMD through: [Designer]
Affects PMD Version:
6.47.0
Rule:
UnnecessaryBlock
https://pmd.github.io/latest/pmd_rules_ecmascript_codestyle.html#unnecessaryblock
Description:

Same problem as #4054
PMD reports an unnecessary block for the try/catch, but there's no reason why this should be the case. Further, looking into the generate AST by PMD, it seems to be an issue with handling async/await keywords. In fact, without:
and with it, it shows EmptyStatement instead:

Code Sample demonstrating the issue:
Expected outcome:
PMD reports a violation at line 2 for the try block, but that seems to be a false positive.
Running PMD through: [Designer]