Implemented modes in AsynchronousFunctionNames rule#842
Implemented modes in AsynchronousFunctionNames rule#842knocte merged 6 commits intofsprojects:masterfrom
Conversation
To NamingHelper.fs because both SimpleAsyncComplementaryHelpers and AsynchronousFunctionNames have to be able to access that type.
|
Missing change in docs. |
Greptile OverviewConfidence Score: 2/5
|
| Filename | Overview |
|---|---|
| docs/content/how-tos/rules/FL0096.md | Docs updated to show new mode config for FL0096; example disables the rule but now includes config.mode. |
| src/FSharpLint.Core/Application/Configuration.fs | Changes AsynchronousFunctionNames config type to RuleConfig<...> and constructs it with constructRuleWithConfig, which currently skips the rule entirely when config is omitted (breaking { enabled: true } behavior and default config). |
| src/FSharpLint.Core/Rules/Conventions/Naming/AsynchronousFunctionNames.fs | Adds Config.Mode and new modes logic (library heuristic + access level + nested behavior). Main functional risk is config defaulting handled elsewhere, not in this file. |
| src/FSharpLint.Core/Rules/Conventions/Naming/SimpleAsyncComplementaryHelpers.fs | Moves AsynchronousFunctionsMode to shared helper and continues using Config.Mode; no functional logic changes in this PR diff. |
| src/FSharpLint.Core/Rules/NamingHelper.fs | Introduces shared AsynchronousFunctionsMode DU under Helper.Naming.Asynchronous for reuse by multiple rules. |
| tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/AsynchronousFunctionNames.fs | Updates tests to pass config to rule and adds new fixtures covering AllAPIs (non-public + nested bindings). |
| tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/SimpleAsyncComplementaryHelpers.fs | Updates tests to use shared AsynchronousFunctionsMode and to pass Mode = AnyPublicAPIs explicitly. |
Sequence Diagram
sequenceDiagram
participant UserCfg as fsharplint.json
participant Config as Configuration.fs
participant Ctor as constructRuleWithConfig
participant AFN as AsynchronousFunctionNames.rule
participant Runner as AsynchronousFunctionNames.runner
participant Heur as LibraryHeuristics
UserCfg->>Config: Deserialize RuleConfig<AsynchronousFunctionNames.Config>
Config->>Ctor: constructRuleWithConfig AFN.rule (if enabled)
alt config block present
Ctor->>AFN: rule(config)
AFN->>Runner: Runner = runner config
Runner->>Heur: howLikelyProjectIsLibrary(projectFileName)
Runner-->>Config: Suggestions emitted/empty
else config omitted (Config=None)
Ctor-->>Config: returns None (rule not constructed)
Note over Config,Ctor: Enabled rule becomes effectively disabled
end
Additional Comments (2)
This needs a default
Either add a default |
That has Mode member, which may be on of: OnlyPublicAPIsInLibraries (default), AnyPublicAPIs, AllAPIs.
For AllAPIs mode.
Mode OnlyPublicAPIsInLibraries only runs in projects that are likely library projects. Mode AnyPublicAPIs flags all public APIs like before. Mode AllAPIs also flags (give violations about) internal, private, and nested APIs.
f88df9d to
7e125a6
Compare
Added new setting description to docs. |
Actually, instead of defaulting to a mode when not specifying the mode (like TypePrefixing rule does), I'd prefer if we throw an exception in this case because in this case the rule is new (in the case of TypePrefixing, the rule already existed when we added the mode). |
In "Rule Settings" section.
b689dc2 to
d2ebfb7
Compare
To include info about mode setting.
The rule is constructed using |
So? |
So it is already functioning as you described, no need to change anything. |
|
Ok great. |
Both rules yeah? |
Yes. |
Mode
OnlyPublicAPIsInLibrariesonly runs in projects that are likely library projects.Mode
AnyPublicAPIsflags all public APIs like before.Mode
AllAPIsalso flags (give violations about) internal, private, and nested APIs.Contributes to #517.