[All] Fix ~45 code scanning warnings in Fable.Transforms#4357
Conversation
Address five categories of analyzer warnings across 23 files: - GRA-STRING-001/002/004: Add StringComparison.Ordinal to string operations - IONIDE-007: Replace cons-nil patterns (x :: []) with list literals ([x]) - IONIDE-005: Replace empty string comparisons with String.IsNullOrEmpty - GRA-TYPE-ANNOTATE-001: Add type annotations to ambiguous `string` calls - GRA-INTERPOLATED-001: Add format specifiers (:s, :d) to interpolated strings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Ionide.Analyzers.Cli found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
Python Type Checking Results (Pyright)
Excluded files with errors (4 files)These files have known type errors and are excluded from CI. Remove from
|
…tations Revert all :s and :d format specifiers added to interpolated strings because Fable's Standalone tests compile the compiler to JavaScript, and Fable doesn't handle .NET-style format specifiers correctly — they produce literal % characters in the JS output. Also fix string type annotations to use string<type> syntax instead of string (x: type), which the analyzer still flagged. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| Helper.ConstructorCall(constructor com ent, t, [], ?loc = r) |> Some | ||
| | t -> | ||
| $"Cannot create instance of type unresolved at compile time: %A{t}" | ||
| $"Cannot create instance of type unresolved at compile time: {t}" |
Check warning
Code scanning / Ionide.Analyzers.Cli
Warns about missing type specifiers in interpolated strings Warning
|
The though with this is to reduce the number of code scanning security warnings for Fable, starting with Fable.Transforms. Currently 726 warnings which doesn't look too good. What do you think? @MangelMaxime @ncave |
|
I think it is a good idea to reduce the number of warnings. Especially, because right now even if we have the F# analyzers in place personally I don't look at it because their are too many warnings. 🙈 If we get the number of warning down, or even reach zero we can then only merge a PR when it does not increase it or add new warnings 🙂 |
|
@dbrattli But I miss my Joking aside, it was only done just to avoid the horrible source formatting that list literals have, so the source can stay human readable. But since human readability is no longer important anyway, nobody cares, so it's all good. The less warnings, the better. 👍 |
Summary
src/Fable.Transforms/StringComparison.OrdinaltoStartsWith,EndsWith, andLastIndexOfstring overloadsx :: []) with list literal patterns ([x]), also improving readability of complex multi-element patterns inRust/Replacements.fss = ""conditionals withString.IsNullOrEmpty(s)for more efficient empty string testingstringfunction calls usingstring<type>syntaxNote: GRA-INTERPOLATED-001 (
:s/:dformat specifiers) was attempted but reverted — the Standalone tests compile the compiler to JavaScript via Fable, which doesn't handle .NET-style format specifiers correctly.Test plan
dotnet build src/Fable.Transforms/Fable.Transforms.fsproj— 0 errors, 0 warnings./build.sh test javascript --skip-fable-library— 2,603/2,607 passed (4 failures are pre-existing locale-dependent Convert format tests)🤖 Generated with Claude Code