Skip to content

[All] Fix ~45 code scanning warnings in Fable.Transforms#4357

Open
dbrattli wants to merge 2 commits intomainfrom
dbrattli/fable-warnings
Open

[All] Fix ~45 code scanning warnings in Fable.Transforms#4357
dbrattli wants to merge 2 commits intomainfrom
dbrattli/fable-warnings

Conversation

@dbrattli
Copy link
Collaborator

@dbrattli dbrattli commented Feb 23, 2026

Summary

  • Address four categories of code scanning analyzer warnings across 15 files in src/Fable.Transforms/
  • GRA-STRING-001/002/004: Add explicit StringComparison.Ordinal to StartsWith, EndsWith, and LastIndexOf string overloads
  • IONIDE-007: Replace cons-nil list patterns (x :: []) with list literal patterns ([x]), also improving readability of complex multi-element patterns in Rust/Replacements.fs
  • IONIDE-005: Replace s = "" conditionals with String.IsNullOrEmpty(s) for more efficient empty string testing
  • GRA-TYPE-ANNOTATE-001: Add type annotations to ambiguous string function calls using string<type> syntax

Note: GRA-INTERPOLATED-001 (:s/:d format 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)
  • CI pipeline passes

🤖 Generated with Claude Code

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>
@dbrattli dbrattli changed the title Fix ~150 code scanning warnings in Fable.Transforms [All] Fix ~150 code scanning warnings in Fable.Transforms Feb 23, 2026
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ionide.Analyzers.Cli found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@github-actions
Copy link

Python Type Checking Results (Pyright)

Metric Value
Total errors 18
Files with errors 4
Excluded files 4
New errors ✅ No
Excluded files with errors (4 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/test_hash_set.py 3 Excluded
temp/tests/Python/test_nested_and_recursive_pattern.py 2 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 1 Excluded

…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

Interpolated hole expression without format detected. Use prefix with the correct % to enforce type safety.
@dbrattli dbrattli changed the title [All] Fix ~150 code scanning warnings in Fable.Transforms Fix ~45 code scanning warnings in Fable.Transforms Feb 23, 2026
@dbrattli dbrattli changed the title Fix ~45 code scanning warnings in Fable.Transforms [All] Fix ~45 code scanning warnings in Fable.Transforms Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant