SemanticDiff icon indicating copy to clipboard operation
SemanticDiff copied to clipboard

Hide diffs to Java import blocks

Open jglick opened this issue 10 months ago • 2 comments

Consider https://app.semanticdiff.com/gh/jenkinsci/jenkins/pull/9688/changes#cli/src/main/java/hudson/cli/CLI.java?ignore_comments=true as an example. (https://github.com/jenkinsci/jenkins/pull/9688) Most of the first page that you see consists of changes to Java import statements. These are not really interesting to the reviewer in most cases. In fact some IDEs automatically collapse the entire block of import statements by default so you can focus on the actual code; and if you use an IDE to add missing imports, and either an IDE or a standalone tool like Spotless to manage imports (sort order, unused entries) you never even touch them manually.

It would be nice if SemanticDiff hid changes to import statements by default, or just displayed a concise summary of packages newly used or no longer used.

jglick avatar Feb 21 '25 17:02 jglick

We originally thought about adding a rule to ignore the order of imports, but decided against it because the order of imports has had an impact in the past (https://bugs.openjdk.org/browse/JDK-7101822).

Considering that the bug has been fixed for almost 10 years now, I think it is safe to enable it. This should be fixed in one of the next deployments.

mmueller2012 avatar Feb 21 '25 18:02 mmueller2012

To be clear, my presumption was that you are already in a project which enforces a particular sort order for imports, and was referring to the fact that added and removed imports are displayed (prominently) in a diff.

jglick avatar Feb 21 '25 19:02 jglick