[Chapel Merge] chplcheck: implement redundant parenths rule

Branch: refs/heads/main
Revision: a1cde47a90b7b18a4b0d409e3a0a9dfadbe13111
Author: DanilaFe
Link: chplcheck: implement redundant parenths rule by DanilaFe · Pull Request #25225 · chapel-lang/chapel · GitHub
Log Message:
chplcheck: implement redundant parenths rule (#25225)

Addresses a part of [Feature Request]: Lint rule for extra parentheses · Issue #25219 · chapel-lang/chapel · GitHub,
except the var = (x); issue.

Warnings on the right, auto-fixes on the left.

This PR just exposes the existing parenthesis location map, and only
applies to conditionals and loops. Some changes were necessary to make
this work for 'for' loops, in which the AST node is originally built as
an Identifier, then translated into a `Variable.; I added operation to
the builder to support persisting locations across such transformations.

Reviewed by @jabraham17 -- thanks!


  • start_test test/chplcheck
  • paratest

Compare: Comparing 83ca8ab57566a0afb524573b847825e116d8830f...ea0d60dee0d9a860abd5e26e94371bf7b7aa1960 · chapel-lang/chapel · GitHub

M Makefile
M frontend/include/chpl/uast/Builder.h
M frontend/lib/parsing/ParserContextImpl.h
M frontend/lib/uast/Builder.cpp
A test/chplcheck/RedundantParentheses.chpl
A test/chplcheck/RedundantParentheses.good
A test/chplcheck/RedundantParentheses.good-fixit
M test/chplcheck/activerules.good
M test/chplcheck/allrules.good
M tools/chapel-py/src/method-tables/uast-methods.h
M tools/chplcheck/src/rules.py