rspec/rules/S119/vbnet/rule.adoc
Fred Tingaud 6f24cc0632
Clean rule at root
In some cases, the `rule.adoc` at root of a rule is never included
anywhere and thus is dead code.
It's a maintenance cost by itself, but also it misses opportunities to
inline code that seems used by two documents when in fact only one
document is actually rendered. And this missed opportunity, in turn,
stops us from applying the correct language tag on the code samples.
2023-10-16 16:34:38 +02:00

71 lines
1.7 KiB
Plaintext

== Why is this an issue?
Inconsistent naming conventions can lead to confusion and errors when working in a team. This rule ensures that all generic type parameter names follow a consistent naming convention by checking them against a provided regular expression.
The default configuration follows Microsoft's recommended convention:
* Generic type parameter names must start with an upper case 'T', e.g. T
* The rest of the name should use Pascal casing, starting with an upper case character, e.g. TKey
* Short abbreviations of 2 letters can be capitalized, e.g. TFooID
* Longer abbreviations should be lowercased, e.g. TFooHtml
== How to fix it
To fix this issue, ensure that all generic type parameter names in your code follow the naming convention specified in the regular expression.
=== Code examples
==== Noncompliant code example
With the default parameter value `^T(([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?)?$`:
[source,vbnet,diff-id=1,diff-type=noncompliant]
----
Public Class Foo(Of tkey) ' Noncompliant
End Class
----
==== Compliant solution
[source,vbnet,diff-id=1,diff-type=compliant]
----
Public Class Foo(Of TKey) ' Compliant
End Class
----
== Resources
=== Documentation
* Microsoft Learn - https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/generic-type-parameters[Generic Type Parameters (C# reference)]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Rename "xxx" to match the regular expression: "yyy".
=== Parameters
.format
****
_String_
----
^T(([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?)?$
----
Regular expression used to check the generic type parameter names against.
****
'''
== Comments And Links
(visible only on this page)
endif::env-github,rspecator-view[]