Analyzer Rules

Funcky ships two sets of Roslyn analyzers that guide you towards correct and idiomatic usage of the library.

  • Built-in analyzers (λ0xxx) are part of the Funcky package itself and are always active. They guard against usages that we consider incorrect or unsafe.
  • Funcky.Analyzers (λ1xxx) is an optional package with additional style and usage rules, most of them with an automatic code fix. Install it with:
    <PackageReference Include="Funcky.Analyzers" Version="..." PrivateAssets="all" />
    

Rules in the λ11xx range concern the FunctionalAssert helpers from the Funcky.Xunit package.

Built-in rules

RuleSeverityTitle
λ0001ErrorDisallowed use of TryGetValue
λ0003ErrorMember is not intended for direct usage

Funcky.Analyzers

RuleSeverityTitle
λ1001WarningUse of Enumerable.Repeat for a single element
λ1002WarningUse of Enumerable.Repeat with no element
λ1003WarningUse this method with argument names
λ1004WarningUse ConcatToString instead of JoinToString(string.Empty)
λ1005WarningPrefer GetOrElse over Match
λ1006WarningPrefer OrElse over Match
λ1007WarningPrefer SelectMany over Match
λ1008WarningPrefer ToNullable over Match
λ1009ErrorDo not use default to instantiate this type
λ1010ErrorAn option has either zero or one elements
λ1101WarningAssert can be simplified

Removed rules

RuleTitleNote
λ0002Use of Option<T>.None() method groupOption<T>.None() was replaced by the Option<T>.None property in 3.0. The rule and its code fix were removed once the method was gone. See the migration guide.

Configuring severity

All rules can be configured in an .editorconfig like any other Roslyn diagnostic, for example:

[*.cs]
dotnet_diagnostic.λ1003.severity = suggestion

The only exception is λ0003, which is not configurable because the flagged members do not work outside their intended syntax.