Skip to content

Commit

Permalink
Merge pull request #128 from nojaf/allow-multiple-paths
Browse files Browse the repository at this point in the history
Allow to specify multiple analyzers-paths.
  • Loading branch information
nojaf authored Oct 26, 2023
2 parents 31d7b8a + 68d370b commit a804a3f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit a804a3f

Please sign in to comment.