rspec/rules/S3282/xml/rule.adoc

62 lines
1.4 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Exclusions for default interceptors can be declared either in xml or as class annotations. Since annotations are more visible to maintainers, they are preferred.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,xml]
2021-04-28 16:49:39 +02:00
----
<assembly-descriptor>
<interceptor-binding>
<ejb-name>MyExcludedClass</ejb-name>
<exclude-default-interceptors>true</exclude-default-interceptors> <!-- Noncompliant -->
<exclude-class-interceptors>true</exclude-class-interceptors> <!-- Noncomopliant -->
<method>
<method-name>doTheThing</method-name>
</method>
</interceptor-binding>
</assembly-descriptor>
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,xml]
2021-04-28 16:49:39 +02:00
----
@ExcludeDefaultInterceptors
public class MyExcludedClass implements MessageListener
{
@ExcludeClassInterceptors
@ExcludeDefaultInterceptors
public void doTheThing() {
// ...
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Move this exclusion into the class as an annotation.
'''
== Comments And Links
(visible only on this page)
=== on 23 Jul 2015, 13:53:27 Ann Campbell wrote:
Rule origin: \https://groups.google.com/forum/#!topic/sonarqube/cYQdBhf00eo
Project is EJB if it contains JEE Beans (any one of javax.ejb.Singleton, MessageDriven, Stateless or Stateful) (@Local/@Remote interfaces are not mandatory)
endif::env-github,rspecator-view[]