KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In my case there are two reason for doing that: Sometimes people by mistake import classes which present in macbooks JDKs but absent in Linux. This causes build to fail on CI which are Linux based boxes. I doesn’t happen frequently, but when it does I'm thinking that there should be some smarter way to find out that earlier. Unused imports trigger warning in IDE/code analysis. From time to time somebody need to spend time on cleaning that up. Even if its just single right click in IDE you still need to make PR, pass a build etc etc. I'm curious if there is any way to find unused imports programmatically (lets say from unit test) and fail locally if there are any. Maybe failing a build because of unused import sounds harsh, but if it saves time for team overall it makes sens to do so (would love to hear opinion on that as well). UPDATE : I followed yegor256 suggestion and incorporated Checkstyle task with initially small subset of Sun Code Conventions (unused imports is one of them) and made it break a build if violations found. After one week of trial we've got zero unused imports in our codebase and surprisingly zero complaints about this rule (by the way, Checkstyle is really fast: analyzing ~100KLoc taking less than one second). As for using IDE for such analysis: yes, it good choice, but having this kind of checks run as part of automated build is better.
Tags (comma-separated)
Save Edits
Cancel