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

[EC4][Java] Rule is not applicable to Java #233

Closed
cyChop opened this issue Oct 11, 2023 · 7 comments · Fixed by #243
Closed

[EC4][Java] Rule is not applicable to Java #233

cyChop opened this issue Oct 11, 2023 · 7 comments · Fixed by #243

Comments

@cyChop
Copy link
Contributor

cyChop commented Oct 11, 2023

Describe the bug
The rule "avoid global variables" is not applicable to Java.

The history: the first rules were inspired by web best practices, and transposed to other languages without analysis due to lack of time. This shows in the description of this rule, which shows JS.

Scope is not an issue in Java, and constants are a best practice for readability and memory optimization. EC4 is not applicable to Java and should be removed.

@utarwyn
Copy link
Member

utarwyn commented Oct 20, 2023

I agree that this rule should be discussed, it seems not revelant in Java.
I would even say that this rule is not 100% applicable in JavaScript, the gain in terms of performance/eco-design seems really small. It is a bad practice in general (for security reasons for example), variables should be scoped accordingly.

And I no longer see the rule in the latest version of best practices repo/book?

Resources:

@diyfr
Copy link

diyfr commented Oct 20, 2023

ecocode-java:EC4 conflict with java:S1192

@cvgaviao
Copy link

cvgaviao commented Nov 8, 2023

Is it is not applicable for Java at all. and I almost freak out after I saw that the number of issues of our project have increased from 10 to 310 from one day to another because of it, plus EC2 and EC75 :)

@dedece35
Copy link
Member

dedece35 commented Nov 8, 2023

Hi @cyChop, @utarwyn, @diyfr, @cvgaviao,
I agree with you on EC4. Please feel free to contribute with a PR to make this rule deprecated for Java language. For this, please make followed tasks :

  • update RULES.md to update Java pictogram and explain deprecation
  • update CHANGELOG.md to explain deprecation
  • delete Java rule implementation and tests on ecocode repository
  • delete Java test implementation on ecocode-java-test-project repository

Regarding EC2 rule, sorry, I don't agree. Please check refactoring work in issue #216 and associated PR #222.
Unfortunately, this work is not released yet (see CHANGELOG.md) but soon.

Regarding EC75, sorry again, I don't agree. For me it has been a good practice since a long time. Maybe now, with JVM upgrades, this rule could be deprecated. If it is, please could you give us documentation on this point, @cvgaviao, please ?

But if you want to discuss about EC2 and EC75, please open a new issue for each, if you don't agree with my comments above. Thank you :p !

@diyfr
Copy link

diyfr commented Nov 9, 2023

Hello @dedece35, you validate the test files said "COMPLIANT" with classic sonar rules to avoid conflict ?

@cyChop
Copy link
Contributor Author

cyChop commented Nov 9, 2023

But if you want to discuss about EC2 and EC75, please open a new issue for each, if you don't agree with my comments above. Thank you :p !

I think your mailbox trapped you, because I made an issue for each. I'll quote you on those issues and answer there. :)

@dedece35
Copy link
Member

Hello @dedece35, you validate the test files said "COMPLIANT" with classic sonar rules to avoid conflict ?

Could you give some reference in code to illustrate it, please ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants