Skip to content

Files

Latest commit

 

History

History
42 lines (28 loc) · 995 Bytes

OneTopLevelClass.md

File metadata and controls

42 lines (28 loc) · 995 Bytes

Pattern: Top-level class not in separate source file

Issue: -

Description

Each top-level class should reside in a source file of its own to avoid any confusion or misunderstanding. If file doesn't contain public class, enum or interface, top-level type is the first type in file.

Default configuration

<module name="OneTopLevelClass"/>

Examples

An example of code with violations:

public class Foo{
    //methods
}

class Foo2{
    //methods
}

An example of code without violations:

public class Foo{
    //methods
}

Further Reading