Skip to content

Commit 9c5f2fa

Browse files
CopilotTheAngryByrd
andcommitted
Address code review feedback: improve RSP file parsing
- Update documentation to accurately reflect line-by-line parsing - Use Array.choose instead of filter + map to avoid duplicate trimming - Optimize by trimming once and reusing the result Co-authored-by: TheAngryByrd <[email protected]>
1 parent 2ea9243 commit 9c5f2fa

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/FSharp.Analyzers.Cli/Program.fs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ let isFSharpFile (file: string) =
338338

339339
/// <summary>Reads FSC compiler arguments from a response (RSP) file.</summary>
340340
/// <remarks>
341-
/// RSP files contain compiler arguments, with each argument on a separate line or separated by spaces.
341+
/// RSP files contain compiler arguments, with each argument on a separate line.
342342
/// Lines starting with '#' are treated as comments and ignored.
343343
/// Empty lines are ignored.
344344
/// </remarks>
@@ -351,13 +351,17 @@ let readFscArgsFromFile (filePath: string) : string =
351351

352352
let args =
353353
File.ReadAllLines(filePath)
354-
|> Array.filter (fun line ->
354+
|> Array.choose (fun line ->
355355
let trimmed = line.Trim()
356356

357-
not (String.IsNullOrWhiteSpace trimmed)
358-
&& not (trimmed.StartsWith("#"))
357+
if
358+
String.IsNullOrWhiteSpace trimmed
359+
|| trimmed.StartsWith("#")
360+
then
361+
None
362+
else
363+
Some trimmed
359364
)
360-
|> Array.map (fun line -> line.Trim())
361365
|> String.concat ";"
362366

363367
if String.IsNullOrWhiteSpace args then

0 commit comments

Comments
 (0)