feat(rules): add F# review support - #1448
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). |
| - `match` expressions that omit a reachable discriminated-union or `option` case, especially after a union gains a new case; do not report a match that the compiler can prove exhaustive | ||
| - Catch-all `_` branches used only to suppress an incomplete-pattern warning when an omitted case needs distinct behavior or error handling | ||
| - Active patterns or guards whose ordering shadows a later reachable case, silently selecting the wrong branch | ||
| - `Option.get`, `Option.Value`, `Result.get`, or equivalent unwraps where `None` or `Error` can occur for runtime, external, or untrusted input |
There was a problem hiding this comment.
Option.get exists, but the FSharp.Core Result module does not define Result.get.
| - `Option.get`, `Option.Value`, `Result.get`, or equivalent unwraps where `None` or `Error` can occur for runtime, external, or untrusted input | |
| - `Option.get`, accessing `.Value` on an option/value option, or project-specific partial `Result` unwraps where `None`, `ValueNone`, or `Error` can occur for runtime, external, or untrusted input |
There was a problem hiding this comment.
Applied in 6898498. I verified that Result.get is not part of FSharp.Core, so the rule now names Option getters and project-specific partial Result unwraps.
| #### .NET Interop and Type Boundaries | ||
| - Passing F# `option` values through a .NET API as though they were `null`, or treating a nullable/reference return from .NET as non-null without a local invariant | ||
| - P/Invoke, reflection, serialization, or JSON bindings whose declared types, field names, nullability, ownership, or enum values do not match the external contract | ||
| - Unsafe casts (`unbox`, `:?`, `Unchecked.defaultof`, or reflection-based invocation) without a locally established runtime type/nullability invariant |
There was a problem hiding this comment.
:? is a type test, not an unsafe cast
| - Unsafe casts (`unbox`, `:?`, `Unchecked.defaultof`, or reflection-based invocation) without a locally established runtime type/nullability invariant | |
| - Runtime downcasts or unchecked/default-producing operations (`:?>`, `unbox`, `Unchecked.defaultof`, or reflection-based invocation) without a locally established runtime type/nullability invariant |
There was a problem hiding this comment.
Applied in 6898498. :? is a type test; the rule now targets runtime downcasts (:?>) and other unchecked/default-producing operations.
| - Untrusted values flowing into SQL, shell commands, file paths, URLs, deserialization, or HTML without validation or parameterization, and secrets written to source, logs, or error messages | ||
|
|
||
| #### Signatures and Module Boundaries | ||
| - An `.fsi` signature that promises a different type, exception behavior, mutability contract, or visibility from the implementation it exposes |
There was a problem hiding this comment.
| - An `.fsi` signature that promises a different type, exception behavior, mutability contract, or visibility from the implementation it exposes | |
| - An `.fsi` signature whose exposed types, arity, generic constraints, mutability, or visibility do not match the implementation or intended public API |
There was a problem hiding this comment.
Applied in 6898498. The signature guidance now covers exposed types, arity, generic constraints, mutability, and visibility against the implementation or intended public API.
NanaseInori
left a comment
There was a problem hiding this comment.
The follow-up commit addresses the F# accuracy issues raised in the earlier review. The rule now uses the correct FSharp.Core terminology (Option access / project-specific partial Result unwraps and :?> for runtime downcasts), and the .fsi guidance is phrased around the actual signature contract.
The extension allowlist and default-rule resolution cover .fs, .fsi, and .fsx, including case-insensitive allowlist tests. I don't see any remaining blocking issue in the current head.
This review was conducted by NanaseInori's review bot, using the model GPT-5.6 Sol. If you need a human review, please manually @NanaseInori.
wu21-web
left a comment
There was a problem hiding this comment.
Please update the site documentation.
|
Updated in 9863efa. The site Review Rules page now lists the built-in **/*.{fs,fsi,fsx} -> fsharp.md mapping in the English, Chinese, Japanese, Korean, and Russian docs, including its implementation/signature/script scope.
|
wu21-web
left a comment
There was a problem hiding this comment.
Add an exclude pattern, for example a glob like, **/*.Test.fs or**/*Test.fs, and add it to the test index.
| - `match` expressions that omit a reachable discriminated-union or `option` case, especially after a union gains a new case; do not report a match that the compiler can prove exhaustive | ||
| - Catch-all `_` branches used only to suppress an incomplete-pattern warning when an omitted case needs distinct behavior or error handling | ||
| - Active patterns or guards whose ordering shadows a later reachable case, silently selecting the wrong branch | ||
| - `Option.get`, accessing `.Value` on an option/value option, or project-specific partial `Result` unwraps where `None`, `ValueNone`, or `Error` can occur for runtime, external, or untrusted input |
There was a problem hiding this comment.
You missed one
| - `Option.get`, accessing `.Value` on an option/value option, or project-specific partial `Result` unwraps where `None`, `ValueNone`, or `Error` can occur for runtime, external, or untrusted input | |
| - `Option.get`, `ValueOption.get`, accessing `.Value` on an option/value option, or project-specific partial `Result` unwraps where `None`, `ValueNone`, or `Error` can occur for runtime, external, or untrusted input |
There was a problem hiding this comment.
Implemented in a8a0488. ValueOption.get is now listed alongside Option.get; make check, make test, make coverage, and make build all pass.
|
Updated in 2abe064. Added
|
2abe064 to
8364f31
Compare
|
Follow-up: upstream |
|
@yaodong-shen please rebase main |
# Conflicts: # pages/src/content/docs/en/review-rules.md # pages/src/content/docs/ja/review-rules.md # pages/src/content/docs/ko/review-rules.md # pages/src/content/docs/ru/review-rules.md # pages/src/content/docs/zh/review-rules.md
Description
Adds focused review coverage for F# source files.
.fs,.fsi, and.fsxfiles to a conservative F# system rule;.fsiand.fsxto the review allowlist;The rule prioritizes concrete correctness, security, lifetime, async/cancellation, sequence, interop, and module-boundary defects; it explicitly avoids formatting and unsupported style preferences.
Closes #1447
Type of Change
How Has This Been Tested?
make testpasses locallymake checkpasses locallymake buildpasses locallymake coveragepasses locally (92.5%, above the 90% threshold)ocr review --audience agent --previewinspected the changed configuration scope; a full LLM review cannot run locally because no OCR provider is configured.Checklist
make check)Codex (GPT-5) was used for development assistance. I reviewed the resulting change and did not add AI attribution trailers to the commit.
Related Issues
Closes #1447