rspec/rules/S118/java/rule.adoc

71 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Sharing some naming conventions is a key point to make it possible for a team to efficiently collaborate. This rule allows to check that all ``++abstract++`` class names match a provided regular expression. If a non-abstract class match the regular expression, an issue is raised to suggest to either make it abstract or to rename it.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
With the default regular expression: ``++^Abstract[A-Z][a-zA-Z0-9]*$++``:
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
abstract class MyClass { // Noncompliant
}
class AbstractLikeClass { // Noncompliant
}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
abstract class AbstractClass {
}
class LikeClass {
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Rename this abstract class name to match the regular expression ${format}
=== Parameters
.format
****
_String_
----
^Abstract[A-Z][a-zA-Z0-9]*$
----
Regular expression used to check the abstract class names against.
****
'''
== Comments And Links
(visible only on this page)
=== on 8 May 2013, 10:15:22 Freddy Mallet wrote:
Dedicated issue message when the regular expression matches a class name which is not abstract :
Make this class abstract or rename it, since it matches the regular expression ${format}
=== on 20 May 2013, 12:08:29 Fabrice Bellingard wrote:
Implementation: \http://jira.codehaus.org/browse/SONARJAVA-147
endif::env-github,rspecator-view[]