Skip to content

Commit 2becbe1

Browse files
authored
Always process folder recursive. (#2775)
* Always process folder recursive. * Remove last traces of recurse. Add UpgradeGuide.md entry.
1 parent cd3fb2d commit 2becbe1

File tree

5 files changed

+13
-20
lines changed

5 files changed

+13
-20
lines changed

docs/docs/end-users/UpgradeGuide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ fsharp_experimental_stroustrup_style = true
7070
### console application
7171
- `-v` is now short for `--verbosity` instead of `--version`
7272
- The console output was revamped.
73+
- `--recurse` was removed. Please use [.fantomasignore](./IgnoreFiles.html) file if you wish to ignore certain files.
7374

7475
### Miscellaneous
7576
- The public API of CodeFormatter no longer uses `FSharpOption<'T>`, instead overloads are now used.

src/Fantomas.Tests/Integration/IgnoreFilesTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ let ``ignore specific file in subfolder`` () =
5353
use ignoreFixture = new FantomasIgnoreFile(sprintf "%s/%s/A.fs" sub1 sub2)
5454

5555
let { ExitCode = exitCode } =
56-
runFantomasTool (sprintf "--recurse --check .%c%s" Path.DirectorySeparatorChar sub1)
56+
runFantomasTool (sprintf "--check .%c%s" Path.DirectorySeparatorChar sub1)
5757

5858
exitCode |> should equal 0
5959

src/Fantomas.Tests/Integration/MultiplePathsTests.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let ``format multiple paths`` () =
3838
fileContentMatches FormattedCode fileFixtureTwo.Filename
3939

4040
[<Test>]
41-
let ``format multiple paths with recursive flag`` () =
41+
let ``format multiple paths recursively`` () =
4242
use config = new ConfigurationFile("[*]\nend_of_line = lf")
4343

4444
use fileFixtureOne = new TemporaryFileCodeSample(UserCode)
@@ -48,7 +48,7 @@ let ``format multiple paths with recursive flag`` () =
4848
use fileFixtureThree = new TemporaryFileCodeSample(UserCode, subFolder = "sub")
4949

5050
let arguments =
51-
sprintf "%s \"%s\" \"%s\" \"sub\" -r" Verbosity fileFixtureOne.Filename fileFixtureTwo.Filename
51+
sprintf "%s \"%s\" \"%s\" \"sub\"" Verbosity fileFixtureOne.Filename fileFixtureTwo.Filename
5252

5353
let { ExitCode = exitCode; Output = output } = runFantomasTool arguments
5454

src/Fantomas/Program.fs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ open Spectre.Console
1111
let extensions = set [| ".fs"; ".fsx"; ".fsi"; ".ml"; ".mli" |]
1212

1313
type Arguments =
14-
| [<Unique; AltCommandLine("-r")>] Recurse
1514
| [<Unique>] Force
1615
| [<Unique>] Profile
1716
| [<Unique>] Out of string
@@ -24,7 +23,6 @@ type Arguments =
2423
interface IArgParserTemplate with
2524
member s.Usage =
2625
match s with
27-
| Recurse -> "Process the input folder recursively."
2826
| Force -> "Print the output even if it is not valid F# code. For debugging purposes only."
2927
| Out _ ->
3028
"Give a valid path for files/folders. Files should have .fs, .fsx, .fsi, .ml or .mli extension only. Multiple files/folders are not supported."
@@ -83,13 +81,9 @@ let isInExcludedDir (fullPath: string) =
8381
let isFSharpFile (s: string) =
8482
Set.contains (Path.GetExtension s) extensions
8583

86-
/// Get all appropriate files, either recursively or non-recursively
87-
let allFiles isRec path =
88-
let searchOption =
89-
(if isRec then
90-
SearchOption.AllDirectories
91-
else
92-
SearchOption.TopDirectoryOnly)
84+
/// Get all appropriate files, recursively.
85+
let findAllFilesRecursively path =
86+
let searchOption = SearchOption.AllDirectories
9387

9488
Directory.GetFiles(path, "*.*", searchOption)
9589
|> Seq.filter (fun f -> isFSharpFile f && not (isInExcludedDir f))
@@ -182,7 +176,7 @@ let private reportCheckResults (checkResult: Format.CheckResult) =
182176
|> List.map (fun filename -> $"%s{filename} needs formatting")
183177
|> Seq.iter stdlog
184178

185-
let runCheckCommand (recurse: bool) (inputPath: InputPath) : int =
179+
let runCheckCommand (inputPath: InputPath) : int =
186180
let check files =
187181
Async.RunSynchronously(Format.checkCode files)
188182

@@ -208,12 +202,12 @@ let runCheckCommand (recurse: bool) (inputPath: InputPath) : int =
208202
logGrEqDetailed $"'%s{f}' was ignored"
209203
0
210204
| InputPath.File path -> path |> Seq.singleton |> check |> processCheckResult
211-
| InputPath.Folder path -> path |> allFiles recurse |> check |> processCheckResult
205+
| InputPath.Folder path -> path |> findAllFilesRecursively |> check |> processCheckResult
212206
| InputPath.Multiple(files, folders) ->
213207
let allFilesToCheck =
214208
seq {
215209
yield! files
216-
yield! (Seq.collect (allFiles recurse) folders)
210+
yield! (Seq.collect findAllFilesRecursively folders)
217211
}
218212

219213
allFilesToCheck |> check |> processCheckResult
@@ -274,8 +268,6 @@ let main argv =
274268

275269
let force = results.Contains <@ Arguments.Force @>
276270
let profile = results.Contains <@ Arguments.Profile @>
277-
let recurse = results.Contains <@ Arguments.Recurse @>
278-
279271
let version = results.TryGetResult <@ Arguments.Version @>
280272

281273
let maybeVerbosity =
@@ -351,7 +343,7 @@ let main argv =
351343
if not <| Directory.Exists(outputFolder) then
352344
Directory.CreateDirectory(outputFolder) |> ignore
353345

354-
allFiles recurse inputFolder
346+
findAllFilesRecursively inputFolder
355347
|> Seq.toList
356348
|> List.map (fun i ->
357349
// s supposes to have form s1/suffix
@@ -461,7 +453,7 @@ let main argv =
461453
daemon.WaitForClose.GetAwaiter().GetResult()
462454
exit 0
463455
elif check then
464-
inputPath |> runCheckCommand recurse |> exit
456+
inputPath |> runCheckCommand |> exit
465457
else
466458
try
467459
match inputPath, outputPath with

tests/regressions.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let git (workingDirectory: string) (arguments: string) = wrap workingDirectory "
4343

4444
let format (workingDirectory: string) (input: string list) =
4545
let input = String.concat " " input
46-
wrap workingDirectory "dotnet" $"{fantomasBinary} {input} --recurse"
46+
wrap workingDirectory "dotnet" $"{fantomasBinary} {input}"
4747

4848
let runCommands (workingDirectory: string) (commands: Command list) =
4949
task {

0 commit comments

Comments
 (0)