From 2b1cb8fe27b873a4d5e37da5a841a775081ae9a1 Mon Sep 17 00:00:00 2001 From: webwarrior-ws Date: Thu, 18 Dec 2025 12:37:35 +0100 Subject: [PATCH 1/2] PublicValuesNames: add test for nested function Which tests for the fact that the rule should not fire for nested functions because they are not public. --- .../Conventions/Naming/PublicValuesNames.fs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/PublicValuesNames.fs b/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/PublicValuesNames.fs index 0cbf5eb6b..f1bebf3a0 100644 --- a/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/PublicValuesNames.fs +++ b/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/PublicValuesNames.fs @@ -94,3 +94,23 @@ let (|Empty|_|) str = """ this.AssertNoWarnings() + +let pascalCaseConfig = { config with Naming = Some NamingCase.PascalCase } + +[] +type TestConventionsPublicValuesNamesPascalCase() = + inherit TestAstNodeRuleBase.TestAstNodeRuleBase(PublicValuesNames.rule pascalCaseConfig) + + [] + member this.``Nested function should not generate warning``() = + this.Parse """ +module Program + +[ "one" ] +|> Seq.iter (fun str -> + let someFunc bar = bar + someFunc str +) +""" + + this.AssertNoWarnings() From 6381063aea3a2805e8912bf663e4c490730b2f62 Mon Sep 17 00:00:00 2001 From: webwarrior-ws Date: Thu, 18 Dec 2025 13:02:11 +0100 Subject: [PATCH 2/2] PublicValuesNames: fix rule Fix false positive in case of nested function. The rule should not fire for nested functions because they are not public. --- .../Rules/Conventions/Naming/PublicValuesNames.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/PublicValuesNames.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/PublicValuesNames.fs index 774dc3651..4633a8d35 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/PublicValuesNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/PublicValuesNames.fs @@ -36,7 +36,7 @@ let private getIdentifiers (args:AstNodeRuleParams) = | AstNode.Expression(SynExpr.ForEach(_, _, _, true, pattern, _, _, _)) -> getPatternIdents AccessControlLevel.Private (getValueOrFunctionIdents args.CheckInfo) false pattern | AstNode.Binding(SynBinding(_, _, _, _, attributes, _, valData, pattern, _, _, _, _, _)) -> - if not (isLiteral attributes || isExtern attributes) then + if not (isLiteral attributes || isExtern attributes || isNested args args.NodeIndex) then match identifierTypeFromValData valData with | Value | Function -> let accessibility = getAccessControlLevel args.SyntaxArray args.NodeIndex