Commit 2f5a5a9
authored
Add fix for tab-oriented confusion (#369)
This result for the `AddClarifyingBracesCodemod` was confusing, because
it shouldn't act on the statement. There's no visual confusion in the
single statement within the if block.
The math the codemod does for calculating the offsets involved and
deciding to change is based on column number. This makes sense if the
code is written with spaces, not tabs. With tabs, the "visual layout" of
the code depends on the viewer, and the offsets would require different
math at a minimum. Our workaround is to ignore cases that involve tabs
for now until we get a better design to accommodate tabs.
<img width="434" alt="image"
src="https://github.com/pixee/codemodder-java/assets/911610/9de959b0-d952-42a9-b673-54716a513a47">1 parent 2438833 commit 2f5a5a9
File tree
2 files changed
+20
-0
lines changed- core-codemods/src
- main/java/io/codemodder/codemods
- test/resources/add-clarifying-braces
2 files changed
+20
-0
lines changedLines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
79 | 87 | | |
80 | 88 | | |
81 | 89 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments