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

Allow to specify multiple analyzers-paths. #128

Merged
merged 2 commits into from Oct 26, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Changed
* [Use fixed version of FCS and FSharp.Core](https://github.com/ionide/FSharp.Analyzers.SDK/pull/127) (thanks @nojaf!)
* [Allow to specify multiple analyzers-paths](https://github.com/ionide/FSharp.Analyzers.SDK/pull/128) (thanks @nojaf!)

## [0.16.0] - 2023-10-16

Expand Down
26 changes: 16 additions & 10 deletions src/FSharp.Analyzers.Cli/Program.fs
Expand Up @@ -12,7 +12,7 @@ open Ionide.ProjInfo

type Arguments =
| Project of string list
| Analyzers_Path of string
| Analyzers_Path of string list
| Fail_On_Warnings of string list
| Ignore_Files of string list
| Exclude_Analyzer of string list
Expand Down Expand Up @@ -252,15 +252,16 @@ let main argv =
printInfo "Ignore Files: [%s]" (ignoreFiles |> String.concat ", ")
let ignoreFiles = ignoreFiles |> List.map Glob

let analyzersPath =
let path = results.GetResult(<@ Analyzers_Path @>, "packages/Analyzers")
let analyzersPaths =
results.GetResult(<@ Analyzers_Path @>, [ "packages/Analyzers" ])
|> List.map (fun path ->
if Path.IsPathRooted path then
path
else
Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, path))
)

if Path.IsPathRooted path then
path
else
Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, path))

printInfo "Loading analyzers from %s" analyzersPath
printInfo "Loading analyzers from %s" (String.concat ", " analyzersPaths)

let excludeAnalyzers = results.GetResult(<@ Exclude_Analyzer @>, [])

Expand Down Expand Up @@ -291,7 +292,12 @@ let main argv =
let client =
Client<CliAnalyzerAttribute, CliContext>(logger, Set.ofList excludeAnalyzers)

let dlls, analyzers = client.LoadAnalyzers analyzersPath
let dlls, analyzers =
((0, 0), analyzersPaths)
||> List.fold (fun (accDlls, accAnalyzers) analyzersPath ->
let dlls, analyzers = client.LoadAnalyzers analyzersPath
(accDlls + dlls), (accAnalyzers + analyzers)
)

printInfo "Registered %d analyzers from %d dlls" analyzers dlls

Expand Down