eclipse-collections
eclipse-collections copied to clipboard
Turn on additional IntelliJ inspections and fix violations.
It's been a while since we turned on additional IntelliJ inspections. There are many newly created inspections that are worth adding. Older inspections that were buggy have been fixed or got new options so we can configure them to have no false positives.
When turning on inspections, we currently have to make changes in two profiles, which correspond with two config files.
- Turn on the new inspection in
.idea/inspectionProfiles/IDE.xml
at the INSPECTION or WARNING severity. This makes the warnings visible in the text editor. - Turn on the new inspection in one of
.idea/inspectionProfiles/{1_Severe.xml,2_Inconsistent_Constructs.xml,3_Consistent_Style.xml,4_No_Auto_fix.xml}
at the ERROR severity. This makes the error appear in one of the four relevant TeamCity builds.
There are a ew ways to approach the work. We could turn on the inspections one at a time. Alternatively, we could turn them all on at the WARNING severity first so the violations appear in TeamCity right away, then fix the violations, then change the severity to ERROR.
1_Severe.xml This profile contains a few severe inspections.
2_Inconsistent_Constructs.xml
This profile contains inspections which flag constructs that are pointless, or a little bit wrong.
Add:
- Method is identical to its super method
- Constant on wrong side of comparison (constants go on the right)
- Unused assignment
- Redundant type cast
- Collection declared by class, not interface
- Type may be weakened (configured with our interfaces as stop classes)
- Interface may be annotated as ‘@FunctionalInterface’
- ‘size() == 0’ can be replaced with ‘isEmpty()’
3_Consistent_Style.xml
This profile contains inspections which flag constructs that are redundant or inconsistent. There is plenty over overlap with profile (2). When in doubt, inspections that affect the bytecode go into (2) and inspections that don't go into (3).
Add:
- Explicit type argument T can be replaced with <>
- Missing ‘@Override’ annotation
- Commented out code
- ‘if’ statement can be replaced with conditional or boolean expression
- Redundant ‘if’ statement
4_No_Auto_fix.xml
This profile contains inspections which have warnings but no auto-fixes. These are more difficult to fix and must be used sparingly. Examples include naming conventions, where an author has to stop and pick a name.
I could work on it.