Skip to content

Commit bb70e3c

Browse files
committed
fix more rules
1 parent c1fb125 commit bb70e3c

File tree

6 files changed

+51
-50
lines changed

6 files changed

+51
-50
lines changed

src/FSharpLint.Client/FSharpLintToolLocator.fs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ let private readOutputStreamAsLines (outputStream: StreamReader) : string list =
3232
let nextLine = outputStream.ReadLine()
3333

3434
if isNull nextLine then
35-
continuation []
35+
continuation List.Empty
3636
else
3737
readLines outputStream (fun lines -> nextLine :: lines |> continuation)
3838

@@ -73,15 +73,15 @@ let private runToolListCmd (workingDir: Folder) (globalFlag: bool) : Result<stri
7373
ps.UseShellExecute <- false
7474

7575
match startProcess ps with
76-
| Ok p ->
77-
p.WaitForExit()
78-
let exitCode = p.ExitCode
76+
| Ok proc ->
77+
proc.WaitForExit()
78+
let exitCode = proc.ExitCode
7979

8080
if exitCode = 0 then
81-
let output = readOutputStreamAsLines p.StandardOutput
81+
let output = readOutputStreamAsLines proc.StandardOutput
8282
Ok output
8383
else
84-
let error = p.StandardError.ReadToEnd()
84+
let error = proc.StandardError.ReadToEnd()
8585
Error(DotNetToolListError.ExitCodeNonZero(ps.FileName, ps.Arguments, exitCode, error))
8686
| Error err -> Error(DotNetToolListError.ProcessStartError err)
8787

@@ -113,7 +113,7 @@ let private (|CompatibleTool|_|) lines =
113113
let tool =
114114
List.tryFind
115115
(fun (packageId, version) ->
116-
match packageId, version with
116+
match (packageId, version) with
117117
| CompatibleToolName _, CompatibleVersion _ -> true
118118
| _ -> false)
119119
tools
@@ -129,7 +129,7 @@ let private fsharpLintVersionOnPath () : (FSharpLintExecutableFile * FSharpLintV
129129
Option.ofObj (Environment.GetEnvironmentVariable("FSHARPLINT_SEARCH_PATH_OVERRIDE"))
130130
|> Option.orElse (Option.ofObj (Environment.GetEnvironmentVariable("PATH")))
131131
|> function
132-
| Some s -> s.Split([| if isWindows then ';' else ':' |], StringSplitOptions.RemoveEmptyEntries)
132+
| Some path -> path.Split([| if isWindows then ';' else ':' |], StringSplitOptions.RemoveEmptyEntries)
133133
| None -> Array.empty
134134
|> Seq.choose (fun folder ->
135135
if isWindows then
@@ -154,15 +154,15 @@ let private fsharpLintVersionOnPath () : (FSharpLintExecutableFile * FSharpLintV
154154
UseShellExecute = false)
155155

156156
match startProcess processStart with
157-
| Ok p ->
158-
p.WaitForExit()
159-
let stdOut = p.StandardOutput.ReadToEnd()
157+
| Ok proc ->
158+
proc.WaitForExit()
159+
let stdOut = proc.StandardOutput.ReadToEnd()
160160

161161
stdOut
162162
|> Option.ofObj
163-
|> Option.bind (fun s ->
164-
if s.Contains("Current version: ", StringComparison.CurrentCultureIgnoreCase) then
165-
let version = s.ToLowerInvariant().Replace("current version: ", String.Empty).Trim()
163+
|> Option.bind (fun stdOut ->
164+
if stdOut.Contains("Current version: ", StringComparison.CurrentCultureIgnoreCase) then
165+
let version = stdOut.ToLowerInvariant().Replace("current version: ", String.Empty).Trim()
166166
Some (FSharpLintExecutableFile(fsharpLintExecutablePath), FSharpLintVersion(version))
167167
else
168168
None)

src/FSharpLint.Client/LSPFSharpLintService.fs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ let private getFolderFor filePath (): Result<Folder, FSharpLintServiceError> =
153153
else match Folder.FromFile filePath with
154154
| None -> Error FSharpLintServiceError.FileDoesNotExist
155155
| Some folder -> Ok folder
156-
156+
157157
handleFile filePath
158158

159159
let private getDaemon (agent: MailboxProcessor<Msg>) (folder: Folder) : Result<JsonRpc, FSharpLintServiceError> =
@@ -190,26 +190,26 @@ let private daemonNotFoundResponse filePath (error: GetDaemonError) : Task<FShar
190190
workingDirectory,
191191
pathEnvironmentVariable,
192192
error)) ->
193-
$"FSharpLint.Client tried to run `%s{executableFile} %s{arguments}` inside working directory \"{workingDirectory}\" but could not find \"%s{executableFile}\" on the PATH (%s{pathEnvironmentVariable}). Error: %s{error}",
194-
FSharpLintResponseCode.ErrDaemonCreationFailed
193+
($"FSharpLint.Client tried to run `%s{executableFile} %s{arguments}` inside working directory \"{workingDirectory}\" but could not find \"%s{executableFile}\" on the PATH (%s{pathEnvironmentVariable}). Error: %s{error}",
194+
FSharpLintResponseCode.ErrDaemonCreationFailed)
195195
| GetDaemonError.DotNetToolListError(DotNetToolListError.ProcessStartError(ProcessStartError.UnexpectedException(executableFile,
196196
arguments,
197197
error)))
198198
| GetDaemonError.FSharpLintProcessStart(ProcessStartError.UnexpectedException(executableFile, arguments, error)) ->
199-
$"FSharpLint.Client tried to run `%s{executableFile} %s{arguments}` but failed with \"%s{error}\"",
200-
FSharpLintResponseCode.ErrDaemonCreationFailed
199+
($"FSharpLint.Client tried to run `%s{executableFile} %s{arguments}` but failed with \"%s{error}\"",
200+
FSharpLintResponseCode.ErrDaemonCreationFailed)
201201
| GetDaemonError.DotNetToolListError(DotNetToolListError.ExitCodeNonZero(executableFile,
202202
arguments,
203203
exitCode,
204204
error)) ->
205-
$"FSharpLint.Client tried to run `%s{executableFile} %s{arguments}` but exited with code {exitCode} {error}",
206-
FSharpLintResponseCode.ErrDaemonCreationFailed
205+
($"FSharpLint.Client tried to run `%s{executableFile} %s{arguments}` but exited with code {exitCode} {error}",
206+
FSharpLintResponseCode.ErrDaemonCreationFailed)
207207
| GetDaemonError.InCompatibleVersionFound ->
208-
"FSharpLint.Client did not found a compatible dotnet tool version to launch as daemon process",
209-
FSharpLintResponseCode.ErrToolNotFound
208+
("FSharpLint.Client did not found a compatible dotnet tool version to launch as daemon process",
209+
FSharpLintResponseCode.ErrToolNotFound)
210210
| GetDaemonError.CompatibleVersionIsKnownButNoDaemonIsRunning(FSharpLintVersion version) ->
211-
$"FSharpLint.Client found a compatible version `%s{version}` but no daemon could be launched.",
212-
FSharpLintResponseCode.ErrDaemonCreationFailed
211+
($"FSharpLint.Client found a compatible version `%s{version}` but no daemon could be launched.",
212+
FSharpLintResponseCode.ErrDaemonCreationFailed)
213213

214214
{ Code = int code
215215
FilePath = filePath
@@ -226,10 +226,10 @@ let private cancellationWasRequestedResponse filePath : Task<FSharpLintResponse>
226226

227227
let mapResultToResponse (filePath: string) (result: Result<Task<FSharpLintResponse>, FSharpLintServiceError>) =
228228
match result with
229-
| Ok t -> t
229+
| Ok version -> version
230230
| Error FSharpLintServiceError.FileDoesNotExist -> fileNotFoundResponse filePath
231231
| Error FSharpLintServiceError.FilePathIsNotAbsolute -> fileNotAbsoluteResponse filePath
232-
| Error(FSharpLintServiceError.DaemonNotFound e) -> daemonNotFoundResponse filePath e
232+
| Error(FSharpLintServiceError.DaemonNotFound err) -> daemonNotFoundResponse filePath err
233233
| Error FSharpLintServiceError.CancellationWasRequested -> cancellationWasRequestedResponse filePath
234234

235235
type LSPFSharpLintService() =
@@ -239,7 +239,7 @@ type LSPFSharpLintService() =
239239
interface IFSharpLintService with
240240
member this.Dispose() =
241241
if not cts.IsCancellationRequested then
242-
agent.PostAndReply Reset |> ignore
242+
agent.PostAndReply Reset |> ignore<_>
243243
cts.Cancel()
244244

245245
member _.VersionAsync(versionRequest: VersionRequest, ?cancellationToken: CancellationToken) : Task<FSharpLintResponse> =
@@ -252,8 +252,8 @@ type LSPFSharpLintService() =
252252
Methods.Version,
253253
cancellationToken = Option.defaultValue cts.Token cancellationToken
254254
)
255-
.ContinueWith(fun (t: Task<string>) ->
255+
.ContinueWith(fun (task: Task<string>) ->
256256
{ Code = int FSharpLintResponseCode.OkCurrentDaemonVersion
257-
Result = Content t.Result
257+
Result = Content task.Result
258258
FilePath = versionRequest.FilePath }))
259259
|> mapResultToResponse versionRequest.FilePath

src/FSharpLint.Client/LSPFSharpLintServiceTypes.fs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ type FSharpLintResponseCode =
1313
| ErrDaemonCreationFailed = -1
1414
| OkCurrentDaemonVersion = 0
1515

16-
type File = private File of string
17-
with
16+
type File = private File of string
17+
with
1818
static member From (filePath: string) =
1919
if File.Exists(filePath) then
2020
filePath |> File |> Some
2121
else
2222
None
2323

24-
static member Unwrap(File f) = f
24+
static member Unwrap(File file) = file
2525

2626
type FSharpLintVersion = FSharpLintVersion of string
2727
type FSharpLintExecutableFile = FSharpLintExecutableFile of File
28-
type Folder = private Folder of string
29-
with
28+
type Folder = private Folder of string
29+
with
3030
static member FromFile (filePath: string) =
31-
if File.Exists(filePath) then
31+
if File.Exists(filePath) then
3232
let folder = (FileInfo filePath).Directory
3333
if folder.Exists then
3434
folder.FullName |> Folder |> Some
@@ -37,12 +37,12 @@ with
3737
else
3838
None
3939
static member FromFolder (folderPath: string) =
40-
if Directory.Exists(folderPath) then
40+
if Directory.Exists(folderPath) then
4141
let folder = DirectoryInfo folderPath
4242
folder.FullName |> Folder |> Some
4343
else
4444
None
45-
static member Unwrap(Folder f) = f
45+
static member Unwrap(Folder folder) = folder
4646

4747
[<RequireQualifiedAccess>]
4848
type FSharpLintToolStartInfo =

src/FSharpLint.Console/Daemon.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type FSharpLintDaemon(sender: Stream, reader: Stream) as this =
1919

2020
let disconnectEvent = new ManualResetEvent(false)
2121

22-
let exit () = disconnectEvent.Set() |> ignore
22+
let exit () = disconnectEvent.Set() |> ignore<bool>
2323

2424
do rpc.Disconnected.Add(fun _ -> exit ())
2525

tests/FSharpLint.Client.Tests/ReferenceTests.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ module FSharpLint.Client.ReferenceTests
33
open NUnit.Framework
44
open System.IO
55
open System
6+
open System.Runtime.Remoting
67

78
[<Test>]
89
let ``FSharpLint.Client should not reference FSharpLint.Core``() =
910
try
1011
System.Activator.CreateInstanceFrom("FSharp.Compiler.Service.dll", "FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults")
11-
|> ignore
12+
|> ignore<ObjectHandle>
1213
with
1314
| :? FileNotFoundException as e -> () // dll is missing, what we want
1415
| :? MissingMethodException as e -> Assert.Fail() // ctor is missing, dll was found

tests/FSharpLint.Client.Tests/TestClient.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ open Contracts
77
open LSPFSharpLintService
88
open LSPFSharpLintServiceTypes
99

10-
let (</>) x y = Path.Combine(x, y)
10+
let (</>) path1 path2 = Path.Combine(path1, path2)
1111

1212
let basePath = TestContext.CurrentContext.TestDirectory </> ".." </> ".." </> ".." </> ".." </> ".."
13-
let fsharpLintConsoleDll = basePath </> "src" </> "FSharpLint.Console" </> "bin" </> "Release" </> "net6.0" </> "dotnet-fsharplint.dll"
13+
let fsharpLintConsoleDll = basePath </> "src" </> "FSharpLint.Console" </> "bin" </> "Release" </> "net9.0" </> "dotnet-fsharplint.dll"
1414
let fsharpConsoleOutputDir = Path.GetFullPath (Path.GetDirectoryName(fsharpLintConsoleDll))
1515

1616
[<RequireQualifiedAccess>]
@@ -20,26 +20,26 @@ type ToolLocationOverride(toolStatus: ToolStatus) =
2020

2121
do match toolStatus with
2222
| ToolStatus.Available -> Environment.SetEnvironmentVariable("FSHARPLINT_SEARCH_PATH_OVERRIDE", fsharpConsoleOutputDir)
23-
| ToolStatus.NotAvailable ->
23+
| ToolStatus.NotAvailable ->
2424
let path = Environment.GetEnvironmentVariable("PATH")
2525
// ensure bin dir is not in path
2626
if path.Contains(fsharpConsoleOutputDir, StringComparison.InvariantCultureIgnoreCase) then
2727
Assert.Inconclusive()
2828

2929
File.Delete(tempFolder)
30-
Directory.CreateDirectory(tempFolder) |> ignore
30+
Directory.CreateDirectory(tempFolder) |> ignore<DirectoryInfo>
3131

3232
// set search path to an empty dir
3333
Environment.SetEnvironmentVariable("FSHARPLINT_SEARCH_PATH_OVERRIDE", tempFolder)
34-
34+
3535
interface IDisposable with
3636
member this.Dispose() =
3737
if File.Exists tempFolder then
3838
File.Delete tempFolder
3939

4040
let runVersionCall filePath (service: IFSharpLintService) =
4141
async {
42-
let request =
42+
let request =
4343
{
4444
FilePath = filePath
4545
}
@@ -51,11 +51,11 @@ let runVersionCall filePath (service: IFSharpLintService) =
5151
[<Test>]
5252
let TestDaemonNotFound() =
5353
using (new ToolLocationOverride(ToolStatus.NotAvailable)) <| fun _ ->
54-
54+
5555
let testHintsFile = basePath </> "tests" </> "FSharpLint.FunctionalTest.TestedProject" </> "FSharpLint.FunctionalTest.TestedProject.NetCore" </> "TestHints.fs"
5656
let fsharpLintService: IFSharpLintService = new LSPFSharpLintService() :> IFSharpLintService
5757
let versionResponse = runVersionCall testHintsFile fsharpLintService
58-
58+
5959
Assert.AreEqual(LanguagePrimitives.EnumToValue FSharpLintResponseCode.ErrToolNotFound, versionResponse.Code)
6060

6161
[<Test>]
@@ -79,7 +79,7 @@ let TestFilePathShouldBeAbsolute() =
7979
let testHintsFile = ".." </> "tests" </> "FSharpLint.FunctionalTest.TestedProject" </> "FSharpLint.FunctionalTest.TestedProject.NetCore" </> "TestHints.fs"
8080
let fsharpLintService: IFSharpLintService = new LSPFSharpLintService() :> IFSharpLintService
8181
let versionResponse = runVersionCall testHintsFile fsharpLintService
82-
82+
8383
Assert.AreEqual(LanguagePrimitives.EnumToValue FSharpLintResponseCode.ErrFilePathIsNotAbsolute, versionResponse.Code)
8484

8585
[<Test>]
@@ -89,5 +89,5 @@ let TestFileShouldExists() =
8989
let testHintsFile = basePath </> "tests" </> "FSharpLint.FunctionalTest.TestedProject" </> "FSharpLint.FunctionalTest.TestedProject.NetCore" </> "TestHintsOOOPS.fs"
9090
let fsharpLintService: IFSharpLintService = new LSPFSharpLintService() :> IFSharpLintService
9191
let versionResponse = runVersionCall testHintsFile fsharpLintService
92-
92+
9393
Assert.AreEqual(LanguagePrimitives.EnumToValue FSharpLintResponseCode.ErrFileNotFound, versionResponse.Code)

0 commit comments

Comments
 (0)