rspec/rules/S3376/rule.adoc

43 lines
1.0 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-01-27 13:42:22 +01:00
Adherence to the standard naming conventions makes your code not only more readable, but more usable. For instance, ``++class FirstAttribute : Attribute++`` can be used simply with ``++First++``, but you must use the full name for ``++class AttributeOne : Attribute++``.
2020-06-30 12:48:39 +02:00
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
This rule raises an issue when classes extending ``++Attribute++``, ``++EventArgs++``, or ``++Exception++``, do not end with their parent class names.
2020-06-30 12:48:39 +02:00
=== Noncompliant code example
2020-06-30 12:48:39 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:48:39 +02:00
----
class AttributeOne : Attribute // Noncompliant
{
}
----
=== Compliant solution
2020-06-30 12:48:39 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:48:39 +02:00
----
class FirstAttribute : Attribute
{
}
----
=== Exceptions
2020-06-30 12:48:39 +02:00
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.
[source,text]
2020-06-30 12:48:39 +02:00
----
class Timeout : Exception // Noncompliant
{
}
class ExtendedTimeout : Timeout // Ignored; doesn't conform to convention, but the direct base doesn't conform either
{
}
----