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

[RFC] Java Cleanup - Errors & Warnings #3194

Open
1 of 36 tasks
currantw opened this issue Dec 5, 2024 · 1 comment
Open
1 of 36 tasks

[RFC] Java Cleanup - Errors & Warnings #3194

currantw opened this issue Dec 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@currantw
Copy link
Contributor

currantw commented Dec 5, 2024

Is your feature request related to a problem?

The code inspections tool in IntelliJ IDEA generates thousands of warnings and errors when compiling this project. These range from trivial code quality warnings (e.g. unused imports or unnecessary toString calls) to more serious errors (e.g. for deprecated APIs). While some of these will be difficult to fix, many are trivial to resolve: we should take advantage of these by addressing them gradually in order to improve quality and performance.

What solution would you like?

We should gradually address these errors and warnings, starting with those that are either trivial to fix (i.e. they can be resolved with a batch "Quick Fix") or higher severity (i.e. they could cause bugs or other issues). The lists below represent a rough grouping of some of the errors and warnings that I think it would be easiest and/or most valuable to address.

Higher severity or possible bugs:

  • Deprecated API usage (983 warnings)
  • Usage of API marked for removal (66 errors)
  • Optional.get() is called without isPresent() check (11 warnings)
  • String comparison with == instead of equals() (2 warnings)
  • Wrong package statement (24 errors)
  • JUnit 5 obselete assertions (52 warnings)

Trivial to fix:

  • Field may be final (279 warnings) - Mark Constant Fields as final #3191
  • size == 0 can be replaced with isEmpty (61 warnings)
  • Unnecessary call to toString() (102 warnings)
  • Lombok @Getter may be used (203 warnings)
  • Lombok @Setter may be used (47 warnings)
  • Redundant String operation (21 warnings)
  • Redundant type cast (71 warnings)
  • Stream API call chain can be simplified (27 warnings)
  • Unnecessarily escaped character (22 warnings)
  • Misordered assertEquals() arguments (131 warnings)
  • Simplifiable assertion (164 warnings)
  • Unused assignment (25 warnings)
  • Wrapper type may be primitive (35 warnings)
  • String.equals() can be replaced with String.isEmpty() (5 warnings)
  • Redundant call to String.format() (8 warnings)
  • Redundant local variable (35 warnings)
  • Redundant throws clause (190 warnings)
  • Declaration can have final modifier (382 warnings)
  • Statement can be replaced with enhanced switch (59 warnings)
  • Text block can be used (193 warnings)
  • Class can be record class (58 warnings)
  • Pattern variable can be used (107 warnings)
  • SequencedCollection method (e.g. getFirst()) can be used (348 warnings)
  • for loop can be replaced with enhanced for loop (11 warnings)
  • Raw use of parametrized class (207 warnings)
  • Explicit type can be replaced with <> (98 warnings)
  • Anonymous type can be replaced with lambda (4 warnings)
  • Lambda can be replaced with method reference (37 warnings)
  • Statement lambda can be replaced with expression lambda (45 warnings)
  • if can be replaced with switch (21 warnings)

What alternatives have you considered?

We could ignore these errors completely, or ignore some of them. We could choose to address different errors and/or prioritize them differently.

Do you have any additional context?

None.

@currantw currantw added enhancement New feature or request untriaged labels Dec 5, 2024
@YANG-DB YANG-DB removed the untriaged label Dec 6, 2024
@YANG-DB
Copy link
Member

YANG-DB commented Dec 6, 2024

@currantw thanks - looks great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants