Skip to content

Commit 1e8d187

Browse files
authored
Merge PR fsprojects#639 from Mersho/AvoidTooShortNamesBang
AvoidTooShortNames: honor "let!" declarations.
2 parents 10d1e2b + d919a9a commit 1e8d187

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/FSharpLint.Core/Rules/Conventions/AvoidTooShortNames.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ let private getParameterWithBelowMinimumLength (pats: SynPat list): (Ident * str
5151

5252
let private getIdentifiers (args:AstNodeRuleParams) =
5353
match args.AstNode with
54+
| AstNode.Expression(SynExpr.LetOrUseBang(_, _, _, pat, _, _, _, _)) ->
55+
getParameterWithBelowMinimumLength [pat]
5456
| AstNode.Match(SynMatchClause(namePattern, _, _, _, _)) ->
5557
getParameterWithBelowMinimumLength [namePattern]
5658
| AstNode.Binding(SynBinding(_, _, _, _, _, _, _, pattern, _, _, _, _)) ->

tests/FSharpLint.Core.Tests/Rules/Conventions/AvoidTooShortNames.fs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,23 @@ match foo with
142142
"""
143143
Assert.IsTrue(this.ErrorExistsAt(3, 7))
144144
Assert.IsFalse(this.ErrorExistsAt(3, 14))
145+
146+
[<Test>]
147+
member this.AvoidTooShortNamesShouldProduceError_13() =
148+
this.Parse """
149+
async {
150+
let! z = async { return 1 + 2 }
151+
return z
152+
} |> Async.RunSynchronously |> ignore<int>"""
153+
154+
Assert.IsTrue this.ErrorsExist
155+
156+
[<Test>]
157+
member this.AvoidTooShortNamesShouldProduceError_14() =
158+
this.Parse """
159+
async {
160+
let! result = async { return 1 + 2 }
161+
return result
162+
} |> Async.RunSynchronously |> ignore<int>"""
163+
164+
Assert.IsTrue this.NoErrorsExist

0 commit comments

Comments
 (0)