Shared naming conventions make it possible for a team to collaborate efficiently. Following the established convention of single-letter type
parameter names helps users and maintainers of your code quickly see the difference between a type parameter and a poorly named class.
This rule check that all type parameter names match a provided regular expression. The following code snippets use the default regular
expression.
Noncompliant code example
With the default regular expression ^[A-Z]$
:
public class MyClass<TYPE> { // Noncompliant
func method<TYPE>(t : TYPE) { // Noncompliant
}
}
Compliant solution
public class MyClass<T> {
func method<T>(t : T) {
}
}