Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable UnusedFormal linter rule by default #25986

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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