RETURN should be used to terminate a database query or a stored procedure

Software ResiliencyCode Reliability

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.

Business Impacts

It is recommended to use the RETURN statement as the last instruction since it could be a risky move from a business standpoint.

One of the risks include decrease in Productivity if the RETURN statement was not used as a last instruction. 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 verifies that the last instruction of a procedure or a function should be return. Depending on specific thresholds CAST has set to ensure that not using RETURN is not a too frequent pattern, Highlight counts penalty points to the given scanned file.

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