intellij-community icon indicating copy to clipboard operation
intellij-community copied to clipboard

[IDEA-289267] Change highlight to highlight unused code (1/2)

Open Fabrice-TIERCELIN opened this issue 3 years ago • 5 comments

Hi @BasLeijdekkers,

What steps will reproduce the issue?

  1. Go to FileSettings... → EditorInspections
  2. Enable Unnecessary unboxing
  3. Enable Severity: Warning
  4. Add the Integer i = Integer.valueOf(42).intValue(); statement in a Java class

What is the expected result? The intValue method is highlighted as an unused code.

What happens instead? The Integer.valueOf(42) expression is highlighted instead as a standard warning.

Which inspections are concerned?

  1. UnnecessaryUnboxing
  2. RedundantArrayForVarargsCall
  3. BoxingBoxedValue
  4. DuplicateCondition
  5. ExtendsObject
  6. TypeParameterExtendsObject
  7. PointlessNullCheck
  8. ConditionCoveredByFurtherCondition
  9. RedundantLambdaParameterType
  10. MeaninglessRecordAnnotation
  11. UnnecessaryThis
  12. RedundantMethodOverride

Which inspections already work like this?

  1. FinalPrivateMethodInspection
  2. FinalStaticMethodInspection
  3. ConfusingElseInspection
  4. SimplifiableEqualsExpressionInspection
  5. UnnecessaryBreakInspection
  6. UnnecessaryContinueInspection
  7. UnnecessaryDefaultInspection
  8. UnnecessaryLabelOnBreakStatementInspection
  9. UnnecessaryLabelOnContinueStatementInspection
  10. UnnecessaryReturnInspection
  11. DeleteUnnecessaryStatementFix
  12. JavaLangImportInspection
  13. SamePackageImportInspection
  14. UnnecessaryInheritDocInspection
  15. UnusedLabelInspection
  16. TransientFieldInNonSerializableClassInspection
  17. UnnecessaryConstructorInspection
  18. UnnecessaryFinalOnLocalVariableOrParameterInspection
  19. EmptySynchronizedStatementInspection
  20. TrivialFunctionalExpressionUsageInspection
  21. UnnecessaryInitCauseInspection
  22. EmptyFinallyBlockInspection
  23. UnnecessaryExplicitNumericCastInspection
  24. ...

Unit tests have been added. All the unit tests have successfully worked.

Fabrice-TIERCELIN avatar May 01 '22 06:05 Fabrice-TIERCELIN

LIKE_UNUSED_CODE would be deprecated, please don't use it. Register inspection's errorAttributes instead

akozlova avatar Jul 05 '22 08:07 akozlova

I will update the PR

Fabrice-TIERCELIN avatar Jul 05 '22 18:07 Fabrice-TIERCELIN

Not all the warnings of UnnecessaryBoxing are unused code so I didn't activate the special high-lightening for this inspection.

I still have improved UnnecessaryBoxing by moving the warnings.

Fabrice-TIERCELIN avatar Jul 07 '22 17:07 Fabrice-TIERCELIN

@BasLeijdekkers, do you agree the PR the way it is or should I remove some parts?

Fabrice-TIERCELIN avatar Aug 23 '22 06:08 Fabrice-TIERCELIN

@BasLeijdekkers, if there parts of the PR you don't like, you can merge the half and the remaining will still be in a PR.

Fabrice-TIERCELIN avatar Dec 11 '22 18:12 Fabrice-TIERCELIN