A Return Statement in the middle of a command makes it unreadable

Software ResiliencyProgramming Best Practices

Why you should care

The RETURN statement is useful as it terminates a query, stored procedure or batch.

When used in a stored procedure, the RETURN statement specifies an integer value to return to the calling application, batch, or procedure. If no value is specified then the stored procedure returns the value to 0. None of the statements in a stored procedure are executed after the RETURN statement is executed.

Having a RETURN statement in the middle of the procedure or function results in the values of the procedure or function, after the statement, to not be returned and executed.

Business Impacts

Having the RETURN statement in the middle of the command makes rest of the code unproductive. Lack of a RETURN statement would cause the code to function improperly and result in a loss of time.

Production Risk
5362

How we detect

This code insight ensures that the return statement should be at the end of a procedure or function should always be the last instruction.

5362

About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.

See featuresHow it works