Skip to content

Commit e67978b

Browse files
authored
Merge PR #796 from webwarrior-ws/fix-rule-49
Fix PublicValuesNames rule to not apply to nested functions as they are not publicly accessible.
2 parents 9bec3ed + 6381063 commit e67978b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let private getIdentifiers (args:AstNodeRuleParams) =
3636
| AstNode.Expression(SynExpr.ForEach(_, _, _, true, pattern, _, _, _)) ->
3737
getPatternIdents AccessControlLevel.Private (getValueOrFunctionIdents args.CheckInfo) false pattern
3838
| AstNode.Binding(SynBinding(_, _, _, _, attributes, _, valData, pattern, _, _, _, _, _)) ->
39-
if not (isLiteral attributes || isExtern attributes) then
39+
if not (isLiteral attributes || isExtern attributes || isNested args args.NodeIndex) then
4040
match identifierTypeFromValData valData with
4141
| Value | Function ->
4242
let accessibility = getAccessControlLevel args.SyntaxArray args.NodeIndex

tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/PublicValuesNames.fs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,23 @@ let (|Empty|_|) str =
9494
"""
9595

9696
this.AssertNoWarnings()
97+
98+
let pascalCaseConfig = { config with Naming = Some NamingCase.PascalCase }
99+
100+
[<TestFixture>]
101+
type TestConventionsPublicValuesNamesPascalCase() =
102+
inherit TestAstNodeRuleBase.TestAstNodeRuleBase(PublicValuesNames.rule pascalCaseConfig)
103+
104+
[<Test>]
105+
member this.``Nested function should not generate warning``() =
106+
this.Parse """
107+
module Program
108+
109+
[ "one" ]
110+
|> Seq.iter (fun str ->
111+
let someFunc bar = bar
112+
someFunc str
113+
)
114+
"""
115+
116+
this.AssertNoWarnings()

0 commit comments

Comments
 (0)