MonkeyProof Coding Standard for MATLAB
Table of Contents
Introduction
1.
Naming conventions
❱
1.1.
Loop iterator naming
1.2.
Negated boolean names
1.3.
Parent / child name redundancy
1.4.
Name shadowing
1.5.
Names to avoid
1.6.
Function names document their use
1.7.
Function name construction
1.8.
Name-value pair casing
1.9.
The 'Test' suffix
1.10.
Name length
1.11.
Descriptive names
1.12.
The 'is' prefix
1.13.
Abbreviations
1.14.
Units in variable names
1.15.
The 'n' prefix
1.16.
Name class object
2.
Layout & comments
❱
2.1.
Comment blocks
2.2.
Indentation guidelines
2.3.
Whitespace guidelines
2.4.
Line length
2.5.
Comments on poorly written code
2.6.
Equals sign alignment
2.7.
Commas in rows
2.8.
Methods/Properties blocks with duplicate attributes
2.9.
Tab characters
2.10.
Properties blocks before methods blocks
2.11.
Help text
2.12.
Correct spelling
2.13.
Align struct definition
2.14.
Constants with end of line comments
3.
Statements & expressions
❱
3.1.
Constant definitions at top
3.2.
Magic numbers
3.3.
Function calls without inputs
3.4.
One statement per line
3.5.
If else
3.6.
Switch otherwise
3.7.
Mixed types in expressions
3.8.
Parentheses in logical expressions
3.9.
Parentheses in mathematical expressions
3.10.
Assert inputs
3.11.
Global variables
3.12.
Constant conditional statements
3.13.
Group struct field definitions
3.14.
Dependencies known
3.15.
Try for exception handling
3.16.
Floating-point comparisons
3.17.
Zero before decimal point
3.18.
Workspace variable ans
3.19.
Debugging functions
3.20.
Elseif else
3.21.
Abstract class instantiation
3.22.
Command syntax
3.23.
Accessing other workspaces
3.24.
Logical indexing
3.25.
Loop vectorization
3.26.
Use switch blocks
3.27.
Variable in one unit
3.28.
Undocumented functions
4.
Higher level rules
❱
4.1.
Complexity
4.2.
Number of function arguments
4.3.
Constructors with single output
4.4.
Scripts
4.5.
Editor warnings
4.6.
Getters and setters
4.7.
Mex-files
4.8.
Nesting depth
4.9.
Repeated code
4.10.
Structure ownership
4.11.
Single responsibility
4.12.
Commented out code
4.13.
Reuse of iterator variables
4.14.
Rewriting existing functions
4.15.
Columns with implicit meaning
4.16.
Nested functions
4.17.
Input parameter dependency
4.18.
Missing methods declarations and implementations
4.19.
Mismatch input and output declarations and implementations
4.20.
First output constructor
4.21.
Iterator variables outside loop
4.22.
More input arguments than expected
4.23.
Superclass property implementation
4.24.
Java dependency
4.25.
Method access permissions
5.
Security
❱
5.1.
Eval-functions
5.2.
Shell escape
5.3.
Security Security Server Certificate Usage
5.4.
Security XML reading
5.5.
Constant variable names
5.6.
Security Username and Password
6.
Release notes
Light
Rust
Coal
Navy
Ayu
MonkeyProof Coding Standard for MATLAB v1.4.0
Security