Skip to content

Commit

Permalink
Clean up !-deref operator usage as per
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Mar 6, 2021
1 parent a7ad663 commit 298a287
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 97 deletions.
2 changes: 1 addition & 1 deletion AltCover.Engine/Cobertura.fs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,6 @@ module internal Cobertura =

rewrite
|> Option.ofObj
|> Option.iter (fun d -> d.Save(!path |> Option.get))
|> Option.iter (fun d -> d.Save(path.Value |> Option.get))

(result, 0uy, String.Empty)
6 changes: 3 additions & 3 deletions AltCover.Engine/CommandLine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ module internal CommandLine =
proc.BeginErrorReadLine()
proc.BeginOutputReadLine()
proc.WaitForExitCustom()
proc.ExitCode * (!dropReturnCode |> not).ToInt32
proc.ExitCode * (dropReturnCode.Value |> not).ToInt32

let logException store (e: Exception) =
error <- e.Message :: error
Expand Down Expand Up @@ -408,10 +408,10 @@ module internal CommandLine =
reportErrors String.Empty extend
Output.usage info

let internal ddFlag (name: string) flag =
let internal ddFlag (name: string) (flag:bool ref) =
(name,
(fun (_: string) ->
if !flag then
if flag.Value then
error <-
Format.Local("MultiplesNotAllowed", "--" + (name.Split('|') |> Seq.last))
:: error
Expand Down
4 changes: 2 additions & 2 deletions AltCover.Engine/LCov.fs
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ FN:4,(anonymous_0)
| Unknown -> ()
| XML document ->
doWithStream
(fun () -> File.OpenWrite(!path |> Option.get))
(fun () -> File.OpenWrite(path.Value |> Option.get))
(convertReport document format)
| JSON x ->
doWithStream (fun () -> File.OpenWrite(!path |> Option.get)) (convertJson x)
doWithStream (fun () -> File.OpenWrite(path.Value |> Option.get)) (convertJson x)

(result, 0uy, String.Empty)
10 changes: 5 additions & 5 deletions AltCover.Engine/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ module internal Main =
let found =
toDirectories |> Seq.filter Directory.Exists

if !CoverageParameters.inplace
if CoverageParameters.inplace.Value
&& CommandLine.error |> List.isEmpty
&& found.Any() then
found
Expand All @@ -370,7 +370,7 @@ module internal Main =
(fun (toDirectory, fromDirectory) ->
if CommandLine.verbosity < 1 // implement it early here
then
if !CoverageParameters.inplace then
if CoverageParameters.inplace.Value then
Output.info
<| CommandLine.Format.Local("savingto", toDirectory)

Expand Down Expand Up @@ -607,9 +607,9 @@ module internal Main =
Instrument.instrumentGenerator assemblyNames ]

Visitor.visit visitors assemblies
Zip.save document report !CoverageParameters.zipReport
Zip.save document report CoverageParameters.zipReport.Value

if !CoverageParameters.collect then
if CoverageParameters.collect.Value then
Runner.setRecordToFile report

CommandLine.processTrailingArguments rest (toInfo |> Seq.head))
Expand All @@ -618,7 +618,7 @@ module internal Main =

CommandLine.reportErrors
"Instrumentation"
(dotnetBuild && !CoverageParameters.inplace)
(dotnetBuild && CoverageParameters.inplace.Value)

result

Expand Down
10 changes: 5 additions & 5 deletions AltCover.Engine/Runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ module internal Runner =
("x|executable=",
(fun x ->
if CommandLine.validatePath "--executable" x then
if Option.isSome !executable then
if Option.isSome executable.Value then
CommandLine.error <-
CommandLine.Format.Local("MultiplesNotAllowed", "--executable")
:: CommandLine.error
Expand All @@ -741,7 +741,7 @@ module internal Runner =
("l|lcovReport=",
(fun x ->
if CommandLine.validatePath "--lcovReport" x then
if Option.isSome !LCov.path then
if Option.isSome LCov.path.Value then
CommandLine.error <-
CommandLine.Format.Local("MultiplesNotAllowed", "--lcovReport")
:: CommandLine.error
Expand All @@ -762,7 +762,7 @@ module internal Runner =
("c|cobertura=",
(fun x ->
if CommandLine.validatePath "--cobertura" x then
if Option.isSome !Cobertura.path then
if Option.isSome Cobertura.path.Value then
CommandLine.error <-
CommandLine.Format.Local("MultiplesNotAllowed", "--cobertura")
:: CommandLine.error
Expand Down Expand Up @@ -841,7 +841,7 @@ module internal Runner =
let internal requireExe (parse: Either<string * OptionSet, string list * OptionSet>) =
match parse with
| Right (l, options) ->
match (!executable, !collect) with
match (executable.Value, collect.Value) with
| (None, false)
| (Some _, true) ->
CommandLine.error <-
Expand Down Expand Up @@ -1075,7 +1075,7 @@ module internal Runner =
(args: string list)
=
let result =
if !collect then
if collect.Value then
0
else
runProcess report payload args
Expand Down
32 changes: 16 additions & 16 deletions AltCover.Engine/Visitor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ module internal CoverageParameters =
let internal defer = ref false

let internal deferOpCode () =
if !defer then
if defer.Value then
OpCodes.Ldc_I4_1
else
OpCodes.Ldc_I4_0
Expand All @@ -307,7 +307,7 @@ module internal CoverageParameters =
[ defaultInputDirectory ]
|> List.map Path.GetFullPath

let internal inplaceSelection a b = if !inplace then a else b
let internal inplaceSelection a b = if inplace.Value then a else b

let internal theOutputDirectories = List<string>()

Expand Down Expand Up @@ -420,7 +420,7 @@ module internal Inspector =

match nameProvider with
| :? AssemblyDefinition as a ->
(!CoverageParameters.local)
(CoverageParameters.local.Value)
&& a.MainModule
|> moduleFiles
|> Seq.tryHead
Expand Down Expand Up @@ -641,7 +641,7 @@ module internal Visitor =

sourceLinkDocuments <-
Some x.Module
|> Option.filter (fun _ -> !CoverageParameters.sourcelink)
|> Option.filter (fun _ -> CoverageParameters.sourcelink.Value)
|> Option.map
(fun x ->
x.CustomDebugInformations
Expand Down Expand Up @@ -687,7 +687,7 @@ module internal Visitor =
Seq.fold updateInspection x.Inspection types

let visitcount =
if !CoverageParameters.showGenerated then
if CoverageParameters.showGenerated.Value then
selectAutomatic types Exemption.None
else
Exemption.None
Expand Down Expand Up @@ -922,7 +922,7 @@ module internal Visitor =
let internal selectExemption k items exemption =
if k = StaticFilter.AsCovered then
Exemption.StaticAnalysis
else if !CoverageParameters.showGenerated then
else if CoverageParameters.showGenerated.Value then
selectAutomatic items exemption
else
exemption
Expand Down Expand Up @@ -984,7 +984,7 @@ module internal Visitor =
// Skip nested methods when in method-point mode
|> Seq.filter
(fun (_, _, methods, _) ->
!CoverageParameters.methodPoint |> not
CoverageParameters.methodPoint.Value |> not
|| methods |> List.tail |> List.isEmpty)
|> Seq.collect (
(fun (m, k, methods, top) ->
Expand Down Expand Up @@ -1055,7 +1055,7 @@ module internal Visitor =
|| state.OpCode.FlowControl = FlowControl.Throw
|| state.OpCode.FlowControl = FlowControl.Return // includes state.Next = null
|| isNull state.Next) then
(if !CoverageParameters.coalesceBranches
(if CoverageParameters.coalesceBranches.Value
&& state <> l.Head then
state :: l
else
Expand Down Expand Up @@ -1113,7 +1113,7 @@ module internal Visitor =
// Eliminate the "all inside one SeqPnt" jumps
// This covers a multitude of compiler generated branching cases
// TODO can we simplify
match (!CoverageParameters.coalesceBranches,
match (CoverageParameters.coalesceBranches.Value,
includedSequencePoint dbg toNext toJump) with
| (true, _)
| (_, Some _) ->
Expand Down Expand Up @@ -1198,13 +1198,13 @@ module internal Visitor =

let private extractBranchPoints dbg rawInstructions interesting vc =
let makeDefault i =
if !CoverageParameters.coalesceBranches then
if CoverageParameters.coalesceBranches.Value then
-1
else
i

let processBranches =
if !CoverageParameters.coalesceBranches then
if CoverageParameters.coalesceBranches.Value then
coalesceBranchPoints dbg
else
id
Expand Down Expand Up @@ -1242,7 +1242,7 @@ module internal Visitor =
|> indexList)
|> Seq.filter
(fun l ->
!CoverageParameters.coalesceBranches
CoverageParameters.coalesceBranches.Value
|| l.Length > 1) // TODO revisit
|> Seq.collect id
|> Seq.mapi
Expand All @@ -1266,7 +1266,7 @@ module internal Visitor =
Included = interesting
VisitCount = vc
Representative =
if !CoverageParameters.coalesceBranches then
if CoverageParameters.coalesceBranches.Value then
Reporting.Contributing
else
Reporting.Representative
Expand Down Expand Up @@ -1306,7 +1306,7 @@ module internal Visitor =
&& (((instructions |> Seq.isEmpty
|| CoverageParameters.coverstyle = CoverStyle.BranchOnly)
&& rawInstructions |> Seq.isEmpty |> not)
|| !CoverageParameters.methodPoint)
|| CoverageParameters.methodPoint.Value)

let sp =
if methodPointOnly () then
Expand All @@ -1319,7 +1319,7 @@ module internal Visitor =
SeqPnt =
dbg.GetSequencePoint(i)
|> Option.ofObj
|> Option.filter (fun _ -> !CoverageParameters.methodPoint)
|> Option.filter (fun _ -> CoverageParameters.methodPoint.Value)
|> Option.map SeqPnt.Build
Uid = m.Method.MetadataToken.ToInt32()
Interesting = interesting
Expand All @@ -1342,7 +1342,7 @@ module internal Visitor =
&& CoverageParameters.withBranches ()
&& (CoverageParameters.coverstyle
<> CoverStyle.LineOnly)
&& (!CoverageParameters.methodPoint |> not)
&& (CoverageParameters.methodPoint.Value |> not)

let bp =
if includeBranches () then
Expand Down
10 changes: 5 additions & 5 deletions AltCover.Tests/Runner.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ module AltCoverRunnerTests =
Assert.That(y, Is.SameAs options)
Assert.That(x, Is.Empty)

match !Runner.executable with
match Runner.executable.Value with
| Some x -> Assert.That(Path.GetFileName x, Is.EqualTo unique)
finally
Runner.executable := None)
Expand Down Expand Up @@ -1301,7 +1301,7 @@ module AltCoverRunnerTests =
Assert.That(y, Is.SameAs options)
Assert.That(x, Is.Empty)

Assert.That(!Runner.collect, Is.True)
Assert.That(Runner.collect.Value, Is.True)
finally
Runner.collect := false

Expand Down Expand Up @@ -1352,7 +1352,7 @@ module AltCoverRunnerTests =
Assert.That(y, Is.SameAs options)
Assert.That(x, Is.Empty)

match !LCov.path with
match LCov.path.Value with
| Some x -> Assert.That(Path.GetFileName x, Is.EqualTo unique)

Assert.That(Runner.I.summaries.Length, Is.EqualTo 2)
Expand Down Expand Up @@ -1768,7 +1768,7 @@ module AltCoverRunnerTests =
Assert.That(y, Is.SameAs options)
Assert.That(x, Is.Empty)

match !Cobertura.path with
match Cobertura.path.Value with
| Some x -> Assert.That(Path.GetFileName x, Is.EqualTo unique)

Assert.That(Runner.I.summaries.Length, Is.EqualTo 2)
Expand Down Expand Up @@ -1930,7 +1930,7 @@ module AltCoverRunnerTests =
Assert.That(y, Is.SameAs options)
Assert.That(x, Is.Empty)

Assert.That(!CommandLine.dropReturnCode, Is.True)
Assert.That(CommandLine.dropReturnCode.Value, Is.True)
finally
CommandLine.dropReturnCode := false

Expand Down
Loading

0 comments on commit 298a287

Please sign in to comment.