Apex Batch and PMD rule EmptyStatementBlock

apexpmd

Does anyone know is there any option how to fix this PMD rule:

EmptyStatementBlock

in case when the error/violations/rule is reported for:

global override void finish(Database.BatchableContext bc) { }

I am pretty new in Salesforce so I am afraid to add or change some things related to batch because of possible code breaking.

Thanks in advance!

Best Answer

Add the following annotation to your code:

@SuppressWarnings('PMD.EmptyStatementBlock')

Example:

@SuppressWarnings('PMD.EmptyStatementBlock')
public override void finish(Database.BatchableContext bc) { }

This will disable the warning only for that method.

Note that public should generally be used for interface methods, unless you're making a Managed Package that needs this method to be global. Very few classes need global, and should not be marked as such unless necessary (e.g. WebService methods, @RemoteAction methods for iframe Visualforce pages, etc).

Related Topic