ionide / FSharp.Analyzers.SDK

Library for building custom analyzers for F# / FSAC
http://ionide.io/FSharp.Analyzers.SDK/
MIT License
74 stars 21 forks source link

Error when analyzer globs go unmatched #204

Closed Smaug123 closed 6 months ago

Smaug123 commented 7 months ago

This is a perf hit, of course, but I claim it's not an important one.

I took the liberty of unindenting the code at the end of the main function (by early-exiting), but this has made the diff pretty nasty, sorry :(

Fixes #203.

I could understand not wanting this; on balance, though, I think these cases are more likely to be user error than intended.

dawedawe commented 7 months ago

How about we change the log level to warning and remove the last log message about aborting. Considere the different behaviours of a missing Exclude and a missing Include glob:

Include:

dotnet run --project src/FSharp.Analyzers.Cli/FSharp.Analyzers.Cli.fsproj -- --project ./samples/OptionAnalyzer/OptionAnalyzer.fsproj --analyzers-path ./samples/OptionAnalyzer/bin/Release --verbosity d --include-analyzers Foo
info: Running in verbose mode
info: Treat as Hints: []
info: Treat as Info: []
info: Treat as Warning: []
info: Treat as Error: []
info: Exclude Files: []
info: Include Files: []
info: Loading analyzers from /home/dawe/src/FSharp.Analyzers.SDK/samples/OptionAnalyzer/bin/Release
info: Registered 0 analyzers from 1 dlls
error: The following glob(s) were specified to include or exclude specific analyzers, but they did not match any discovered analyzers. Have you got them right? Foo

Exclude:

dotnet run --project src/FSharp.Analyzers.Cli/FSharp.Analyzers.Cli.fsproj -- --project ./samples/OptionAnalyzer/OptionAnalyzer.fsproj --analyzers-path ./samples/OptionAnalyzer/bin/Release --verbosity diag --exclude-analyzers foo
info: Running in verbose mode
info: Treat as Hints: []
info: Treat as Info: []
info: Treat as Warning: []
info: Treat as Error: []
info: Exclude Files: []
info: Include Files: []
info: Loading analyzers from /home/dawe/src/FSharp.Analyzers.SDK/samples/OptionAnalyzer/bin/Release
info: Registered 1 analyzers from 1 dlls
info: Running analyzers for /home/dawe/src/FSharp.Analyzers.SDK/samples/OptionAnalyzer/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.fs
info: Running analyzers for /home/dawe/src/FSharp.Analyzers.SDK/samples/OptionAnalyzer/Library.fs
info: Running analyzers for /home/dawe/src/FSharp.Analyzers.SDK/samples/OptionAnalyzer/obj/Debug/net6.0/OptionAnalyzer.AssemblyInfo.fs
error: The following glob(s) were specified to include or exclude specific analyzers, but they did not match any discovered analyzers. Have you got them right? foo
/home/dawe/src/FSharp.Analyzers.SDK/samples/OptionAnalyzer/Library.fs(10,4): Warning OV001 - Option.Value shouldn't be used
/home/dawe/src/FSharp.Analyzers.SDK/samples/OptionAnalyzer/Library.fs(21,52): Warning OV001 - Option.Value shouldn't be used
error: Aborting because there were unmatched analyzer globs (see earlier log).

A non-matching Exclude glob means, we still run the analyzers from the given directories as seen in the output above. Given that, the last log message doesn't sound right to me.

nojaf commented 6 months ago

Hi @Smaug123, did you see @dawedawe's last message here?

Smaug123 commented 6 months ago

I don't really want this feature enough to work on it any more, thanks!