rspec/rules/S3756/java/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

50 lines
1.1 KiB
Plaintext

== Why is this an issue?
A cleanly coded web application will have a clear separation of concerns, with business logic in the ``++@Service++`` layer, and communication with other systems in the data access layer.
To help enforce such a separation of concerns, this rule raises an issue when a ``++@Service++`` class has ``++RestTemplate++``, ``++JmsTemplate++``, ``++WebServiceTemplate++``, ``++JdbcTemplate++``, or ``++DataSource++`` member.
=== Noncompliant code example
[source,java]
----
@Service ("greetingmanager")
public class GreetingManagerImpl implements GreetingManager
{
@Autowired
DataSource ds; // Noncompliant
----
=== Compliant solution
[source,java]
----
@Service ("greetingmanager")
public class GreetingManagerImpl implements GreetingManager
{
@Autowired
GreetingDao gdao; // DataSource and its use have been moved here
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Move this "xxTypexx" member and its use to a DAO class.
=== Highlighting
member declaration
endif::env-github,rspecator-view[]