Skip to content
New issue

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

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

Already on GitHub? # to your account

Green IT rule: Remove non-reachable code #97

Open
skaslay1910 opened this issue Jan 30, 2025 · 4 comments
Open

Green IT rule: Remove non-reachable code #97

skaslay1910 opened this issue Jan 30, 2025 · 4 comments

Comments

@skaslay1910
Copy link

SonarQube as a code profiler has checks to list out unused variable, unused arguments etc but there are no rules to check for unused code.

creedengo could setup a new rule to check for such non-reachable code.
Removing non-reachable code can lead to compiler optimization resulting in less CPU work, less memory usage and thus saving energy consumption

Request to look at it as a Green IT rule.

@dedece35
Copy link
Member

Hi @skaslay1910,
thank you for your great idea.
But :

  • I think this idea isn't specific for java language. thus, can you create your issue in "creedengo-rules-specifications" (this is the rules repository to initiate an idea)
  • I think that the implementation will be difficult because the profiler must check all the code to check if a public method for example is used or not before saying it isn't used. Currently, development tools already do this work (like IntelliJ or Eclipse for example), but I'm surpirsed that SonarQube doesn't tell us this problem.

@skaslay1910
Copy link
Author

Hi
Yes, today intelligent editors for Java, .NET are able to detect and mention it during compilation. But unused code in scripting languages remain undetected.
Have created this issue in "creedengo-rules-specifications" as per my understanding. Will work on figuring out if this issue is detected by SonarQube and how feasible it is to include this rule in creedengo.

@dedece35
Copy link
Member

Hi @skaslay1910, thank you for answer. I've just answered you in the issue green-code-initiative/creedengo-rules-specifications#371 to check if we can have a proof of this idea to confirm this new rule.

@vdebellabre
Copy link

This feature is actually very difficult to do properly and extensively. It is much better to rely on the compilers for this, they have a lot more information and resources than a linter, and many of them already display warnings when appropriate.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants