Method is used in expression but has no ReturnType in definition.

Noncompliant Code Example

ClassMethod foo()
{
    Quit "1"
}

ClassMethod bar()
{
    #Dim str As %String = ..foo()
    Write !,str
}

Compliant Solution

ClassMethod foo() As %String
{
    Quit "1"
}

ClassMethod bar()
{
    #Dim str As %String = ..foo()
    Write !,str
}

Detects when a method argument is passed by reference but is never assigned in the body of the method.

This either means that this argument does not need to be passed by reference, or that the code forgets to assign a value to it.

A class with empty methods and/or the methods are declared abstract, should be abstract:

Classes with only empty class declarations, as in:

    Class MyUtilityClass
    {
    ClassMethod m1() { }
    ClassMethod m2() [ abstract ] { /* ... */ }
    }

are often "utility classes", which have no other purpose than to offer a set of methods for other classes to use.

Such classes can be made abstract; if they are not, it is possible to instantiate them using:

You should avoid legacy versions of if, else and for, and use the most modern format which uses curly braces. Below is explained the reason.

A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the class is doing too many things.

Noncompliant Code Example

The following code snippet illustrates this rule with a maximum number of 10 parameters:

A long property list can indicate that a new structure should be created to wrap the numerous properties or that the class is doing too many things.

Noncompliant Code Example

The following code snippet illustrates this rule with a maximum number of 10 properties:

This check retrieves the number of lines in a given method and checks that it is less than, or equal to, a given threshold. Note that the opening and closing braces are taken into account, but the method declaration is not.

The default value is 50.

Consider this code example:

    if (condition) {
        return value1
    } else {
        do something
        do somethingElse
        etc
        etc
    }

Since the if block exits unconditionally, the else may be pruned and the code then becomes:

It is common to see code such as this:

    try {
        // very large block of code here
    } catch (e) {
        // handle exception
    }

This, however, is often a misdesign: in all the statements inside the try block, it frequently happens that only one or two actually throw an exception.

It is therefore advised, both for readability and understandability, to keep try blocks as small and self-contained as possible.

This rule checks that a given class has a number of methods which is less than, or equal to, a configurable threshold. A class with too many methods is often an indication that this class needs to be refactored into several, smaller classes.

Note that class methods are not accounted for.

Pages