intellij-community
intellij-community copied to clipboard
[IDEA-289267] Change highlight to highlight unused code (1/2)
Hi @BasLeijdekkers,
What steps will reproduce the issue?
- Go to File → Settings... → Editor → Inspections
- Enable Unnecessary unboxing
- Enable Severity: Warning
- 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?
- UnnecessaryUnboxing
- RedundantArrayForVarargsCall
- BoxingBoxedValue
- DuplicateCondition
- ExtendsObject
- TypeParameterExtendsObject
- PointlessNullCheck
- ConditionCoveredByFurtherCondition
- RedundantLambdaParameterType
- MeaninglessRecordAnnotation
- UnnecessaryThis
- RedundantMethodOverride
Which inspections already work like this?
- FinalPrivateMethodInspection
- FinalStaticMethodInspection
- ConfusingElseInspection
- SimplifiableEqualsExpressionInspection
- UnnecessaryBreakInspection
- UnnecessaryContinueInspection
- UnnecessaryDefaultInspection
- UnnecessaryLabelOnBreakStatementInspection
- UnnecessaryLabelOnContinueStatementInspection
- UnnecessaryReturnInspection
- DeleteUnnecessaryStatementFix
- JavaLangImportInspection
- SamePackageImportInspection
- UnnecessaryInheritDocInspection
- UnusedLabelInspection
- TransientFieldInNonSerializableClassInspection
- UnnecessaryConstructorInspection
- UnnecessaryFinalOnLocalVariableOrParameterInspection
- EmptySynchronizedStatementInspection
- TrivialFunctionalExpressionUsageInspection
- UnnecessaryInitCauseInspection
- EmptyFinallyBlockInspection
- UnnecessaryExplicitNumericCastInspection
- ...
Unit tests have been added. All the unit tests have successfully worked.
LIKE_UNUSED_CODE would be deprecated, please don't use it. Register inspection's errorAttributes instead
I will update the PR
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.
@BasLeijdekkers, do you agree the PR the way it is or should I remove some parts?
@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.