diff --git a/Makefile b/Makefile index 6f69fa711bde..7a4fa7f91c05 100644 --- a/Makefile +++ b/Makefile @@ -216,7 +216,7 @@ lint-standard-modules: chplcheck FORCE tools/chplcheck/chplcheck --skip-unstable \ --internal-prefix "_" \ --internal-prefix "chpl_" \ - --disable-rule "RedundantParentheses" \ + --disable-rule "ControlFlowParentheses" \ $(MODULES_TO_LINT) compile-util-python: FORCE diff --git a/test/chplcheck/RedundantParentheses.chpl b/test/chplcheck/ControlFlowParentheses.chpl similarity index 100% rename from test/chplcheck/RedundantParentheses.chpl rename to test/chplcheck/ControlFlowParentheses.chpl diff --git a/test/chplcheck/ControlFlowParentheses.good b/test/chplcheck/ControlFlowParentheses.good new file mode 100644 index 000000000000..6ec8bc4a9882 --- /dev/null +++ b/test/chplcheck/ControlFlowParentheses.good @@ -0,0 +1,34 @@ +ControlFlowParentheses.chpl:1: node violates rule UseExplicitModules +ControlFlowParentheses.chpl:13: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:14: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:15: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:16: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:17: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:18: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:19: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:20: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:21: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:23: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:24: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:25: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:26: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:27: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:28: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:29: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:30: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:31: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:33: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:34: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:35: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:36: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:37: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:38: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:39: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:40: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:41: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:43: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:45: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:47: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:49: node violates rule ControlFlowParentheses +ControlFlowParentheses.chpl:51: node violates rule ControlFlowParentheses +[Success matching fixit for ControlFlowParentheses] diff --git a/test/chplcheck/RedundantParentheses.good-fixit b/test/chplcheck/ControlFlowParentheses.good-fixit similarity index 100% rename from test/chplcheck/RedundantParentheses.good-fixit rename to test/chplcheck/ControlFlowParentheses.good-fixit diff --git a/test/chplcheck/RedundantParentheses.good b/test/chplcheck/RedundantParentheses.good deleted file mode 100644 index cac1fa44180a..000000000000 --- a/test/chplcheck/RedundantParentheses.good +++ /dev/null @@ -1,34 +0,0 @@ -RedundantParentheses.chpl:1: node violates rule UseExplicitModules -RedundantParentheses.chpl:13: node violates rule RedundantParentheses -RedundantParentheses.chpl:14: node violates rule RedundantParentheses -RedundantParentheses.chpl:15: node violates rule RedundantParentheses -RedundantParentheses.chpl:16: node violates rule RedundantParentheses -RedundantParentheses.chpl:17: node violates rule RedundantParentheses -RedundantParentheses.chpl:18: node violates rule RedundantParentheses -RedundantParentheses.chpl:19: node violates rule RedundantParentheses -RedundantParentheses.chpl:20: node violates rule RedundantParentheses -RedundantParentheses.chpl:21: node violates rule RedundantParentheses -RedundantParentheses.chpl:23: node violates rule RedundantParentheses -RedundantParentheses.chpl:24: node violates rule RedundantParentheses -RedundantParentheses.chpl:25: node violates rule RedundantParentheses -RedundantParentheses.chpl:26: node violates rule RedundantParentheses -RedundantParentheses.chpl:27: node violates rule RedundantParentheses -RedundantParentheses.chpl:28: node violates rule RedundantParentheses -RedundantParentheses.chpl:29: node violates rule RedundantParentheses -RedundantParentheses.chpl:30: node violates rule RedundantParentheses -RedundantParentheses.chpl:31: node violates rule RedundantParentheses -RedundantParentheses.chpl:33: node violates rule RedundantParentheses -RedundantParentheses.chpl:34: node violates rule RedundantParentheses -RedundantParentheses.chpl:35: node violates rule RedundantParentheses -RedundantParentheses.chpl:36: node violates rule RedundantParentheses -RedundantParentheses.chpl:37: node violates rule RedundantParentheses -RedundantParentheses.chpl:38: node violates rule RedundantParentheses -RedundantParentheses.chpl:39: node violates rule RedundantParentheses -RedundantParentheses.chpl:40: node violates rule RedundantParentheses -RedundantParentheses.chpl:41: node violates rule RedundantParentheses -RedundantParentheses.chpl:43: node violates rule RedundantParentheses -RedundantParentheses.chpl:45: node violates rule RedundantParentheses -RedundantParentheses.chpl:47: node violates rule RedundantParentheses -RedundantParentheses.chpl:49: node violates rule RedundantParentheses -RedundantParentheses.chpl:51: node violates rule RedundantParentheses -[Success matching fixit for RedundantParentheses] diff --git a/test/chplcheck/activerules.good b/test/chplcheck/activerules.good index 79d0d88f179e..a3660c6b6cb5 100644 --- a/test/chplcheck/activerules.good +++ b/test/chplcheck/activerules.good @@ -4,6 +4,7 @@ Active rules: CamelCaseFunctions Warn for functions that are not 'camelCase'. CamelCaseRecords Warn for records that are not 'camelCase'. ChplPrefixReserved Warn for user-defined names that start with the 'chpl_' reserved prefix. + ControlFlowParentheses Warn for unnecessary parentheses in conditional statements and loops. DoKeywordAndBlock Warn for redundant 'do' keyword before a curly brace '{'. EmptyStmts Warn for empty statements (i.e., unnecessary semicolons). IncorrectIndentation Warn for inconsistent or missing indentation @@ -11,7 +12,6 @@ Active rules: MisleadingIndentation Warn for single-statement blocks that look like they might be multi-statement blocks. PascalCaseClasses Warn for classes that are not 'PascalCase'. PascalCaseModules Warn for modules that are not 'PascalCase'. - RedundantParentheses Warn for unnecessary parentheses in conditional statements and loops. SimpleDomainAsRange Warn for simple domains in loops that can be ranges. UnusedLoopIndex Warn for unused index variables in loops. UnusedTupleUnpack Warn for unused tuple unpacking, such as '(_, _)'. diff --git a/test/chplcheck/allrules.good b/test/chplcheck/allrules.good index 788e5dc96ed4..5d6c35288601 100644 --- a/test/chplcheck/allrules.good +++ b/test/chplcheck/allrules.good @@ -6,6 +6,7 @@ Available rules (default rules marked with *): CamelOrPascalCaseVariables Warn for variables that are not 'camelCase' or 'PascalCase'. * ChplPrefixReserved Warn for user-defined names that start with the 'chpl_' reserved prefix. ConsecutiveDecls Warn for consecutive variable declarations that can be combined. + * ControlFlowParentheses Warn for unnecessary parentheses in conditional statements and loops. * DoKeywordAndBlock Warn for redundant 'do' keyword before a curly brace '{'. * EmptyStmts Warn for empty statements (i.e., unnecessary semicolons). * IncorrectIndentation Warn for inconsistent or missing indentation @@ -14,7 +15,6 @@ Available rules (default rules marked with *): NestedCoforalls Warn for nested 'coforall' loops, which could lead to performance hits. * PascalCaseClasses Warn for classes that are not 'PascalCase'. * PascalCaseModules Warn for modules that are not 'PascalCase'. - * RedundantParentheses Warn for unnecessary parentheses in conditional statements and loops. * SimpleDomainAsRange Warn for simple domains in loops that can be ranges. UnusedFormal Warn for unused formals in functions. * UnusedLoopIndex Warn for unused index variables in loops. diff --git a/tools/chplcheck/src/rules.py b/tools/chplcheck/src/rules.py index c6b2d7c0046b..0ee6deef62de 100644 --- a/tools/chplcheck/src/rules.py +++ b/tools/chplcheck/src/rules.py @@ -230,7 +230,7 @@ def DoKeywordAndBlock( return check @driver.basic_rule(set((Loop, Conditional))) - def RedundantParentheses( + def ControlFlowParentheses( context: Context, node: typing.Union[Loop, Conditional] ): """