Skip to content

Commit

Permalink
Enable UnusedFormal linter rule by default (#25986)
Browse files Browse the repository at this point in the history
Enables the UnusedFormal linter rule by default, which was turned off
due to confusing bugs.

@riftEmber resolved the known bugs with this rule in
#25954, so this rule can be
reenabled by default.

[Reviewed by @riftEmber]
  • Loading branch information
jabraham17 authored Sep 25, 2024
2 parents e4c48fa + 5a2953f commit fd77a8e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ lint-standard-modules: chplcheck FORCE
--internal-prefix "_" \
--internal-prefix "chpl_" \
--disable-rule "ControlFlowParentheses" \
--disable-rule "UnusedFormal" \
$(MODULES_TO_LINT)

compile-util-python: FORCE
Expand Down
2 changes: 1 addition & 1 deletion doc/rst/tools/chplcheck/chplcheck.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ checking for unused formals.

.. code-block:: python
@driver.advanced_rule(default=False)
@driver.advanced_rule
def UnusedFormal(context, root):
formals = dict()
uses = set()
Expand Down
1 change: 0 additions & 1 deletion test/chplcheck/PREDIFF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
FLAGS="--enable-rule ConsecutiveDecls"\
" --enable-rule BoolLitInCondStatement"\
" --enable-rule UseExplicitModules"\
" --enable-rule UnusedFormal"\
" --enable-rule CamelOrPascalCaseVariables"\
" --enable-rule NestedCoforalls"\
" --internal-prefix myprefix_ --internal-prefix _"\
Expand Down
5 changes: 5 additions & 0 deletions test/chplcheck/Unused.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ module Unused {

myProc(1,2);
myProcIgnored(1,2);

var Outer: [1..10] int;
proc foo(Outer) {
Outer[1] = 2;
}
}
2 changes: 1 addition & 1 deletion test/chplcheck/allrules.good
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Available rules (default rules marked with *):
* PascalCaseClasses Warn for classes that are not 'PascalCase'.
* PascalCaseModules Warn for modules that are not 'PascalCase'.
* SimpleDomainAsRange Warn for simple domains in loops that can be ranges.
UnusedFormal Warn for unused formals in functions.
* UnusedFormal Warn for unused formals in functions.
* UnusedLoopIndex Warn for unused index variables in loops.
* UnusedTupleUnpack Warn for unused tuple unpacking, such as '(_, _)'.
UseExplicitModules Warn for code that relies on auto-inserted implicit modules.
1 change: 0 additions & 1 deletion test/chplcheck/fixit-interactive/PREDIFF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
$CHPL_HOME/tools/chplcheck/chplcheck --enable-rule ConsecutiveDecls \
--enable-rule BoolLitInCondStatement \
--enable-rule UseExplicitModules \
--enable-rule UnusedFormal \
--enable-rule CamelOrPascalCaseVariables \
--enable-rule NestedCoforalls \
--internal-prefix "myprefix_" --internal-prefix "_" \
Expand Down
2 changes: 1 addition & 1 deletion tools/chplcheck/src/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def FixMisleadingIndentation(context: Context, result: AdvancedRuleResult):
fixit = Fixit.build(Edit(loc.path(), line_start, loc.end(), text))
return [fixit] if fixit else []

@driver.advanced_rule(default=False)
@driver.advanced_rule
def UnusedFormal(context: Context, root: AstNode):
"""
Warn for unused formals in functions.
Expand Down

0 comments on commit fd77a8e

Please sign in to comment.