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

Java - Rules "Avoid returning a JPA Entity in a RestController" #138

Closed
wants to merge 4 commits into from

Conversation

MP-Aubay
Copy link
Contributor

@MP-Aubay MP-Aubay commented Apr 6, 2023

Team : 2 millions

Rule ID incoming (green-code-initiative/ecoCode-challenge#58)

Rule description :
Using persistence Entity in the return of a Rest controler is not energy efficient.
This use induces a multiples unnecessary SQL calls, multiple unused fields serialization, and thus unnecessary calculations by the CPU, RAM usage and network usage.

@MP-Aubay MP-Aubay added java 🏆 challenge2023 🏆 Work done during the ecoCode Challenge labels Apr 6, 2023

methods.stream().filter(methodTree -> {
var returnType = methods.get(0).returnType().symbolType();
var parametrizedTypes = returnType.typeArguments();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: parameterized is missing an e

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also replaced the methods.get(0) by methodTree

@MP-Aubay MP-Aubay marked this pull request as ready for review April 6, 2023 12:17
@MP-Aubay MP-Aubay changed the title [DRAFT] Java - Rules "Avoid returning a JPA Entity in a RestController" Java - Rules "Avoid returning a JPA Entity in a RestController" Apr 6, 2023
@MP-Aubay MP-Aubay self-assigned this Apr 6, 2023
@MP-Aubay MP-Aubay added the 🗃️ rule rule improvment or rule development or bug label Apr 6, 2023
@MP-Aubay
Copy link
Contributor Author

MP-Aubay commented Apr 6, 2023

This feature should not be merge before final rule ID is know and updated in code

@sonarcloud
Copy link

sonarcloud bot commented Apr 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

96.9% 96.9% Coverage
0.0% 0.0% Duplication

@SebastienSurier
Copy link

For now, can we just add a ruleID with a number not already used and add the rule un rules.md file ?
If necessary, we can redo a small refacto to change the naming, when a rule is well defined

@github-actions
Copy link

This PR has been automatically marked as stale because it has no activity for 30 days.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@github-actions github-actions bot added the stale label Jun 25, 2023
@dedece35
Copy link
Member

@github-actions
Copy link

This PR has been automatically marked as stale because it has no activity for 30 days.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@github-actions github-actions bot added the stale label Oct 24, 2023
@dedece35 dedece35 assigned dedece35 and unassigned MP-Aubay Dec 21, 2023
@github-actions github-actions bot removed the stale label Dec 22, 2023
@dedece35
Copy link
Member

dedece35 commented Dec 26, 2023

to discuss in core-team :

  • no scientific paper to prove this rule
  • no measures to prove it's a "green" rule

for me, rule not acceptable like that.
do we refuse this rule ?

@jhertout
Copy link
Contributor

jhertout commented Jan 3, 2024

Hello,

I agree that we don't have enough elements to validate and add this rule in the plugin.

@dedece35
Copy link
Member

dedece35 commented Jan 11, 2024

Hi @MP-Aubay, @natixis-caen, @SebastienSurier, @rducasse

sorry but with implementation is that situation, we can't accept this implementation because :

  • no scientific paper to prove this rule
  • no measures to prove it's a "green" rule

We keep this proposition to measure it when we will have a tool to measure it.
(check RULES.md )

@dedece35 dedece35 closed this Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗃️ rule rule improvment or rule development or bug 🏆 challenge2023 🏆 Work done during the ecoCode Challenge java
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants