Use of a macro as a statement

CachéQuality release 
1.0.0
Id 
OS0028
Rule type 
Severity 

Major

Major
SQALE characteristic 
  • Maintainability
    • Understandability
Tags 
coding-guidelines, confusing, maintainability
Remediation function 
Constant/issue
Remediation cost 
10min

ObjectScript allows to use macros as statement, as in:

    Method m()
    {
        $$$SOMETHING
    }

or even:

    Method m()
    {
        $$$SOMETHING(with, arguments)
    }

Here, SOMETHING is a macro. The problem is that a macro can expand to anything; for instance (for the argumentless version):

    // Returns a value unconditionally
    #define SOMETHING return ""
    // Performs an action depending on a condition
    #define SOMETHING if (condition) do x else do y
    // Returns a value depending on a condition
    #define SOMETHING quit:somecondition someValue
    // etc etc

This requires users unfamiliar with the code to lookup the contents of the macro in order to understand the code.

It is therefore advised to avoid using macros in code for readability reasons.