question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Random code cleanup tasks

See original GitHub issue

Here is a list of code quality improvements/checks that I had in my todo list. I’ve purposely kept them in one issue because we have a lot of issues already. Feel free to add to this or provide feedback.

  • Verify that calls to addListener have a corresponding removeListener

  • Replace Exceptions.printStackTrace traces with java.util.logger

  • Replace numbers with constants that call Insets method and perhaps make them available in a utility class so others can

  • Review methods and arguement naming conventions in StringUtilities - having String string may be undesirable

  • Make a utility class to display DialogDisplayer errors instead of doing this for example:

final NotifyDescriptor nd = new NotifyDescriptor.Message("The provided URL is invalid.", NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(nd);
  • Use StringUtils.isBlank() instead of the following:
!= null && !.isEmpty() everywhere.
isEmptyOrNull()
  • Search replace “,” with SeperatorConstants.COMMA etc. Annotate @nothreadsafe methods - Not currently looking to pursue this throughout the whole codebase - new PRs can try to stick to this style if it helps dev. Integrate JSR-305 ~~* use @notnull etc ~~ SonarQube suggestions - Removed from list as this is covered in other Sonar related tickets.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
arcturus2commented, Feb 10, 2020

Verify that calls to addListener have a corresponding removeListener

I’m interested in the benefit of this. I had a quick google as I was curious as to java best practices, and found the following link which leads me to believe it isn’t a garbage collection related code cleanup. https://coderanch.com/t/344003/java/call-remove-Listeners

Is it for another reason?

@aldebaran30701 actually my motivation was GC/memory/performance related. If I do a search for addListener in the code base I get 179 results and removeListener has just 25 occurrences. I’m uneasy about those numbers. Following on from memory cleanup work a while back, I noticed that if I closed a view like the Attribute Editor, not all of the memory it has been using is released, even if you wait for GC to do it’s thing. I’d like to explore the idea of removing Listeners when the views are closed and see if that helps.

Noted that the memory myth looks busted in their example but our code base in way more complicated and my thought is that we can help Java a bit my removing listeners when we don’t need them. I could be wrong though because I’m not an expert on this topic.

0reactions
github-actions[bot]commented, Dec 8, 2021

This issue is stale because it has been open for 6 months with no activity. Consider reviewing and taking an action on this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clean Code Cleanups - 10Pines | Blog
Code cleanup goes smoothly if we have a strategy. If you start deleting code randomly, it's very likely to leave things out.
Read more >
Code Cleanup: When Your Work Is Undoing Other People's ...
My general advice for such cases is: Do Not Over-cleanup. This whole work is a tradeoff — you'll clean up 100 more lines...
Read more >
Code Cleanup: 7 Simple Daily Steps That Pay off in the End
We'll present seven simple code cleanup tasks that you can perform daily, to keep your codebase readable, easy to navigate, and maintain. We...
Read more >
7 Tips To Write Clean And Better Code in 2020 - GeeksforGeeks
How to Write Clean and Better Code? 1. Use Meaningful Names. You will be writing a lot of names for variables, functions, classes, ......
Read more >
Clean Code Cheat Sheet - planetgeek.ch
Isolated testee: Clear where the failure happened. Isolated test: No dependency between tests (random order). Repeatable. +. No assumed initial state ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found