Skip to content

Commit 2661a96

Browse files
authored
Add a new FAQ about ignoring formatting or types (#363)
* Add a new FAQ about ignoring formatting or types Based on this Slack question: https://rewriteoss.slack.com/archives/C01A843MWG5/p1741425521114579 "Hi, is there a way to tell rewriteTest to ignore the formatting when comparing before and after java? Or ideally to compare AST is equivalent, ignoring if static imports or fully qualified types are used." * Update based on feedback from Tim --------- Co-authored-by: Mike Solomon <mike-solomon@users.noreply.github.com>
1 parent caed5eb commit 2661a96

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/reference/faq.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,17 @@ Time savings estimates provide you with a general idea of how much time was save
301301
The assumption is that this time saved number represents how long it would take a developer to change the code, create a PR to review said change, and then merge/deploy it once it was reviewed. It _does not_ estimate how long it would take a developer to find this issue in the code (which, in some cases, can be quite a bit longer than making the change itself).
302302

303303
[You can export data tables with those results per recipe](../running-recipes/data-tables.md).
304+
305+
## Is there a way to tell `rewriteTest` to ignore formatting when comparing before and after? Likewise, can we just compare LST equivalence while ignoring static imports or fully qualified types?
306+
307+
No there is not -- and very intentionally not so.
308+
309+
The reason is that these differences can be indicative of underlying issues. For example:
310+
311+
* Ignoring formatting differences might overlook cases where incorrect formatting affects code behavior or leads to compilation issues.
312+
313+
* Ignoring import differences might cause problems if a necessary type is missing or not properly imported.
314+
315+
Additionally, if `rewriteTest` ignores these issues, it could lead to problems composing multiple recipes together. The output of one recipe becomes the input for the next, and if that output contains formatting or import issues, it can cause issues downstream.
316+
317+
Because of that, we recommend fixing the underlying causes of those differences.

0 commit comments

Comments
 (0)