Skip to content

Commit eb741d3

Browse files
committed
NestedFunctionNames,UnnestedFunctionNames: fix rules
Fix rules to only take into account function and method names.
1 parent 0264277 commit eb741d3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/FSharpLint.Core/Rules/Conventions/Naming/NestedFunctionNames.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ open FSharpLint.Rules.Helper.Naming
88

99
let private getIdentifiers (args: AstNodeRuleParams) =
1010
match args.AstNode with
11-
| AstNode.Binding (SynBinding (_, _, _, _, _attributes, _, _, pattern, _, _, _, _, _)) ->
11+
| AstNode.Binding (SynBinding (_, _, _, _, _attributes, _, valData, pattern, _, _, _, _, _)) ->
1212
if isNested args args.NodeIndex then
1313
let maxAccessibility = AccessControlLevel.Public
14-
getPatternIdents maxAccessibility (fun _a11y innerPattern -> getFunctionIdents innerPattern) true pattern
14+
match identifierTypeFromValData valData with
15+
| Function | Member ->
16+
getPatternIdents maxAccessibility (fun _a11y innerPattern -> getFunctionIdents innerPattern) true pattern
17+
| _ -> Array.empty
1518
else
1619
Array.empty
1720
| _ -> Array.empty

src/FSharpLint.Core/Rules/Conventions/Naming/UnnestedFunctionNames.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ open FSharpLint.Rules.Helper.Naming
88

99
let private getIdentifiers (args: AstNodeRuleParams) =
1010
match args.AstNode with
11-
| AstNode.Binding (SynBinding (_, _, _, _, _attributes, _, _, pattern, _, _, _, _,_)) ->
11+
| AstNode.Binding (SynBinding (_, _, _, _, _attributes, _, valData, pattern, _, _, _, _,_)) ->
1212
if isNested args args.NodeIndex then
1313
Array.empty
1414
else
1515
let maxAccessibility = AccessControlLevel.Public
16-
getPatternIdents maxAccessibility (fun _a11y innerPattern -> getFunctionIdents innerPattern) true pattern
16+
match identifierTypeFromValData valData with
17+
| Function | Member ->
18+
getPatternIdents maxAccessibility (fun _a11y innerPattern -> getFunctionIdents innerPattern) true pattern
19+
| _ -> Array.empty
1720
| _ -> Array.empty
1821

1922
let rule config =

0 commit comments

Comments
 (0)