rspec/rules/S3376/rule.adoc

36 lines
984 B
Plaintext
Raw Normal View History

2020-06-30 12:48:39 +02:00
Adherence to the standard naming conventions makes your code not only more readable, but more usable. For instance, <code>class FirstAttribute : Attribute</code> can be used simply with <code>First</code>, but you must use the full name for <code>class AttributeOne : Attribute</code>.
This rule raises an issue when classes extending <code>Attribute</code>, <code>EventArgs</code>, or <code>Exception</code>, do not end with their parent class names.
== Noncompliant Code Example
----
class AttributeOne : Attribute // Noncompliant
{
}
----
== Compliant Solution
----
class FirstAttribute : Attribute
{
}
----
== Exceptions
If a class' direct base class doesn't follow the convention, then no issue is reported on the class itself, regardless of whether or not it conforms to the convention.
----
class Timeout : Exception // Noncompliant
{
}
class ExtendedTimeout : Timeout // Ignored; doesn't conform to convention, but the direct base doesn't conform either
{
}
----