Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle fullname more gracefully and do a bugfix release #39

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Changelog

## 0.5.1 - 2023-12-06

### Fixed
* Handle types without a FullName more gracefully. [#39](https://github.com/G-Research/fsharp-analyzers/pull/39)

## 0.5.0 - 2023-12-04

### Added
* Add ImmutableCollectionEquality analyzer. [#34](https://github.com/G-Research/fsharp-analyzers/pull/37)
* Add LoggingArgFuncNotFullyApplied analyzer. [#34](https://github.com/G-Research/fsharp-analyzers/pull/38)
* Add ImmutableCollectionEquality analyzer. [#37](https://github.com/G-Research/fsharp-analyzers/pull/37)
* Add LoggingArgFuncNotFullyApplied analyzer. [#38](https://github.com/G-Research/fsharp-analyzers/pull/38)

## 0.4.0 - 2023-11-23

Expand Down
10 changes: 8 additions & 2 deletions src/FSharp.Analyzers/ImmutableCollectionEqualityAnalyzer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ let isImmutableType (basicQualifiedName : string) (e : FSharpExpr) =

let t = e.Type

t.BasicQualifiedName = basicQualifiedName
let basicQualifiedNameOfExprType =
if t.ErasedType.HasTypeDefinition then
t.ErasedType.TypeDefinition.TryGetFullName () |> Option.defaultValue ""
else
""

basicQualifiedNameOfExprType = basicQualifiedName
&& t.TypeDefinition.Assembly.SimpleName = "System.Collections.Immutable"

let isImmutableDictionaryType (e : FSharpExpr) =
Expand All @@ -39,7 +45,7 @@ let mkMessage typeName m =
}

[<CliAnalyzer("ImmutableCollectionEqualityAnalyzer",
"TODO: add description.",
"Warns about questionable comparison operations among immutable collections",
"https://g-research.github.io/fsharp-analyzers/analyzers/ImmutableCollectionEqualityAnalyzer.html")>]
let immutableCollectionEqualityAnalyzer : Analyzer<CliContext> =
fun (ctx : CliContext) ->
Expand Down
17 changes: 12 additions & 5 deletions src/FSharp.Analyzers/StringAnalyzer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@ let StringStartsWithCode = "GRA-STRING-002"
[<Literal>]
let StringIndexOfCode = "GRA-STRING-003"

let (|StringExpr|_|) (e : FSharpExpr) =
if e.Type.ErasedType.BasicQualifiedName = "System.String" then
Some ()
let tryGetFullName (e : FSharpExpr) =
if e.Type.ErasedType.HasTypeDefinition then
e.Type.ErasedType.TypeDefinition.TryGetFullName ()
else
None

let (|StringExpr|_|) (e : FSharpExpr) =
match tryGetFullName e with
| Some "System.String" -> Some ()
| _ -> None

let (|IntExpr|_|) (e : FSharpExpr) =
if e.Type.ErasedType.BasicQualifiedName = "System.Int32" then
Some ()
if e.Type.ErasedType.HasTypeDefinition then
match tryGetFullName e with
| Some "System.Int32" -> Some ()
| _ -> None
else
None

Expand Down