Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create rule S6745 #3007

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions rules/S6745/java/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"title": "Detection of the Local Butterfly object dependencies anti-pattern",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
],
"defaultSeverity": "Info",
"ruleSpecification": "RSPEC-6745",
"sqKey": "S6745",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "infeasible",
"code": {
"impacts": {
"MAINTAINABILITY": "LOW",
"RELIABILITY": "LOW",
"SECURITY": "LOW"
},
"attribute": "CONVENTIONAL"
}
}
25 changes: 25 additions & 0 deletions rules/S6745/java/rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Local Butterfly is a structural anti-pattern for a component with many immediate dependents.
The scope of dependents is limited to immediate dependents that directly access, use, reference, or contain the Local Butterfly.

These issues arise from the tight coupling between the component and its dependents, which can lead to a lack of flexibility, maintainability, and scalability in the system.

== Why is this an issue?

Any changes or modifications to the component with a large number of immediate dependents may require updates in multiple places.
This can make it challenging to introduce new features or make changes without impacting the entire system.
The lack of flexibility can hinder adapting to evolving requirements or business needs.

The tight coupling between the component and its immediate dependents can make the codebase more complex and harder to understand.
This can lead to difficulties in maintaining and debugging the system.
When a change is required, it may be challenging to identify all the affected areas, increasing the risk of introducing bugs or unintended side effects.

As the number of immediate dependents increases, the component's scalability can be compromised.

Only basic Interfaces or utility classes should be allowed to become Local Butterflies.

== How to fix it

To mitigate these issues, it is recommended to consider alternative design patterns that promote loose coupling and separation of concerns.
By decoupling the component from its immediate dependents, such as using interfaces or abstractions, it becomes easier to modify, maintain, and test the system.
This promotes better flexibility, maintainability, and scalability in the long run.

2 changes: 2 additions & 0 deletions rules/S6745/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}