navigation

FavourNonMutablePropertyInitialization (FL0084)

Introduced in 0.24.0

Cause

Use of mutation to initialize properties with values.

Rationale

There's no need to use mutation to initialize properties with values because F# has specific syntax for this kind of intitialization. Both approaches will compile to the same IL but non-mutable code doesn't look unsafe because it prevents the use of the <- operator.

How To Fix

Replace all occurrences of mutable property initialization with non mutable property initialization. Example: Cookie(Domain = "example.com") instead of let c = Cookie(); c.Domain <- "example.com"

Rule Settings

{
    "FavourNonMutablePropertyInitialization": { "enabled": false }
}