Some compilers have options for detecting dead code, so you may already have the right tools. Please keep in mind that there will be situations when the code is dead and you cannot tell using static source code analysis.
if a = 1 move 'error' to out-message end-if
If a never be 1, then this is dead code. Static analysis of the source code may not find more complex instances of this scenario, especially if the value of a occurs outside the analyzed program - possibly the database.
A transparent scan of the static source code analysis tools on the list on Wikipedia shows that commercial products are expensive (in thousands of euros). Open source tools do not appear to provide significant COBOL coverage. You might want to test them yourself, because I admit that I did not make a thorough assessment, but simply looked at their documentation.
COBOL is a difficult language to parse.
source share