FSharpLint icon indicating copy to clipboard operation
FSharpLint copied to clipboard

Wording of lint warnings

Open duckmatt opened this issue 8 years ago • 1 comments

Currently the descriptions of the rules are far from perfect, community feedback and proposals to help improve them would be amazing, this is the place to do it! The location of the format strings in the project is here, and below in a more readable table:

Warning Warning Message Proposed Message
RulesCanBeReplacedWithComposition Lambda may be able to be replaced with composition. e.g. `fun x -> x > isValid
RulesFailwithfWithArgumentsMatchingFormatString failwithf has more arguments than were found in its format string, these further arguments will be ignored by the compiler.
RulesFailwithWithSingleArgument failwith should have a single argument, further arguments will be ignored by the compiler.
RulesFavourIgnoreOverLetWildError The ignore function is usually favoured over let _ = ... when ignoring the result of an expression.
RulesHintRefactor {0} might be able to be refactored into {1}.
RulesHintSuggestion {0}; suggestion: {1}.
RulesInvalidArgWithTwoArguments invalidArg should have two arguments, further arguments will be ignored by the compiler.
RulesInvalidOpWithSingleArgument invalidOp should have a single argument, further arguments will be ignored by the compiler.
RulesNamingConventionsCamelCaseError Consider changing {0} to camelCase.
RulesNamingConventionsExceptionError Consider changing {0} to be suffixed with 'Exception'.
RulesNamingConventionsInterfaceError Consider changing {0} to be prefix with 'I'.
RulesNamingConventionsPascalCaseError Consider changing {0} to PascalCase.
RulesNamingConventionsUnderscoreError Consider changing {0} to remove any underscores.
RulesNestedStatementsError Code suggested not to be nested more deeply than a depth of {0}.
RulesNullArgWithSingleArgument nullArg should have a single argument, further arguments will be ignored by the compiler.
RulesNumberOfItemsBooleanConditionsError Conditions suggested to contain at most {0} boolean operators.
RulesNumberOfItemsClassMembersError Class suggested to have a maximum of {0} members.
RulesNumberOfItemsFunctionError Functions suggested to have a maximum of {0} parameters.
RulesNumberOfItemsTupleError Tuple suggested to have a maximum of {0} items.
RulesRaiseWithSingleArgument raise should have a single argument, further arguments will be ignored by the compiler.
RulesReimplementsFunction If {0} has no mutable arguments partially applied then the lambda can be removed.
RulesSourceLengthError {0} was {2} lines long, suggested to be less than {1} lines long.
RulesTupleOfWildcardsError A tuple of wildcards in a pattern can be replaced with a single wildcard. {0} can be replaced with {1}.
RulesTypographyFileLengthError File suggested to be less than {0} lines long.
RulesTypographyLineLengthError Line suggested to be less than {0} characters long.
RulesTypographyTabCharacterError Consider replacing tab (\t) with spaces.
RulesTypographyTrailingLineError Found trailing whitespace line at end of file.
RulesTypographyTrailingWhitespaceError Found trailing whitespace at end of line.
RulesUselessBindingError Binding appears to have no purpose.
RulesWildcardNamedWithAsPattern Unnecessary wildcard named using the as pattern, the wildcard can be removed e.g. _ as x replaced with x.
RulesXmlDocumentationAutoPropertyError Auto property {0} suggested to have xml documentation.
RulesXmlDocumentationEnumError Enum {0} suggested to have xml documentation.
RulesXmlDocumentationExceptionError Exception type suggested to have xml documentation.
RulesXmlDocumentationLetError Let binding suggested to have xml documentation.
RulesXmlDocumentationMemberError Member suggested to have xml documentation.
RulesXmlDocumentationModuleError Module suggested to have xml documentation.
RulesXmlDocumentationRecordError Record field {0} suggested to have xml documentation.
RulesXmlDocumentationTypeError Type suggested to have xml documentation.
RulesXmlDocumentationUnionError Union case {0} suggested to have xml documentation.

Please add a comment or make a pull request if you would like to see changes to the descriptions of the warnings

duckmatt avatar Sep 13 '16 22:09 duckmatt

One thing I found when looking at these messages, is that most of them state what is wrong, but not what the user can do to fix it.

For example, the RulesNamingConventionsExceptionError currently is:

Consider changing {0} to be suffixed with 'Exception'.

For an exception type named ProtocolFailure, this would give the following error

Consider changing ProtocolFailure to be suffixed with 'Exception'.

As the hint already knows what the correct solution would be, I think it makes sense to show that in the error message too:

Consider changing ProtocolFailure to be suffixed with 'Exception'. Suggested name: ProtocolFailureException.

Or something like that. The same goes for several other rules, including RulesNamingConventionsInterfaceError, RulesNamingConventionsCamelCaseError, and RulesFailwithfWithArgumentsMatchingFormatString.

The RulesTupleOfWildcardsError is a good example that already shows what action it expects the user to take:

A tuple of wildcards in a pattern can be replaced with a single wildcard. {0} can be replaced with {1}.

ErikSchierboom avatar Oct 21 '16 10:10 ErikSchierboom