Skip to content

Commit

Permalink
Warn on FS1178
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Dec 13, 2023
1 parent c4edf68 commit e5adb8c
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 15 deletions.
7 changes: 6 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ Some common use cases include:
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<WarningsAsErrors>FS0025;FS1182</WarningsAsErrors>
<WarnOn>1182;3390;$(WarnOn)</WarnOn>
<!--
FS0025: Incomplete pattern matches on this expression.
FS1182 Unused variables
FS1178 does not support structural equality
-->
<WarnOn>1182;3390;1178;$(WarnOn)</WarnOn>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode>true</RestoreLockedMode>
<NoWarn>NU1603</NoWarn>
Expand Down
3 changes: 3 additions & 0 deletions src/Fantomas.Client/Contracts.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Methods =
[<Literal>]
let Configuration = "fantomas/configuration"

[<NoComparison>]
type FormatDocumentRequest =
{ SourceCode: string
FilePath: string
Expand All @@ -35,6 +36,7 @@ and FormatCursorPosition =
new(line: int, column: int) = { Line = line; Column = column }
end

[<NoComparison>]
type FormatSelectionRequest =
{
SourceCode: string
Expand Down Expand Up @@ -63,6 +65,7 @@ and FormatSelectionRange =
EndColumn = endColumn }
end

[<NoComparison>]
type FantomasResponse =
{ Code: int
FilePath: string
Expand Down
3 changes: 3 additions & 0 deletions src/Fantomas.Client/Contracts.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Methods =
[<Literal>]
val Configuration: string = "fantomas/configuration"

[<NoComparison>]
type FormatDocumentRequest =
{
SourceCode: string
Expand All @@ -43,6 +44,7 @@ and FormatCursorPosition =
val Column: int
end

[<NoComparison>]
type FormatSelectionRequest =
{
SourceCode: string
Expand All @@ -69,6 +71,7 @@ and FormatSelectionRange =
val EndColumn: int
end

[<NoComparison>]
type FantomasResponse =
{
Code: int
Expand Down
2 changes: 2 additions & 0 deletions src/Fantomas.Client/LSPFantomasService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ open Fantomas.Client.Contracts
open Fantomas.Client.LSPFantomasServiceTypes
open Fantomas.Client.FantomasToolLocator

[<NoComparison>]
type ServiceState =
{ Daemons: Map<FantomasVersion, RunningFantomasTool>
FolderToVersion: Map<Folder, FantomasVersion> }
Expand All @@ -25,6 +26,7 @@ type GetDaemonError =
| InCompatibleVersionFound
| CompatibleVersionIsKnownButNoDaemonIsRunning of version: FantomasVersion

[<NoComparison>]
type Msg =
| GetDaemon of folder: Folder * replyChannel: AsyncReplyChannel<Result<JsonRpc, GetDaemonError>>
| Reset of AsyncReplyChannel<unit>
Expand Down
5 changes: 3 additions & 2 deletions src/Fantomas.Client/LSPFantomasServiceTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type FantomasResponseCode =
| CancellationWasRequested = 10
| DaemonCreationFailed = 11

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison>]
type FormatSelectionResponse =
| Formatted of filename: string * formattedContent: string * formattedRange: FormatSelectionRange
| Error of filename: string * formattingError: string
Expand All @@ -38,7 +38,7 @@ type FormatSelectionResponse =
SelectedRange = None
Cursor = None }

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison>]
type FormatDocumentResponse =
| Formatted of filename: string * formattedContent: string * cursor: FormatCursorPosition option
| Unchanged of filename: string
Expand All @@ -55,6 +55,7 @@ type FantomasToolStartInfo =
| GlobalTool
| ToolOnPath of executableFile: FantomasExecutableFile

[<NoComparison>]
type RunningFantomasTool =
{ Process: Process
RpcClient: JsonRpc
Expand Down
5 changes: 3 additions & 2 deletions src/Fantomas.Client/LSPFantomasServiceTypes.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ type FantomasResponseCode =
| CancellationWasRequested = 10
| DaemonCreationFailed = 11

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison>]
type FormatSelectionResponse =
| Formatted of filename: string * formattedContent: string * formattedRange: FormatSelectionRange
| Error of filename: string * formattingError: string

member AsFormatResponse: unit -> FantomasResponse

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison>]
type FormatDocumentResponse =
| Formatted of filename: string * formattedContent: string * cursor: FormatCursorPosition option
| Unchanged of filename: string
Expand All @@ -41,6 +41,7 @@ type FantomasToolStartInfo =
| GlobalTool
| ToolOnPath of executableFile: FantomasExecutableFile

[<NoComparison>]
type RunningFantomasTool =
{ Process: System.Diagnostics.Process
RpcClient: StreamJsonRpc.JsonRpc
Expand Down
3 changes: 2 additions & 1 deletion src/Fantomas.Core/ASTTransformer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ open Fantomas.Core.RangePatterns
open Fantomas.Core.SyntaxOak
open Microsoft.FSharp.Core

[<NoComparison>]
type CreationAide =
{ SourceText: ISourceText option }

Expand Down Expand Up @@ -595,7 +596,7 @@ let (|ParenMatchLambda|_|) e =
let mkMatchLambda creationAide mFunction cs m =
ExprMatchLambdaNode(stn "function" mFunction, List.map (mkSynMatchClause creationAide) cs, m)

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoEquality; NoComparison>]
type LinkExpr =
| Identifier of
// Could be SynExpr.LongIdent or SynExpr.TypeApp(LongIdent)
Expand Down
1 change: 1 addition & 0 deletions src/Fantomas.Core/CodeFormatterTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

open Fantomas.FCS.Text

[<NoComparison>]
type FormatResult =
{
/// Formatted code
Expand Down
4 changes: 3 additions & 1 deletion src/Fantomas.Core/Context.fs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ module WriterEvents =
| WriteLineBecauseOfTrivia -> true
| _ -> false)

[<System.Diagnostics.DebuggerDisplay("\"{Dump()}\"")>]
[<System.Diagnostics.DebuggerDisplay("\"{Dump()}\""); NoComparison>]
type Context =
{ Config: FormatConfig
WriterModel: WriterModel
Expand Down Expand Up @@ -961,13 +961,15 @@ let autoIndentAndNlnIfExpressionExceedsPageWidthUnlessStroustrup f (e: Expr) (ct
else
autoIndentAndNlnIfExpressionExceedsPageWidth (f e) ctx

[<NoComparison; NoEquality>]
type ColMultilineItem =
| ColMultilineItem of
// current expression
expr: (Context -> Context) *
// sepNln of current item
sepNln: (Context -> Context)

[<NoComparison>]
type ColMultilineItemsState =
{ LastBlockMultiline: bool
Context: Context }
Expand Down
3 changes: 2 additions & 1 deletion src/Fantomas.Core/Context.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type WriterModel =

member IsDummy: bool

[<System.Diagnostics.DebuggerDisplay("\"{Dump()}\"")>]
[<System.Diagnostics.DebuggerDisplay("\"{Dump()}\""); NoComparison>]
type Context =
{ Config: FormatConfig
WriterModel: WriterModel
Expand Down Expand Up @@ -264,6 +264,7 @@ val autoIndentAndNlnTypeUnlessStroustrup: f: (Type -> Context -> Context) -> t:
val autoIndentAndNlnIfExpressionExceedsPageWidthUnlessStroustrup:
f: (Expr -> Context -> Context) -> e: Expr -> ctx: Context -> Context

[<NoComparison; NoEqualityAttribute>]
type ColMultilineItem = ColMultilineItem of expr: (Context -> Context) * sepNln: (Context -> Context)

/// This helper function takes a list of expressions and ranges.
Expand Down
4 changes: 3 additions & 1 deletion src/Fantomas.Core/MultipleDefineCombinations.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module internal Fantomas.Core.MultipleDefineCombinations

open System
open System.Linq
open System.Text
open System.Text.RegularExpressions
open Microsoft.FSharp.Core.CompilerServices
Expand Down Expand Up @@ -107,12 +106,14 @@ type CodeFragment =
// You should never enter the case where you need to compare a hash line with something other than a hash line.
| x, other -> failwith $"Cannot compare %A{x} with %A{other}"

[<NoComparison>]
type FormatResultForDefines =
{ Result: FormatResult
Defines: DefineCombination
Fragments: CodeFragment list }

/// Accumulator type used when building up the fragments.
[<NoComparison>]
type SplitHashState =
{ CurrentBuilder: StringBuilder
LinesCollected: int
Expand All @@ -129,6 +130,7 @@ and [<RequireQualifiedAccess>] LastLineInfo =
| Content

/// Accumulator type used when folding over the selected CodeFragments.
[<NoComparison>]
type FragmentWeaverState =
{ LastLine: int
Cursors: Map<DefineCombination, pos>
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.Core/Selection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let findNode (selection: range) (node: Node) : Node option =

if isExactSelection then Some node else None

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison>]
type TreeForSelection =
/// Format this tree and return the entire result.
| Standalone of Oak
Expand Down
7 changes: 4 additions & 3 deletions src/Fantomas.Core/SyntaxOak.fs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ let combineRanges (ranges: range seq) =
else
Seq.reduce Range.unionRanges ranges

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison>]
type IdentifierOrDot =
| Ident of SingleTextNode
| KnownDot of SingleTextNode
Expand Down Expand Up @@ -1199,7 +1199,7 @@ type LinkSingleAppUnit(functionName: Expr, unit: UnitNode, range) =
member val FunctionName = functionName
member val Unit = unit

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison; NoEquality>]
type ChainLink =
| Identifier of Expr
| Dot of SingleTextNode
Expand Down Expand Up @@ -1417,7 +1417,7 @@ type ElseIfNode(mElse: range, mIf: range, condition: Node, range) as elseIfNode
member _.AddCursor _ = ()
member _.TryGetCursor = None

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison>]
type IfKeywordNode =
| SingleWord of SingleTextNode
| ElseIf of ElseIfNode
Expand Down Expand Up @@ -1553,6 +1553,7 @@ type StaticOptimizationConstraintWhenTyparTyconEqualsTyconNode(typar: SingleText
member val TypeParameter = typar
member val Type = t

[<NoComparison>]
type StaticOptimizationConstraint =
| WhenTyparTyconEqualsTycon of StaticOptimizationConstraintWhenTyparTyconEqualsTyconNode
| WhenTyparIsStruct of SingleTextNode
Expand Down
3 changes: 2 additions & 1 deletion src/Fantomas/Format.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open Fantomas.Core

type ProfileInfo = { LineCount: int; TimeTaken: TimeSpan }

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison>]
type FormatResult =
| Formatted of filename: string * formattedContent: string * profileInfo: ProfileInfo option
| Unchanged of filename: string * profileInfo: ProfileInfo option
Expand All @@ -32,6 +32,7 @@ type FormatParams =
Profile = profile
File = file }

[<NoComparison>]
type CheckResult =
{ Errors: (string * exn) list
Formatted: string list }
Expand Down
3 changes: 2 additions & 1 deletion src/Fantomas/Format.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open Fantomas.Core

type ProfileInfo = { LineCount: int; TimeTaken: TimeSpan }

[<RequireQualifiedAccess>]
[<RequireQualifiedAccess; NoComparison>]
type FormatResult =
| Formatted of filename: string * formattedContent: string * profileInfo: ProfileInfo option
| Unchanged of filename: string * profileInfo: ProfileInfo option
Expand All @@ -22,6 +22,7 @@ type FormatParams =
static member Create: bool * bool * string -> FormatParams
static member Create: FormatConfig * bool * bool * string -> FormatParams

[<NoComparison>]
type CheckResult =
{ Errors: (string * exn) list
Formatted: string list }
Expand Down
1 change: 1 addition & 0 deletions src/Fantomas/IgnoreFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type AbsoluteFilePath =
/// of the ignore-file.
type IsPathIgnored = AbsoluteFilePath -> bool

[<NoComparison; NoEquality>]
type IgnoreFile =
{ Location: IFileInfo
IsIgnored: IsPathIgnored }
Expand Down
1 change: 1 addition & 0 deletions src/Fantomas/IgnoreFile.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type AbsoluteFilePath =
/// of the ignore-file.
type IsPathIgnored = AbsoluteFilePath -> bool

[<NoComparison; NoEquality>]
type IgnoreFile =
{ Location: IFileInfo
IsIgnored: IsPathIgnored }
Expand Down

0 comments on commit e5adb8c

Please sign in to comment.