Branch: refs/heads/main
Revision: 5b779c2d16121d7464f72c4163c31dff7fb3fa2b
Author: DanilaFe
Link: chplcheck: provide alternative fix-it for misleading indentation by DanilaFe · Pull Request #28560 · chapel-lang/chapel · GitHub
Log Message:
chplcheck: provide alternative fix-it for misleading indentation (#28560)
| Bad code | Old fixit | This Fixit |
|---|---|---|
|
|
|
This PR adds another way to fix misleading indentation for loops. In
theory, this could apply to other constructs, but I wanted to keep the
initial proof-of-concept simple.
This was motivated by a demonstration during our talk at HPSF, where
Jade showed off auto-fixes for misleading indentation. I had a thought:
Well, if the user thought Chapel is whitespace-sensitive, and indented
several lines hoping to run them all as part of the loop, shouldn't the
auto-fix help them by making the program do that? Right now, it actively
fights the intent by unindenting code.
This PR implements that idea. It works by identifying all
misleadingly-indented children and grouping all of them. The workflow it
really intends to support is one in which uses indent multiple lines at
once, only to learn that they need to switch to curly braces.

Reviewed by @jabraham17 -- thanks!
Testing
- new chplcheck tests pass
Diff:
M test/chplcheck/MisleadingIndentation.chpl
M test/chplcheck/MisleadingIndentation.good
M test/chplcheck/MisleadingIndentation.good-fixit
A test/chplcheck/fixit-interactive/MisleadingIndentation.chpl
A test/chplcheck/fixit-interactive/MisleadingIndentation.good
A test/chplcheck/fixit-interactive/MisleadingIndentation.input
M tools/chplcheck/src/chplcheck.py
M tools/chplcheck/src/fixits.py
M tools/chplcheck/src/rule_types.py
M tools/chplcheck/src/rules.py
https://github.com/chapel-lang/chapel/pull/28560.diff