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

Fail the tool when analyzers fail to load #198

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

Smaug123
Copy link
Contributor

The tool currently silently swallows this sort of error.

This change is backward incompatible. Is that OK?

@@ -185,6 +194,8 @@ type Client<'TAttribute, 'TContext when 'TAttribute :> AnalyzerAttribute and 'TC
then
true
else
System.Threading.Interlocked.Increment skippedAssemblies |> ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is an idiom I strongly prefer, because it's robust against people choosing in the future to parallelise the Array.filter. Of course, I could rewrite this as a fold instead if mutability is considered harmful.)

@@ -233,10 +244,22 @@ type Client<'TAttribute, 'TContext when 'TAttribute :> AnalyzerAttribute and 'TC
registeredAnalyzers.AddOrUpdate(path, analyzers, (fun _ _ -> analyzers))
|> ignore

Array.length analyzers, analyzers |> Seq.collect snd |> Seq.length
let assemblyCount = Array.length analyzers
let analyzerCount = analyzers |> Seq.sumBy (snd >> Seq.length)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by efficiency change

Copy link
Contributor

@dawedawe dawedawe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, makes sense.

@dawedawe
Copy link
Contributor

@Smaug123 One thing: Could you add a changelog entry, please.

Copy link
Contributor

@nojaf nojaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I'm also on board with this.

The changelog entry (in CHANGELOG.md) would look like:

## [Unreleased]

### Changed
* [Good entry here](https://github.com/ionide/FSharp.Analyzers.SDK/pull/198) (thanks @Smaug123)

Out of interest, what assemblies failed to load in your case?
Actual assemblies with analyzers or other DLLs it tried to load?

@Smaug123
Copy link
Contributor Author

This was motivated by https://github.com/Smaug123/fsharp-prattparser and specifically https://github.com/Smaug123/fsharp-prattparser/actions/runs/7618965411/job/20751163083 :

info: Running in verbose mode
info: Treat as Hints: []
info: Treat as Info: []
info: Treat as Warning: []
info: Treat as Error: [GRA-IMMUTABLECOLLECTIONEQUALITY-001, GRA-INTERPOLATED-001, GRA-JSONOPTS-001, GRA-LOGARGFUNCFULLAPP-001, GRA-STRING-001, GRA-STRING-002, GRA-STRING-003, GRA-TYPE-ANNOTATE-001, GRA-UNIONCASE-001, GRA-VIRTUALCALL-001]
info: Exclude Files: []
info: Include Files: []
info: Loading analyzers from /home/runner/work/fsharp-prattparser/fsharp-prattparser/.analyzerpackages/g-research.fsharp.analyzers/0.6.0/
error: Trying to load /home/runner/work/fsharp-prattparser/fsharp-prattparser/.analyzerpackages/g-research.fsharp.analyzers/0.6.0/analyzers/dotnet/fs/G-Research.FSharp.Analyzers.dll which was built using SDK version 0.22.0.0. Expect 0.23.0.0 instead. Assembly will be skipped.
info: Registered 0 analyzers from 0 dlls
info: No messages found from the analyzer(s)

@nojaf nojaf merged commit 1aa73ad into ionide:main Jan 26, 2024
2 checks passed
@Smaug123 Smaug123 deleted the fail-on-failure branch January 26, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants