-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(fs): check postAnalyzers for StaticPaths #8543
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
fix(fs): check postAnalyzers for StaticPaths #8543
Conversation
- merge `analyzers` + `postAnalyzers` - check this map in StaticPaths function (to check in staticPath mode)
- create AnalyzerType interface and use it in analyzer and PostAnalyzer - add toAnalyzerType function to convert []analyzer and []PostAnalyzer to []AnalyzerType
pkg/fanal/analyzer/analyzer.go
Outdated
| func toAnalyzerType[T AnalyzerType](aa []T) []AnalyzerType { | ||
| var at []AnalyzerType | ||
| for _, a := range aa { | ||
| at = append(at, a) | ||
| } | ||
| return at | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tell me - if you have better way.
- remove AnalyzerType interface - StaticPaths returns error if one postAnalyzer is enabled
| // PostAnalyzers don't implement StaticPathAnalyzer. | ||
| // So if at least one postAnalyzer is enabled - we should not use StaticPath. | ||
| if allPostAnalyzersDisabled := lo.EveryBy(ag.postAnalyzers, func(a PostAnalyzer) bool { | ||
| return slices.Contains(disabled, a.Type()) | ||
| }); !allPostAnalyzersDisabled { | ||
| return nil, false | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
postAnalyzers don't implement StaticPaths now.
Also it looks like will be hard to implement StaticPaths for them.
So looks like we can just check that PostAnalyzers are enabled.
knqyf263
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing it.
Description
To enable
StaticPathsmode - all enabled analyzers must implement theStaticPathAnalyzerinterface.For this we need to check
analyzers. And alsopostAnalyzers(changes in this PR)Otherwise there may be cases when only postAnalyzser is enabled => we enable
StaticPathsmode and skip files.example:
Before:
After:
Related PRs
Checklist