diff --git a/docs/content/how-tos/rules/FL0006.md b/docs/content/how-tos/rules/FL0006.md index c36134fce..43202fabe 100644 --- a/docs/content/how-tos/rules/FL0006.md +++ b/docs/content/how-tos/rules/FL0006.md @@ -31,4 +31,4 @@ Uses the `numIndentationSpaces` global setting. } } -* *allowSingleLineLambda* - whether or not to allow single-line lambda pattern matches +* *allowSingleLineLambda* - whether or not to allow single-line lambda pattern matches. diff --git a/docs/content/how-tos/rules/FL0010.md b/docs/content/how-tos/rules/FL0010.md index 26d82c9d6..ba662c132 100644 --- a/docs/content/how-tos/rules/FL0010.md +++ b/docs/content/how-tos/rules/FL0010.md @@ -29,4 +29,4 @@ Update typed item to use configured spacing. } } -* *typedItemStyle* - style of spacing: "NoSpaces", "SpaceAfter", "SpacesAround" +* *typedItemStyle* - style of spacing: "NoSpaces", "SpaceAfter", "SpacesAround". diff --git a/docs/content/how-tos/rules/FL0011.md b/docs/content/how-tos/rules/FL0011.md index b71601b6a..0b482990c 100644 --- a/docs/content/how-tos/rules/FL0011.md +++ b/docs/content/how-tos/rules/FL0011.md @@ -29,4 +29,4 @@ Update higher order type to have correct formatting as per guide linked above. } } -* *mode* - how to enforce the rule ("Hybrid" or "Always" or "Never") +* *mode* - how to enforce the rule: "Hybrid", "Always", or "Never" diff --git a/docs/content/how-tos/rules/FL0036.md b/docs/content/how-tos/rules/FL0036.md index ac85d1e0d..7c009cb59 100644 --- a/docs/content/how-tos/rules/FL0036.md +++ b/docs/content/how-tos/rules/FL0036.md @@ -33,7 +33,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0037.md b/docs/content/how-tos/rules/FL0037.md index 5fcac04c2..ca620522c 100644 --- a/docs/content/how-tos/rules/FL0037.md +++ b/docs/content/how-tos/rules/FL0037.md @@ -33,7 +33,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0038.md b/docs/content/how-tos/rules/FL0038.md index d407c2cb0..bdec102a9 100644 --- a/docs/content/how-tos/rules/FL0038.md +++ b/docs/content/how-tos/rules/FL0038.md @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0039.md b/docs/content/how-tos/rules/FL0039.md index e1f70a7c3..6247721a8 100644 --- a/docs/content/how-tos/rules/FL0039.md +++ b/docs/content/how-tos/rules/FL0039.md @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0040.md b/docs/content/how-tos/rules/FL0040.md index 88dce6873..38f5bddbe 100644 --- a/docs/content/how-tos/rules/FL0040.md +++ b/docs/content/how-tos/rules/FL0040.md @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0041.md b/docs/content/how-tos/rules/FL0041.md index bf0f6620f..39ba532ce 100644 --- a/docs/content/how-tos/rules/FL0041.md +++ b/docs/content/how-tos/rules/FL0041.md @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0042.md b/docs/content/how-tos/rules/FL0042.md index 22bf7fcb7..1978fa12f 100644 --- a/docs/content/how-tos/rules/FL0042.md +++ b/docs/content/how-tos/rules/FL0042.md @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0043.md b/docs/content/how-tos/rules/FL0043.md index 692ab214f..db47e6912 100644 --- a/docs/content/how-tos/rules/FL0043.md +++ b/docs/content/how-tos/rules/FL0043.md @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0044.md b/docs/content/how-tos/rules/FL0044.md index 2744e7b1f..ec51e5054 100644 --- a/docs/content/how-tos/rules/FL0044.md +++ b/docs/content/how-tos/rules/FL0044.md @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0045.md b/docs/content/how-tos/rules/FL0045.md index d3bc7dfcb..1ebe455a4 100644 --- a/docs/content/how-tos/rules/FL0045.md +++ b/docs/content/how-tos/rules/FL0045.md @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0046.md b/docs/content/how-tos/rules/FL0046.md index 236ecf485..bd4346d4c 100644 --- a/docs/content/how-tos/rules/FL0046.md +++ b/docs/content/how-tos/rules/FL0046.md @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0047.md b/docs/content/how-tos/rules/FL0047.md index ccf266527..29f006f46 100644 --- a/docs/content/how-tos/rules/FL0047.md +++ b/docs/content/how-tos/rules/FL0047.md @@ -31,7 +31,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0048.md b/docs/content/how-tos/rules/FL0048.md index 24cf1ee62..5b79e38cc 100644 --- a/docs/content/how-tos/rules/FL0048.md +++ b/docs/content/how-tos/rules/FL0048.md @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0049.md b/docs/content/how-tos/rules/FL0049.md index 13dc1c271..7fb59eff9 100644 --- a/docs/content/how-tos/rules/FL0049.md +++ b/docs/content/how-tos/rules/FL0049.md @@ -31,7 +31,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0050.md b/docs/content/how-tos/rules/FL0050.md index 886881d74..9f11a5d95 100644 --- a/docs/content/how-tos/rules/FL0050.md +++ b/docs/content/how-tos/rules/FL0050.md @@ -18,7 +18,7 @@ Consistency aides readability. ## How To Fix -Update the non-public value's naming to be consistent with the rules you have specified +Update the non-public value's naming to be consistent with the rules you have specified. ## Rule Settings @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0055.md b/docs/content/how-tos/rules/FL0055.md index c52acfa8d..035f3944f 100644 --- a/docs/content/how-tos/rules/FL0055.md +++ b/docs/content/how-tos/rules/FL0055.md @@ -8,7 +8,7 @@ hide_menu: true ## Cause -A value is binded to a wildcard e.g. `let _ = Console.ReadLine()` +A value is binded to a wildcard e.g. `let _ = Console.ReadLine()`. ## Rationale @@ -16,7 +16,7 @@ Using the ignore function makes it clear what is intended to happen, rather than ## How To Fix -Pipe the value into the ignore function e.g. `Console.ReadLine() |> ignore` +Pipe the value into the ignore function e.g. `Console.ReadLine() |> ignore`. ## Rule Settings diff --git a/docs/content/how-tos/rules/FL0056.md b/docs/content/how-tos/rules/FL0056.md index 0c524d508..2ebab7a9f 100644 --- a/docs/content/how-tos/rules/FL0056.md +++ b/docs/content/how-tos/rules/FL0056.md @@ -8,7 +8,7 @@ hide_menu: true ## Cause -A wildcard is given a name using the as pattern e.g. `match something with | _ as x -> x + y` +A wildcard is given a name using the as pattern e.g. `match something with | _ as x -> x + y`. ## Rationale @@ -16,7 +16,7 @@ The wildcard and as pattern can be replaced with the identifier the value is to ## How To Fix -Replace the wildcard with the identifier the wildcard is currently being bound to, e.g. change `match something with | _ as x -> x + y` to `match something with | x -> x + y` +Replace the wildcard with the identifier the wildcard is currently being bound to, e.g. change `match something with | _ as x -> x + y` to `match something with | x -> x + y`. ## Rule Settings diff --git a/docs/content/how-tos/rules/FL0057.md b/docs/content/how-tos/rules/FL0057.md index 479de3e60..39030837b 100644 --- a/docs/content/how-tos/rules/FL0057.md +++ b/docs/content/how-tos/rules/FL0057.md @@ -8,7 +8,7 @@ hide_menu: true ## Cause -An identifier is binded to itself e.g. `let x = x` +An identifier is binded to itself e.g. `let x = x`. ## Rationale diff --git a/docs/content/how-tos/rules/FL0058.md b/docs/content/how-tos/rules/FL0058.md index a4cea18f7..fa1698c24 100644 --- a/docs/content/how-tos/rules/FL0058.md +++ b/docs/content/how-tos/rules/FL0058.md @@ -8,7 +8,7 @@ hide_menu: true ## Cause -A constructor in a pattern has arguments that consist entirely of wildcards e.g. `SynPat.Paren(_, _)` +A constructor in a pattern has arguments that consist entirely of wildcards e.g. `SynPat.Paren(_, _)`. ## Rationale @@ -16,7 +16,7 @@ The tuple of wildcards can be replaced with a single wildcard. ## How To Fix -Replace the tuple with a single wildcard e.g. the example in the cause could be turned into `SynPat.Paren(_)` +Replace the tuple with a single wildcard e.g. the example in the cause could be turned into `SynPat.Paren(_)`. ## Rule Settings diff --git a/docs/content/how-tos/rules/FL0061.md b/docs/content/how-tos/rules/FL0061.md index d3113b3c5..636e69131 100644 --- a/docs/content/how-tos/rules/FL0061.md +++ b/docs/content/how-tos/rules/FL0061.md @@ -31,6 +31,6 @@ Remove any whitespace from the end of the line. } } -* *numberOfSpacesAllowed* - An integer property that specifies how many space characters are allowed on the end of a line. (Default 1) -* *oneSpaceAllowedAfterOperator* - A boolean property that will allow a single space on the end of the line if it's preceded by an operator/symbol character. (Default true) -* *ignoreBlankLines* - A boolean property that will ignore any lines that are made up of just whitespace. (Default true) +* *numberOfSpacesAllowed* - An integer property that specifies how many space characters are allowed on the end of a line (default: 1). +* *oneSpaceAllowedAfterOperator* - A boolean property that will allow a single space on the end of the line if it's preceded by an operator/symbol character (default: true). +* *ignoreBlankLines* - A boolean property that will ignore any lines that are made up of just whitespace (default: true). diff --git a/docs/content/how-tos/rules/FL0065.md b/docs/content/how-tos/rules/FL0065.md index 5399cd6fc..fbab2d611 100644 --- a/docs/content/how-tos/rules/FL0065.md +++ b/docs/content/how-tos/rules/FL0065.md @@ -18,8 +18,8 @@ Every hint is formed of two parts: the match and the suggestion. Both the match Any F# expression can be matched by a variable or wildcard. -* A variable is represented by a single letter e.g. `x` -* A wildcard is represented by the character `_` +* A variable is represented by a single letter e.g. `x`. +* A wildcard is represented by the character `_`. Variables and wildcards are seemingly the same, and in terms of matching they are. The key difference is that using a variable lets you refer to it in the suggestion, enabling you to show where the matched expression should be moved within the matched code. @@ -59,7 +59,7 @@ In the example above the boolean literal `true` is used to match any F# code whe ### Match Function Application and Operators -Matching function application, prefix operators, and infix operators in hints are all done in the same way as how you'd write it in F# e.g. +Matching function application, prefix operators, and infix operators in hints are all done in the same way as how you'd write it in F# e.g.: [lang=hint] not true ===> false diff --git a/docs/content/how-tos/rules/FL0066.md b/docs/content/how-tos/rules/FL0066.md index 5af096213..71a37d86a 100644 --- a/docs/content/how-tos/rules/FL0066.md +++ b/docs/content/how-tos/rules/FL0066.md @@ -32,5 +32,5 @@ Use non-partial function or pattern matching. } } -* *allowedPartials* - list of strings representing partial functions to allow (e.g. `"List.tryFind"`) -* *additionalPartials* - list of strings representing additional partial functions to disallow +* *allowedPartials* - list of strings representing partial functions to allow (e.g. `"List.tryFind"`). +* *additionalPartials* - list of strings representing additional partial functions to disallow. diff --git a/docs/content/how-tos/rules/FL0067.md b/docs/content/how-tos/rules/FL0067.md index 8e49f0743..8f21caa22 100644 --- a/docs/content/how-tos/rules/FL0067.md +++ b/docs/content/how-tos/rules/FL0067.md @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0068.md b/docs/content/how-tos/rules/FL0068.md index 1fec618be..c6723bde0 100644 --- a/docs/content/how-tos/rules/FL0068.md +++ b/docs/content/how-tos/rules/FL0068.md @@ -18,7 +18,7 @@ Consistency aides readability. ## How To Fix -Update the internal value's naming to be consistent with the rules you have specified +Update the internal value's naming to be consistent with the rules you have specified. ## Rule Settings @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0069.md b/docs/content/how-tos/rules/FL0069.md index de8455875..6400a5ab6 100644 --- a/docs/content/how-tos/rules/FL0069.md +++ b/docs/content/how-tos/rules/FL0069.md @@ -18,7 +18,7 @@ Consistency aides readability. ## How To Fix -Update the generic type naming to be consistent with the rules you have specified +Update the generic type naming to be consistent with the rules you have specified. ## Rule Settings @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked. } } -* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase") -* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None") +* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase". +* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None". * *prefix* - prefix string expected on the front of the identifiers. * *suffix* - suffix string expected on the end of the identifiers. diff --git a/docs/content/how-tos/rules/FL0086.md b/docs/content/how-tos/rules/FL0086.md index 30af8dc5b..4a5c77117 100644 --- a/docs/content/how-tos/rules/FL0086.md +++ b/docs/content/how-tos/rules/FL0086.md @@ -10,15 +10,15 @@ hide_menu: true ## Cause -A named pattern is used just to be compared in the guard against a constant expression e.g. `match something with | bar when bar = "baz" -> ()` +A named pattern is used just to be compared in the guard against a constant expression e.g. `match something with | bar when bar = "baz" -> ()`. ## Rationale -The named pattern can be changed to an as pattern that uses a constant pattern, improving the pattern matching exhaustiveness check +The named pattern can be changed to an as pattern that uses a constant pattern, improving the pattern matching exhaustiveness check. ## How To Fix -Remove the guard and replace the named pattern with the as pattern using a constant pattern, e.g. change `match something with | bar when bar = "baz" -> ()` to `match something with | "baz" as bar -> ()` +Remove the guard and replace the named pattern with the as pattern using a constant pattern, e.g. change `match something with | bar when bar = "baz" -> ()` to `match something with | "baz" as bar -> ()`. ## Rule Settings diff --git a/src/FSharpLint.Core/Framework/Rules.fs b/src/FSharpLint.Core/Framework/Rules.fs index 2be7d3398..2877244ab 100644 --- a/src/FSharpLint.Core/Framework/Rules.fs +++ b/src/FSharpLint.Core/Framework/Rules.fs @@ -53,11 +53,14 @@ type AstNodeRuleConfig = type NamingCase = | PascalCase = 0 | CamelCase = 1 + | AllLowercase = 2 + | AllUppercase = 3 type NamingUnderscores = | None = 0 | AllowPrefix = 1 | AllowAny = 2 + | AllowInfix = 3 type NamingConfig = { Naming:NamingCase option diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/LiteralNames.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/LiteralNames.fs index 2d8df210c..632847507 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/LiteralNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/LiteralNames.fs @@ -12,6 +12,8 @@ let private getIdentifiers (args:AstNodeRuleParams) = let rec getLiteralIdents = function | SynPat.Named(SynIdent(identifier, _), _, _, _) -> Array.singleton (identifier, identifier.idText, None) + | SynPat.LongIdent(SynLongIdent([identifier], _, _), _, _, _, _, _) -> + Array.singleton (identifier, identifier.idText, None) | SynPat.Paren(pat, _) -> getLiteralIdents pat | _ -> Array.empty diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs index 91a685000..8e8fd6f4e 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs @@ -24,6 +24,10 @@ module QuickFixes = let toText = prefixingUnderscores + ident.idText.Replace("_", String.Empty) Some { FromText = ident.idText; FromRange = ident.idRange; ToText = toText }) + let removePrefixingAndSuffixingUnderscores (ident:Ident) = lazy( + let toText = ident.idText.Trim '_' + Some { FromText = ident.idText; FromRange = ident.idRange; ToText = toText }) + let addPrefix prefix (ident:Ident) = lazy( Some { FromText = ident.idText; FromRange = ident.idRange; ToText = prefix + ident.idText }) @@ -48,6 +52,35 @@ module QuickFixes = let camelCaseIdent = mapFirstChar Char.ToLower ident.idText Some { FromText = ident.idText; FromRange = ident.idRange; ToText = camelCaseIdent }) + let splitByCaseChange (name: string) : seq = + let partitionPoints = + seq { + yield 0 + for (index, (current, next)) in name |> Seq.pairwise |> Seq.indexed do + if (Char.IsUpper next || not (Char.IsLetter next)) && not (Char.IsUpper current) then + yield index + 1 + yield name.Length + } + seq { + for (start, finish) in Seq.pairwise partitionPoints do + yield name.Substring(start, finish - start) + } + + let private convertAllToCase (caseMapping: string -> string) (underscoresConfig: Option) (ident:Ident) = + lazy( + let newIdent = + match underscoresConfig with + | Some NamingUnderscores.AllowAny | Some NamingUnderscores.AllowInfix -> + let parts = splitByCaseChange ident.idText |> Seq.map caseMapping + String.Join('_', parts) + | _ -> caseMapping ident.idText + Some { FromText = ident.idText; FromRange = ident.idRange; ToText = newIdent } + ) + + let toAllLowercase = convertAllToCase (fun part -> part.ToLower()) + + let toAllUppercase = convertAllToCase (fun part -> part.ToUpper()) + [] let private NumberOfExpectedBackticks = 4 @@ -75,6 +108,12 @@ let isCamelCase (identifier:string) = if withoutUnderscorePrefix.Length = 0 then true else Char.IsLower withoutUnderscorePrefix.[0] +let isAllLowercase (identifier:string) = + Seq.forall (fun char -> Char.IsLower char || (not <| Char.IsLetter char)) identifier + +let isAllUppercase (identifier:string) = + Seq.forall (fun char -> Char.IsUpper char || (not <| Char.IsLetter char)) identifier + let private pascalCaseRule (identifier:string) = if not (isPascalCase identifier) then Some "RulesNamingConventionsPascalCaseError" else None @@ -83,12 +122,26 @@ let private camelCaseRule (identifier:string) = if not (isCamelCase identifier) then Some "RulesNamingConventionsCamelCaseError" else None -let private underscoreRule allowPrefix (identifier:string) = - if allowPrefix && identifier.TrimStart('_').Contains("_") then - Some "RulesNamingConventionsUnderscoreError" - else if not allowPrefix && identifier.Contains("_") then - Some "RulesNamingConventionsUnderscoreError" - else +let private uppercaseRule (identifier:string) = + if not (isAllUppercase identifier) then Some "RulesNamingConventionsUppercaseError" + else None + +let private lowercaseRule (identifier:string) = + if not (isAllLowercase identifier) then Some "RulesNamingConventionsLowercaseError" + else None + + +let private underscoreRule (underscoreMode: NamingUnderscores) (identifier:string) = + let errorKeyToRemoveUnderscores = "RulesNamingConventionsUnderscoreError" + let errorKeyToRemoveLeadingOrTrailingUnderscores = "RulesNamingConventionsNoInfixUnderscoreError" + match underscoreMode with + | NamingUnderscores.AllowPrefix when identifier.TrimStart('_').Contains '_' -> + Some errorKeyToRemoveUnderscores + | NamingUnderscores.None when identifier.Contains '_' -> + Some errorKeyToRemoveUnderscores + | NamingUnderscores.AllowInfix when (identifier.StartsWith '_' || identifier.EndsWith '_') -> + Some errorKeyToRemoveLeadingOrTrailingUnderscores + | _ -> None let private prefixRule (prefix:string) (identifier:string) = @@ -116,16 +169,25 @@ let private checkIdentifierPart (config:NamingConfig) (identifier:Ident) (idText | Some NamingCase.CamelCase -> camelCaseRule idText |> Option.map (formatError >> tryAddFix QuickFixes.toCamelCase) + | Some NamingCase.AllLowercase -> + lowercaseRule idText + |> Option.map (formatError >> tryAddFix (QuickFixes.toAllLowercase config.Underscores)) + | Some NamingCase.AllUppercase -> + uppercaseRule idText + |> Option.map (formatError >> tryAddFix (QuickFixes.toAllUppercase config.Underscores)) | _ -> None let underscoresError = match config.Underscores with - | Some NamingUnderscores.None -> - underscoreRule false idText + | Some (NamingUnderscores.None as nuCfg) -> + underscoreRule nuCfg idText |> Option.map (formatError >> tryAddFix QuickFixes.removeAllUnderscores) - | Some NamingUnderscores.AllowPrefix -> - underscoreRule true idText + | Some (NamingUnderscores.AllowPrefix as nuCfg) -> + underscoreRule nuCfg idText |> Option.map (formatError >> tryAddFix QuickFixes.removeNonPrefixingUnderscores) + | Some (NamingUnderscores.AllowInfix as nuCfg) -> + underscoreRule nuCfg idText + |> Option.map (formatError >> tryAddFix QuickFixes.removePrefixingAndSuffixingUnderscores) | _ -> None let prefixError = diff --git a/src/FSharpLint.Core/Text.resx b/src/FSharpLint.Core/Text.resx index 17681b968..642d9b6dc 100644 --- a/src/FSharpLint.Core/Text.resx +++ b/src/FSharpLint.Core/Text.resx @@ -174,6 +174,15 @@ Consider changing `{0}` to remove any underscores. + + Consider removing any leading or trailing underscore from `{0}`. + + + Consider changing `{0}` to uppercase. + + + Consider changing `{0}` to lowercase. + Consider using a longer name, as it is currently too short. diff --git a/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/LiteralNames.fs b/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/LiteralNames.fs index 0304628ff..29931c5e9 100644 --- a/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/LiteralNames.fs +++ b/tests/FSharpLint.Core.Tests/Rules/Conventions/Naming/LiteralNames.fs @@ -10,6 +10,7 @@ let config = Underscores = Some NamingUnderscores.None Prefix = None Suffix = None } + [] type TestConventionsLiteralNames() = inherit TestAstNodeRuleBase.TestAstNodeRuleBase(LiteralNames.rule config) @@ -69,3 +70,100 @@ let cat = 5 Assert.IsTrue(this.ErrorExistsAt(5, 4)) +let infixConfig = + { NamingConfig.Naming = Some NamingCase.AllLowercase + Underscores = Some NamingUnderscores.AllowInfix + Prefix = None + Suffix = None } + +[] +type TestConventionsLiteralNamesInfix() = + inherit TestAstNodeRuleBase.TestAstNodeRuleBase(LiteralNames.rule infixConfig) + + [] + member this.LiteralIsInfixUnderscore() = + this.Parse """ +module Program + +[] +let super_cat = 5 +""" + + this.AssertNoWarnings() + + [] + member this.LiteralIsUnderscorePrefix() = + this.Parse """ +module Program + +[] +let _cat = 5 +""" + + Assert.IsTrue(this.ErrorExistsOnLine 5) + + [] + member this.LiteralIsUnderscoreSuffix() = + this.Parse """ +module Program + +[] +let cat_ = 5 +""" + + Assert.IsTrue(this.ErrorExistsOnLine 5) + + [] + member this.LiteralIsNoUnderscore() = + this.Parse """ +module Program + +[] +let SuperCat = 5 +""" + + Assert.IsTrue(this.ErrorExistsOnLine 5) + + [] + member this.SuggestedFix() = + let source = """ +module Program + +[] +let superCat = 5 +""" + let expected = """ +module Program + +[] +let super_cat = 5 +""" + this.Parse source + + Assert.IsTrue(this.ErrorExistsOnLine 5) + + let result = this.ApplyQuickFix source + + Assert.AreEqual(expected, result) + + [] + member this.SuggestedFixForComplexName() = + let source = """ +module Program + +[] +let SuperCatWith1Number = 5 +""" + let expected = """ +module Program + +[] +let super_cat_with_1_number = 5 +""" + this.Parse source + + Assert.IsTrue(this.ErrorExistsOnLine 5) + + let result = this.ApplyQuickFix source + + Assert.AreEqual(expected, result)