diff --git a/src/FSharpLint.Core/Application/Configuration.fs b/src/FSharpLint.Core/Application/Configuration.fs index fca4918a1..ee0dbe9ad 100644 --- a/src/FSharpLint.Core/Application/Configuration.fs +++ b/src/FSharpLint.Core/Application/Configuration.fs @@ -87,9 +87,9 @@ module IgnoreFiles = let private pathMatchesGlob (globs:Regex list) (path:string list) isDirectory = let rec getRemainingGlobSeqForMatches pathSegment (globSeqs:Regex list list) = - globSeqs |> List.choose (function - | globSegment::remaining when globSegment.IsMatch(pathSegment) -> Some remaining - | _ -> None) + List.choose (function + | (globSegment: Regex)::remaining when globSegment.IsMatch(pathSegment) -> Some remaining + | _ -> None) globSeqs let rec doesGlobSeqMatchPathSeq remainingPath currentlyMatchingGlobs = match remainingPath with @@ -99,7 +99,7 @@ module IgnoreFiles = let currentlyMatchingGlobs = getRemainingGlobSeqForMatches currentSegment currentlyMatchingGlobs - let aGlobWasCompletelyMatched = currentlyMatchingGlobs |> List.exists List.isEmpty + let aGlobWasCompletelyMatched = List.exists List.isEmpty currentlyMatchingGlobs let matched = aGlobWasCompletelyMatched && (isDirectory || (not isDirectory && List.isEmpty remaining)) @@ -139,7 +139,7 @@ let constructRuleWithConfig rule ruleConfig = let constructTypePrefixingRuleWithConfig rule (ruleConfig: RuleConfig) = if ruleConfig.Enabled then - let config = ruleConfig.Config |> Option.defaultValue { Mode = TypePrefixing.Mode.Hybrid } + let config = Option.defaultValue { Mode = TypePrefixing.Mode.Hybrid } ruleConfig.Config Some(rule config) else None @@ -150,11 +150,12 @@ type TupleFormattingConfig = tupleParentheses:EnabledConfig option } with member this.Flatten() = - [| - this.tupleCommaSpacing |> Option.bind (constructRuleIfEnabled TupleCommaSpacing.rule) - this.tupleIndentation |> Option.bind (constructRuleIfEnabled TupleIndentation.rule) - this.tupleParentheses |> Option.bind (constructRuleIfEnabled TupleParentheses.rule) - |] |> Array.choose id + Array.choose id + [| + this.tupleCommaSpacing |> Option.bind (constructRuleIfEnabled TupleCommaSpacing.rule) + this.tupleIndentation |> Option.bind (constructRuleIfEnabled TupleIndentation.rule) + this.tupleParentheses |> Option.bind (constructRuleIfEnabled TupleParentheses.rule) + |] type PatternMatchFormattingConfig = { patternMatchClausesOnNewLine:EnabledConfig option @@ -163,12 +164,13 @@ type PatternMatchFormattingConfig = patternMatchExpressionIndentation:EnabledConfig option } with member this.Flatten() = - [| - this.patternMatchClausesOnNewLine |> Option.bind (constructRuleIfEnabled PatternMatchClausesOnNewLine.rule) - this.patternMatchOrClausesOnNewLine |> Option.bind (constructRuleIfEnabled PatternMatchOrClausesOnNewLine.rule) - this.patternMatchClauseIndentation |> Option.bind (constructRuleWithConfig PatternMatchClauseIndentation.rule) - this.patternMatchExpressionIndentation |> Option.bind (constructRuleIfEnabled PatternMatchExpressionIndentation.rule) - |] |> Array.choose id + Array.choose id + [| + this.patternMatchClausesOnNewLine |> Option.bind (constructRuleIfEnabled PatternMatchClausesOnNewLine.rule) + this.patternMatchOrClausesOnNewLine |> Option.bind (constructRuleIfEnabled PatternMatchOrClausesOnNewLine.rule) + this.patternMatchClauseIndentation |> Option.bind (constructRuleWithConfig PatternMatchClauseIndentation.rule) + this.patternMatchExpressionIndentation |> Option.bind (constructRuleIfEnabled PatternMatchExpressionIndentation.rule) + |] type FormattingConfig = { typedItemSpacing:RuleConfig option @@ -180,15 +182,16 @@ type FormattingConfig = patternMatchFormatting:PatternMatchFormattingConfig option } with member this.Flatten() = - [| - this.typedItemSpacing |> Option.bind (constructRuleWithConfig TypedItemSpacing.rule) |> Option.toArray - this.typePrefixing |> Option.bind (constructTypePrefixingRuleWithConfig TypePrefixing.rule) |> Option.toArray - this.unionDefinitionIndentation |> Option.bind (constructRuleIfEnabled UnionDefinitionIndentation.rule) |> Option.toArray - this.moduleDeclSpacing |> Option.bind (constructRuleIfEnabled ModuleDeclSpacing.rule) |> Option.toArray - this.classMemberSpacing |> Option.bind (constructRuleIfEnabled ClassMemberSpacing.rule) |> Option.toArray - this.tupleFormatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - this.patternMatchFormatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - |] |> Array.concat + Array.concat + [| + this.typedItemSpacing |> Option.bind (constructRuleWithConfig TypedItemSpacing.rule) |> Option.toArray + this.typePrefixing |> Option.bind (constructTypePrefixingRuleWithConfig TypePrefixing.rule) |> Option.toArray + this.unionDefinitionIndentation |> Option.bind (constructRuleIfEnabled UnionDefinitionIndentation.rule) |> Option.toArray + this.moduleDeclSpacing |> Option.bind (constructRuleIfEnabled ModuleDeclSpacing.rule) |> Option.toArray + this.classMemberSpacing |> Option.bind (constructRuleIfEnabled ClassMemberSpacing.rule) |> Option.toArray + this.tupleFormatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + this.patternMatchFormatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + |] type RaiseWithTooManyArgsConfig = { failwithBadUsage:EnabledConfig option @@ -199,14 +202,15 @@ type RaiseWithTooManyArgsConfig = failwithfWithArgumentsMatchingFormatString:EnabledConfig option } with member this.Flatten() = - [| - this.failwithBadUsage |> Option.bind (constructRuleIfEnabled FailwithBadUsage.rule) |> Option.toArray - this.raiseWithSingleArgument |> Option.bind (constructRuleIfEnabled RaiseWithSingleArgument.rule) |> Option.toArray - this.nullArgWithSingleArgument |> Option.bind (constructRuleIfEnabled NullArgWithSingleArgument.rule) |> Option.toArray - this.invalidOpWithSingleArgument |> Option.bind (constructRuleIfEnabled InvalidOpWithSingleArgument.rule) |> Option.toArray - this.invalidArgWithTwoArguments |> Option.bind (constructRuleIfEnabled InvalidArgWithTwoArguments.rule) |> Option.toArray - this.failwithfWithArgumentsMatchingFormatString |> Option.bind (constructRuleIfEnabled FailwithfWithArgumentsMatchingFormatString.rule) |> Option.toArray - |] |> Array.concat + Array.concat + [| + this.failwithBadUsage |> Option.bind (constructRuleIfEnabled FailwithBadUsage.rule) |> Option.toArray + this.raiseWithSingleArgument |> Option.bind (constructRuleIfEnabled RaiseWithSingleArgument.rule) |> Option.toArray + this.nullArgWithSingleArgument |> Option.bind (constructRuleIfEnabled NullArgWithSingleArgument.rule) |> Option.toArray + this.invalidOpWithSingleArgument |> Option.bind (constructRuleIfEnabled InvalidOpWithSingleArgument.rule) |> Option.toArray + this.invalidArgWithTwoArguments |> Option.bind (constructRuleIfEnabled InvalidArgWithTwoArguments.rule) |> Option.toArray + this.failwithfWithArgumentsMatchingFormatString |> Option.bind (constructRuleIfEnabled FailwithfWithArgumentsMatchingFormatString.rule) |> Option.toArray + |] type SourceLengthConfig = { maxLinesInLambdaFunction:RuleConfig option @@ -223,20 +227,21 @@ type SourceLengthConfig = maxLinesInClass:RuleConfig option } with member this.Flatten() = - [| - this.maxLinesInLambdaFunction |> Option.bind (constructRuleWithConfig MaxLinesInLambdaFunction.rule) |> Option.toArray - this.maxLinesInMatchLambdaFunction |> Option.bind (constructRuleWithConfig MaxLinesInMatchLambdaFunction.rule) |> Option.toArray - this.maxLinesInValue |> Option.bind (constructRuleWithConfig MaxLinesInValue.rule) |> Option.toArray - this.maxLinesInFunction |> Option.bind (constructRuleWithConfig MaxLinesInFunction.rule) |> Option.toArray - this.maxLinesInMember |> Option.bind (constructRuleWithConfig MaxLinesInMember.rule) |> Option.toArray - this.maxLinesInConstructor |> Option.bind (constructRuleWithConfig MaxLinesInConstructor.rule) |> Option.toArray - this.maxLinesInProperty |> Option.bind (constructRuleWithConfig MaxLinesInProperty.rule) |> Option.toArray - this.maxLinesInModule |> Option.bind (constructRuleWithConfig MaxLinesInModule.rule) |> Option.toArray - this.maxLinesInRecord |> Option.bind (constructRuleWithConfig MaxLinesInRecord.rule) |> Option.toArray - this.maxLinesInEnum |> Option.bind (constructRuleWithConfig MaxLinesInEnum.rule) |> Option.toArray - this.maxLinesInUnion |> Option.bind (constructRuleWithConfig MaxLinesInUnion.rule) |> Option.toArray - this.maxLinesInClass |> Option.bind (constructRuleWithConfig MaxLinesInClass.rule) |> Option.toArray - |] |> Array.concat + Array.concat + [| + this.maxLinesInLambdaFunction |> Option.bind (constructRuleWithConfig MaxLinesInLambdaFunction.rule) |> Option.toArray + this.maxLinesInMatchLambdaFunction |> Option.bind (constructRuleWithConfig MaxLinesInMatchLambdaFunction.rule) |> Option.toArray + this.maxLinesInValue |> Option.bind (constructRuleWithConfig MaxLinesInValue.rule) |> Option.toArray + this.maxLinesInFunction |> Option.bind (constructRuleWithConfig MaxLinesInFunction.rule) |> Option.toArray + this.maxLinesInMember |> Option.bind (constructRuleWithConfig MaxLinesInMember.rule) |> Option.toArray + this.maxLinesInConstructor |> Option.bind (constructRuleWithConfig MaxLinesInConstructor.rule) |> Option.toArray + this.maxLinesInProperty |> Option.bind (constructRuleWithConfig MaxLinesInProperty.rule) |> Option.toArray + this.maxLinesInModule |> Option.bind (constructRuleWithConfig MaxLinesInModule.rule) |> Option.toArray + this.maxLinesInRecord |> Option.bind (constructRuleWithConfig MaxLinesInRecord.rule) |> Option.toArray + this.maxLinesInEnum |> Option.bind (constructRuleWithConfig MaxLinesInEnum.rule) |> Option.toArray + this.maxLinesInUnion |> Option.bind (constructRuleWithConfig MaxLinesInUnion.rule) |> Option.toArray + this.maxLinesInClass |> Option.bind (constructRuleWithConfig MaxLinesInClass.rule) |> Option.toArray + |] type NamesConfig = { interfaceNames:RuleConfig option @@ -259,27 +264,28 @@ type NamesConfig = internalValuesNames:RuleConfig option } with member this.Flatten() = - [| - this.interfaceNames |> Option.bind (constructRuleWithConfig InterfaceNames.rule) |> Option.toArray - this.genericTypesNames |> Option.bind (constructRuleWithConfig GenericTypesNames.rule) |> Option.toArray - this.exceptionNames |> Option.bind (constructRuleWithConfig ExceptionNames.rule) |> Option.toArray - this.typeNames |> Option.bind (constructRuleWithConfig TypeNames.rule) |> Option.toArray - this.recordFieldNames |> Option.bind (constructRuleWithConfig RecordFieldNames.rule) |> Option.toArray - this.enumCasesNames |> Option.bind (constructRuleWithConfig EnumCasesNames.rule) |> Option.toArray - this.unionCasesNames |> Option.bind (constructRuleWithConfig UnionCasesNames.rule) |> Option.toArray - this.moduleNames |> Option.bind (constructRuleWithConfig ModuleNames.rule) |> Option.toArray - this.literalNames |> Option.bind (constructRuleWithConfig LiteralNames.rule) |> Option.toArray - this.namespaceNames |> Option.bind (constructRuleWithConfig NamespaceNames.rule) |> Option.toArray - this.memberNames |> Option.bind (constructRuleWithConfig MemberNames.rule) |> Option.toArray - this.parameterNames |> Option.bind (constructRuleWithConfig ParameterNames.rule) |> Option.toArray - this.measureTypeNames |> Option.bind (constructRuleWithConfig MeasureTypeNames.rule) |> Option.toArray - this.activePatternNames |> Option.bind (constructRuleWithConfig ActivePatternNames.rule) |> Option.toArray - this.publicValuesNames |> Option.bind (constructRuleWithConfig PublicValuesNames.rule) |> Option.toArray - this.nonPublicValuesNames |> Option.bind (constructRuleWithConfig PrivateValuesNames.rule) |> Option.toArray - this.nonPublicValuesNames |> Option.bind (constructRuleWithConfig InternalValuesNames.rule) |> Option.toArray - this.privateValuesNames |> Option.bind (constructRuleWithConfig PrivateValuesNames.rule) |> Option.toArray - this.internalValuesNames|> Option.bind (constructRuleWithConfig InternalValuesNames.rule) |> Option.toArray - |] |> Array.concat + Array.concat + [| + this.interfaceNames |> Option.bind (constructRuleWithConfig InterfaceNames.rule) |> Option.toArray + this.genericTypesNames |> Option.bind (constructRuleWithConfig GenericTypesNames.rule) |> Option.toArray + this.exceptionNames |> Option.bind (constructRuleWithConfig ExceptionNames.rule) |> Option.toArray + this.typeNames |> Option.bind (constructRuleWithConfig TypeNames.rule) |> Option.toArray + this.recordFieldNames |> Option.bind (constructRuleWithConfig RecordFieldNames.rule) |> Option.toArray + this.enumCasesNames |> Option.bind (constructRuleWithConfig EnumCasesNames.rule) |> Option.toArray + this.unionCasesNames |> Option.bind (constructRuleWithConfig UnionCasesNames.rule) |> Option.toArray + this.moduleNames |> Option.bind (constructRuleWithConfig ModuleNames.rule) |> Option.toArray + this.literalNames |> Option.bind (constructRuleWithConfig LiteralNames.rule) |> Option.toArray + this.namespaceNames |> Option.bind (constructRuleWithConfig NamespaceNames.rule) |> Option.toArray + this.memberNames |> Option.bind (constructRuleWithConfig MemberNames.rule) |> Option.toArray + this.parameterNames |> Option.bind (constructRuleWithConfig ParameterNames.rule) |> Option.toArray + this.measureTypeNames |> Option.bind (constructRuleWithConfig MeasureTypeNames.rule) |> Option.toArray + this.activePatternNames |> Option.bind (constructRuleWithConfig ActivePatternNames.rule) |> Option.toArray + this.publicValuesNames |> Option.bind (constructRuleWithConfig PublicValuesNames.rule) |> Option.toArray + this.nonPublicValuesNames |> Option.bind (constructRuleWithConfig PrivateValuesNames.rule) |> Option.toArray + this.nonPublicValuesNames |> Option.bind (constructRuleWithConfig InternalValuesNames.rule) |> Option.toArray + this.privateValuesNames |> Option.bind (constructRuleWithConfig PrivateValuesNames.rule) |> Option.toArray + this.internalValuesNames|> Option.bind (constructRuleWithConfig InternalValuesNames.rule) |> Option.toArray + |] type NumberOfItemsConfig = { maxNumberOfItemsInTuple:RuleConfig option @@ -288,12 +294,13 @@ type NumberOfItemsConfig = maxNumberOfBooleanOperatorsInCondition:RuleConfig option } with member this.Flatten() = - [| - this.maxNumberOfItemsInTuple |> Option.bind (constructRuleWithConfig MaxNumberOfItemsInTuple.rule) |> Option.toArray - this.maxNumberOfFunctionParameters |> Option.bind (constructRuleWithConfig MaxNumberOfFunctionParameters.rule) |> Option.toArray - this.maxNumberOfMembers |> Option.bind (constructRuleWithConfig MaxNumberOfMembers.rule) |> Option.toArray - this.maxNumberOfBooleanOperatorsInCondition |> Option.bind (constructRuleWithConfig MaxNumberOfBooleanOperatorsInCondition.rule) |> Option.toArray - |] |> Array.concat + Array.concat + [| + this.maxNumberOfItemsInTuple |> Option.bind (constructRuleWithConfig MaxNumberOfItemsInTuple.rule) |> Option.toArray + this.maxNumberOfFunctionParameters |> Option.bind (constructRuleWithConfig MaxNumberOfFunctionParameters.rule) |> Option.toArray + this.maxNumberOfMembers |> Option.bind (constructRuleWithConfig MaxNumberOfMembers.rule) |> Option.toArray + this.maxNumberOfBooleanOperatorsInCondition |> Option.bind (constructRuleWithConfig MaxNumberOfBooleanOperatorsInCondition.rule) |> Option.toArray + |] type BindingConfig = { favourIgnoreOverLetWild:EnabledConfig option @@ -303,13 +310,14 @@ type BindingConfig = favourTypedIgnore:EnabledConfig option } with member this.Flatten() = - [| - this.favourIgnoreOverLetWild |> Option.bind (constructRuleIfEnabled FavourIgnoreOverLetWild.rule) |> Option.toArray - this.favourTypedIgnore |> Option.bind (constructRuleIfEnabled FavourTypedIgnore.rule) |> Option.toArray - this.wildcardNamedWithAsPattern |> Option.bind (constructRuleIfEnabled WildcardNamedWithAsPattern.rule) |> Option.toArray - this.uselessBinding |> Option.bind (constructRuleIfEnabled UselessBinding.rule) |> Option.toArray - this.tupleOfWildcards |> Option.bind (constructRuleIfEnabled TupleOfWildcards.rule) |> Option.toArray - |] |> Array.concat + Array.concat + [| + this.favourIgnoreOverLetWild |> Option.bind (constructRuleIfEnabled FavourIgnoreOverLetWild.rule) |> Option.toArray + this.favourTypedIgnore |> Option.bind (constructRuleIfEnabled FavourTypedIgnore.rule) |> Option.toArray + this.wildcardNamedWithAsPattern |> Option.bind (constructRuleIfEnabled WildcardNamedWithAsPattern.rule) |> Option.toArray + this.uselessBinding |> Option.bind (constructRuleIfEnabled UselessBinding.rule) |> Option.toArray + this.tupleOfWildcards |> Option.bind (constructRuleIfEnabled TupleOfWildcards.rule) |> Option.toArray + |] type ConventionsConfig = { recursiveAsyncFunction:EnabledConfig option @@ -334,28 +342,29 @@ type ConventionsConfig = usedUnderscorePrefixedElements:EnabledConfig option } with member this.Flatten() = - [| - this.recursiveAsyncFunction |> Option.bind (constructRuleIfEnabled RecursiveAsyncFunction.rule) |> Option.toArray - this.avoidTooShortNames |> Option.bind (constructRuleIfEnabled AvoidTooShortNames.rule) |> Option.toArray - this.redundantNewKeyword |> Option.bind (constructRuleIfEnabled RedundantNewKeyword.rule) |> Option.toArray - this.favourReRaise |> Option.bind (constructRuleIfEnabled FavourReRaise.rule) |> Option.toArray - this.favourStaticEmptyFields |> Option.bind (constructRuleIfEnabled FavourStaticEmptyFields.rule) |> Option.toArray - this.asyncExceptionWithoutReturn |> Option.bind (constructRuleIfEnabled AsyncExceptionWithoutReturn.rule) |> Option.toArray - this.unneededRecKeyword |> Option.bind (constructRuleIfEnabled UnneededRecKeyword.rule) |> Option.toArray - this.nestedStatements |> Option.bind (constructRuleWithConfig NestedStatements.rule) |> Option.toArray - this.favourConsistentThis |> Option.bind (constructRuleWithConfig FavourConsistentThis.rule) |> Option.toArray - this.cyclomaticComplexity |> Option.bind (constructRuleWithConfig CyclomaticComplexity.rule) |> Option.toArray - this.reimplementsFunction |> Option.bind (constructRuleIfEnabled ReimplementsFunction.rule) |> Option.toArray - this.canBeReplacedWithComposition |> Option.bind (constructRuleIfEnabled CanBeReplacedWithComposition.rule) |> Option.toArray - this.avoidSinglePipeOperator|> Option.bind (constructRuleIfEnabled AvoidSinglePipeOperator.rule) |> Option.toArray - this.usedUnderscorePrefixedElements |> Option.bind (constructRuleIfEnabled UsedUnderscorePrefixedElements.rule) |> Option.toArray - this.raiseWithTooManyArgs |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - this.sourceLength |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - this.naming |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - this.numberOfItems |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - this.binding |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - this.suggestUseAutoProperty |> Option.bind (constructRuleIfEnabled SuggestUseAutoProperty.rule) |> Option.toArray - |] |> Array.concat + Array.concat + [| + this.recursiveAsyncFunction |> Option.bind (constructRuleIfEnabled RecursiveAsyncFunction.rule) |> Option.toArray + this.avoidTooShortNames |> Option.bind (constructRuleIfEnabled AvoidTooShortNames.rule) |> Option.toArray + this.redundantNewKeyword |> Option.bind (constructRuleIfEnabled RedundantNewKeyword.rule) |> Option.toArray + this.favourReRaise |> Option.bind (constructRuleIfEnabled FavourReRaise.rule) |> Option.toArray + this.favourStaticEmptyFields |> Option.bind (constructRuleIfEnabled FavourStaticEmptyFields.rule) |> Option.toArray + this.asyncExceptionWithoutReturn |> Option.bind (constructRuleIfEnabled AsyncExceptionWithoutReturn.rule) |> Option.toArray + this.unneededRecKeyword |> Option.bind (constructRuleIfEnabled UnneededRecKeyword.rule) |> Option.toArray + this.nestedStatements |> Option.bind (constructRuleWithConfig NestedStatements.rule) |> Option.toArray + this.favourConsistentThis |> Option.bind (constructRuleWithConfig FavourConsistentThis.rule) |> Option.toArray + this.cyclomaticComplexity |> Option.bind (constructRuleWithConfig CyclomaticComplexity.rule) |> Option.toArray + this.reimplementsFunction |> Option.bind (constructRuleIfEnabled ReimplementsFunction.rule) |> Option.toArray + this.canBeReplacedWithComposition |> Option.bind (constructRuleIfEnabled CanBeReplacedWithComposition.rule) |> Option.toArray + this.avoidSinglePipeOperator|> Option.bind (constructRuleIfEnabled AvoidSinglePipeOperator.rule) |> Option.toArray + this.usedUnderscorePrefixedElements |> Option.bind (constructRuleIfEnabled UsedUnderscorePrefixedElements.rule) |> Option.toArray + this.raiseWithTooManyArgs |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + this.sourceLength |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + this.naming |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + this.numberOfItems |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + this.binding |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + this.suggestUseAutoProperty |> Option.bind (constructRuleIfEnabled SuggestUseAutoProperty.rule) |> Option.toArray + |] type TypographyConfig = { indentation:EnabledConfig option @@ -366,16 +375,17 @@ type TypographyConfig = noTabCharacters:EnabledConfig option } with member this.Flatten() = - [| - this.indentation |> Option.bind (constructRuleIfEnabled Indentation.rule) |> Option.toArray - this.maxCharactersOnLine |> Option.bind (constructRuleWithConfig MaxCharactersOnLine.rule) |> Option.toArray - this.trailingWhitespaceOnLine |> Option.bind (constructRuleWithConfig TrailingWhitespaceOnLine.rule) |> Option.toArray - this.maxLinesInFile |> Option.bind (constructRuleWithConfig MaxLinesInFile.rule) |> Option.toArray - this.trailingNewLineInFile |> Option.bind (constructRuleIfEnabled TrailingNewLineInFile.rule) |> Option.toArray - this.noTabCharacters |> Option.bind (constructRuleIfEnabled NoTabCharacters.rule) |> Option.toArray - |] |> Array.concat - -let private getOrEmptyList hints = hints |> Option.defaultValue Array.empty + Array.concat + [| + this.indentation |> Option.bind (constructRuleIfEnabled Indentation.rule) |> Option.toArray + this.maxCharactersOnLine |> Option.bind (constructRuleWithConfig MaxCharactersOnLine.rule) |> Option.toArray + this.trailingWhitespaceOnLine |> Option.bind (constructRuleWithConfig TrailingWhitespaceOnLine.rule) |> Option.toArray + this.maxLinesInFile |> Option.bind (constructRuleWithConfig MaxLinesInFile.rule) |> Option.toArray + this.trailingNewLineInFile |> Option.bind (constructRuleIfEnabled TrailingNewLineInFile.rule) |> Option.toArray + this.noTabCharacters |> Option.bind (constructRuleIfEnabled NoTabCharacters.rule) |> Option.toArray + |] + +let private getOrEmptyList hints = Option.defaultValue Array.empty hints type HintConfig = { add:string [] option @@ -658,95 +668,97 @@ let findDeprecation config deprecatedAllRules allRules = let flattenConfig (config:Configuration) = let deprecatedAllRules = - [| - config.formatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - config.conventions |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - config.typography |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat - config.Hints |> Option.map (fun config -> HintMatcher.rule { HintMatcher.Config.HintTrie = parseHints (getOrEmptyList config.add) }) |> Option.toArray - |] |> Array.concat + Array.concat + [| + config.formatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + config.conventions |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + config.typography |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat + config.Hints |> Option.map (fun config -> HintMatcher.rule { HintMatcher.Config.HintTrie = parseHints (getOrEmptyList config.add) }) |> Option.toArray + |] let allRules = - [| - config.TypedItemSpacing |> Option.bind (constructRuleWithConfig TypedItemSpacing.rule) - config.TypePrefixing |> Option.bind (constructTypePrefixingRuleWithConfig TypePrefixing.rule) - config.UnionDefinitionIndentation |> Option.bind (constructRuleIfEnabled UnionDefinitionIndentation.rule) - config.ModuleDeclSpacing |> Option.bind (constructRuleIfEnabled ModuleDeclSpacing.rule) - config.ClassMemberSpacing |> Option.bind (constructRuleIfEnabled ClassMemberSpacing.rule) - config.TupleCommaSpacing |> Option.bind (constructRuleIfEnabled TupleCommaSpacing.rule) - config.TupleIndentation |> Option.bind (constructRuleIfEnabled TupleIndentation.rule) - config.TupleParentheses |> Option.bind (constructRuleIfEnabled TupleParentheses.rule) - config.PatternMatchClausesOnNewLine |> Option.bind (constructRuleIfEnabled PatternMatchClausesOnNewLine.rule) - config.PatternMatchOrClausesOnNewLine |> Option.bind (constructRuleIfEnabled PatternMatchOrClausesOnNewLine.rule) - config.PatternMatchClauseIndentation |> Option.bind (constructRuleWithConfig PatternMatchClauseIndentation.rule) - config.PatternMatchExpressionIndentation |> Option.bind (constructRuleIfEnabled PatternMatchExpressionIndentation.rule) - config.RecursiveAsyncFunction |> Option.bind (constructRuleIfEnabled RecursiveAsyncFunction.rule) - config.AvoidTooShortNames |> Option.bind (constructRuleIfEnabled AvoidTooShortNames.rule) - config.RedundantNewKeyword |> Option.bind (constructRuleIfEnabled RedundantNewKeyword.rule) - config.FavourReRaise |> Option.bind (constructRuleIfEnabled FavourReRaise.rule) - config.FavourStaticEmptyFields |> Option.bind (constructRuleIfEnabled FavourStaticEmptyFields.rule) - config.AsyncExceptionWithoutReturn |> Option.bind (constructRuleIfEnabled AsyncExceptionWithoutReturn.rule) - config.UnneededRecKeyword |> Option.bind (constructRuleIfEnabled UnneededRecKeyword.rule) - config.NestedStatements |> Option.bind (constructRuleWithConfig NestedStatements.rule) - config.FavourConsistentThis |> Option.bind (constructRuleWithConfig FavourConsistentThis.rule) - config.CyclomaticComplexity |> Option.bind (constructRuleWithConfig CyclomaticComplexity.rule) - config.ReimplementsFunction |> Option.bind (constructRuleIfEnabled ReimplementsFunction.rule) - config.CanBeReplacedWithComposition |> Option.bind (constructRuleIfEnabled CanBeReplacedWithComposition.rule) - config.AvoidSinglePipeOperator |> Option.bind (constructRuleIfEnabled AvoidSinglePipeOperator.rule) - config.UsedUnderscorePrefixedElements |> Option.bind (constructRuleIfEnabled UsedUnderscorePrefixedElements.rule) - config.FailwithBadUsage |> Option.bind (constructRuleIfEnabled FailwithBadUsage.rule) - config.RaiseWithSingleArgument |> Option.bind (constructRuleIfEnabled RaiseWithSingleArgument.rule) - config.FailwithWithSingleArgument |> Option.bind (constructRuleIfEnabled FailwithWithSingleArgument.rule) - config.NullArgWithSingleArgument |> Option.bind (constructRuleIfEnabled NullArgWithSingleArgument.rule) - config.InvalidOpWithSingleArgument |> Option.bind (constructRuleIfEnabled InvalidOpWithSingleArgument.rule) - config.InvalidArgWithTwoArguments |> Option.bind (constructRuleIfEnabled InvalidArgWithTwoArguments.rule) - config.FailwithfWithArgumentsMatchingFormatString |> Option.bind (constructRuleIfEnabled FailwithfWithArgumentsMatchingFormatString.rule) - config.MaxLinesInLambdaFunction |> Option.bind (constructRuleWithConfig MaxLinesInLambdaFunction.rule) - config.MaxLinesInMatchLambdaFunction |> Option.bind (constructRuleWithConfig MaxLinesInMatchLambdaFunction.rule) - config.MaxLinesInValue |> Option.bind (constructRuleWithConfig MaxLinesInValue.rule) - config.MaxLinesInFunction |> Option.bind (constructRuleWithConfig MaxLinesInFunction.rule) - config.MaxLinesInMember |> Option.bind (constructRuleWithConfig MaxLinesInMember.rule) - config.MaxLinesInConstructor |> Option.bind (constructRuleWithConfig MaxLinesInConstructor.rule) - config.MaxLinesInProperty |> Option.bind (constructRuleWithConfig MaxLinesInProperty.rule) - config.MaxLinesInModule |> Option.bind (constructRuleWithConfig MaxLinesInModule.rule) - config.MaxLinesInRecord |> Option.bind (constructRuleWithConfig MaxLinesInRecord.rule) - config.MaxLinesInEnum |> Option.bind (constructRuleWithConfig MaxLinesInEnum.rule) - config.MaxLinesInUnion |> Option.bind (constructRuleWithConfig MaxLinesInUnion.rule) - config.MaxLinesInClass |> Option.bind (constructRuleWithConfig MaxLinesInClass.rule) - config.InterfaceNames |> Option.bind (constructRuleWithConfig InterfaceNames.rule) - config.GenericTypesNames |> Option.bind (constructRuleWithConfig GenericTypesNames.rule) - config.ExceptionNames |> Option.bind (constructRuleWithConfig ExceptionNames.rule) - config.TypeNames |> Option.bind (constructRuleWithConfig TypeNames.rule) - config.RecordFieldNames |> Option.bind (constructRuleWithConfig RecordFieldNames.rule) - config.EnumCasesNames |> Option.bind (constructRuleWithConfig EnumCasesNames.rule) - config.UnionCasesNames |> Option.bind (constructRuleWithConfig UnionCasesNames.rule) - config.ModuleNames |> Option.bind (constructRuleWithConfig ModuleNames.rule) - config.LiteralNames |> Option.bind (constructRuleWithConfig LiteralNames.rule) - config.NamespaceNames |> Option.bind (constructRuleWithConfig NamespaceNames.rule) - config.MemberNames |> Option.bind (constructRuleWithConfig MemberNames.rule) - config.ParameterNames |> Option.bind (constructRuleWithConfig ParameterNames.rule) - config.MeasureTypeNames |> Option.bind (constructRuleWithConfig MeasureTypeNames.rule) - config.ActivePatternNames |> Option.bind (constructRuleWithConfig ActivePatternNames.rule) - config.PublicValuesNames |> Option.bind (constructRuleWithConfig PublicValuesNames.rule) - config.NonPublicValuesNames |> Option.bind (constructRuleWithConfig PrivateValuesNames.rule) - config.NonPublicValuesNames |> Option.bind (constructRuleWithConfig InternalValuesNames.rule) - config.PrivateValuesNames |> Option.bind (constructRuleWithConfig PrivateValuesNames.rule) - config.InternalValuesNames |> Option.bind (constructRuleWithConfig InternalValuesNames.rule) - config.MaxNumberOfItemsInTuple |> Option.bind (constructRuleWithConfig MaxNumberOfItemsInTuple.rule) - config.MaxNumberOfFunctionParameters |> Option.bind (constructRuleWithConfig MaxNumberOfFunctionParameters.rule) - config.MaxNumberOfMembers |> Option.bind (constructRuleWithConfig MaxNumberOfMembers.rule) - config.MaxNumberOfBooleanOperatorsInCondition |> Option.bind (constructRuleWithConfig MaxNumberOfBooleanOperatorsInCondition.rule) - config.FavourIgnoreOverLetWild |> Option.bind (constructRuleIfEnabled FavourIgnoreOverLetWild.rule) - config.FavourTypedIgnore |> Option.bind (constructRuleIfEnabled FavourTypedIgnore.rule) - config.WildcardNamedWithAsPattern |> Option.bind (constructRuleIfEnabled WildcardNamedWithAsPattern.rule) - config.UselessBinding |> Option.bind (constructRuleIfEnabled UselessBinding.rule) - config.TupleOfWildcards |> Option.bind (constructRuleIfEnabled TupleOfWildcards.rule) - config.Indentation |> Option.bind (constructRuleIfEnabled Indentation.rule) - config.MaxCharactersOnLine |> Option.bind (constructRuleWithConfig MaxCharactersOnLine.rule) - config.TrailingWhitespaceOnLine |> Option.bind (constructRuleWithConfig TrailingWhitespaceOnLine.rule) - config.MaxLinesInFile |> Option.bind (constructRuleWithConfig MaxLinesInFile.rule) - config.TrailingNewLineInFile |> Option.bind (constructRuleIfEnabled TrailingNewLineInFile.rule) - config.NoTabCharacters |> Option.bind (constructRuleIfEnabled NoTabCharacters.rule) - config.NoPartialFunctions |> Option.bind (constructRuleWithConfig NoPartialFunctions.rule) - |] |> Array.choose id + Array.choose id + [| + config.TypedItemSpacing |> Option.bind (constructRuleWithConfig TypedItemSpacing.rule) + config.TypePrefixing |> Option.bind (constructTypePrefixingRuleWithConfig TypePrefixing.rule) + config.UnionDefinitionIndentation |> Option.bind (constructRuleIfEnabled UnionDefinitionIndentation.rule) + config.ModuleDeclSpacing |> Option.bind (constructRuleIfEnabled ModuleDeclSpacing.rule) + config.ClassMemberSpacing |> Option.bind (constructRuleIfEnabled ClassMemberSpacing.rule) + config.TupleCommaSpacing |> Option.bind (constructRuleIfEnabled TupleCommaSpacing.rule) + config.TupleIndentation |> Option.bind (constructRuleIfEnabled TupleIndentation.rule) + config.TupleParentheses |> Option.bind (constructRuleIfEnabled TupleParentheses.rule) + config.PatternMatchClausesOnNewLine |> Option.bind (constructRuleIfEnabled PatternMatchClausesOnNewLine.rule) + config.PatternMatchOrClausesOnNewLine |> Option.bind (constructRuleIfEnabled PatternMatchOrClausesOnNewLine.rule) + config.PatternMatchClauseIndentation |> Option.bind (constructRuleWithConfig PatternMatchClauseIndentation.rule) + config.PatternMatchExpressionIndentation |> Option.bind (constructRuleIfEnabled PatternMatchExpressionIndentation.rule) + config.RecursiveAsyncFunction |> Option.bind (constructRuleIfEnabled RecursiveAsyncFunction.rule) + config.AvoidTooShortNames |> Option.bind (constructRuleIfEnabled AvoidTooShortNames.rule) + config.RedundantNewKeyword |> Option.bind (constructRuleIfEnabled RedundantNewKeyword.rule) + config.FavourReRaise |> Option.bind (constructRuleIfEnabled FavourReRaise.rule) + config.FavourStaticEmptyFields |> Option.bind (constructRuleIfEnabled FavourStaticEmptyFields.rule) + config.AsyncExceptionWithoutReturn |> Option.bind (constructRuleIfEnabled AsyncExceptionWithoutReturn.rule) + config.UnneededRecKeyword |> Option.bind (constructRuleIfEnabled UnneededRecKeyword.rule) + config.NestedStatements |> Option.bind (constructRuleWithConfig NestedStatements.rule) + config.FavourConsistentThis |> Option.bind (constructRuleWithConfig FavourConsistentThis.rule) + config.CyclomaticComplexity |> Option.bind (constructRuleWithConfig CyclomaticComplexity.rule) + config.ReimplementsFunction |> Option.bind (constructRuleIfEnabled ReimplementsFunction.rule) + config.CanBeReplacedWithComposition |> Option.bind (constructRuleIfEnabled CanBeReplacedWithComposition.rule) + config.AvoidSinglePipeOperator |> Option.bind (constructRuleIfEnabled AvoidSinglePipeOperator.rule) + config.UsedUnderscorePrefixedElements |> Option.bind (constructRuleIfEnabled UsedUnderscorePrefixedElements.rule) + config.FailwithBadUsage |> Option.bind (constructRuleIfEnabled FailwithBadUsage.rule) + config.RaiseWithSingleArgument |> Option.bind (constructRuleIfEnabled RaiseWithSingleArgument.rule) + config.FailwithWithSingleArgument |> Option.bind (constructRuleIfEnabled FailwithWithSingleArgument.rule) + config.NullArgWithSingleArgument |> Option.bind (constructRuleIfEnabled NullArgWithSingleArgument.rule) + config.InvalidOpWithSingleArgument |> Option.bind (constructRuleIfEnabled InvalidOpWithSingleArgument.rule) + config.InvalidArgWithTwoArguments |> Option.bind (constructRuleIfEnabled InvalidArgWithTwoArguments.rule) + config.FailwithfWithArgumentsMatchingFormatString |> Option.bind (constructRuleIfEnabled FailwithfWithArgumentsMatchingFormatString.rule) + config.MaxLinesInLambdaFunction |> Option.bind (constructRuleWithConfig MaxLinesInLambdaFunction.rule) + config.MaxLinesInMatchLambdaFunction |> Option.bind (constructRuleWithConfig MaxLinesInMatchLambdaFunction.rule) + config.MaxLinesInValue |> Option.bind (constructRuleWithConfig MaxLinesInValue.rule) + config.MaxLinesInFunction |> Option.bind (constructRuleWithConfig MaxLinesInFunction.rule) + config.MaxLinesInMember |> Option.bind (constructRuleWithConfig MaxLinesInMember.rule) + config.MaxLinesInConstructor |> Option.bind (constructRuleWithConfig MaxLinesInConstructor.rule) + config.MaxLinesInProperty |> Option.bind (constructRuleWithConfig MaxLinesInProperty.rule) + config.MaxLinesInModule |> Option.bind (constructRuleWithConfig MaxLinesInModule.rule) + config.MaxLinesInRecord |> Option.bind (constructRuleWithConfig MaxLinesInRecord.rule) + config.MaxLinesInEnum |> Option.bind (constructRuleWithConfig MaxLinesInEnum.rule) + config.MaxLinesInUnion |> Option.bind (constructRuleWithConfig MaxLinesInUnion.rule) + config.MaxLinesInClass |> Option.bind (constructRuleWithConfig MaxLinesInClass.rule) + config.InterfaceNames |> Option.bind (constructRuleWithConfig InterfaceNames.rule) + config.GenericTypesNames |> Option.bind (constructRuleWithConfig GenericTypesNames.rule) + config.ExceptionNames |> Option.bind (constructRuleWithConfig ExceptionNames.rule) + config.TypeNames |> Option.bind (constructRuleWithConfig TypeNames.rule) + config.RecordFieldNames |> Option.bind (constructRuleWithConfig RecordFieldNames.rule) + config.EnumCasesNames |> Option.bind (constructRuleWithConfig EnumCasesNames.rule) + config.UnionCasesNames |> Option.bind (constructRuleWithConfig UnionCasesNames.rule) + config.ModuleNames |> Option.bind (constructRuleWithConfig ModuleNames.rule) + config.LiteralNames |> Option.bind (constructRuleWithConfig LiteralNames.rule) + config.NamespaceNames |> Option.bind (constructRuleWithConfig NamespaceNames.rule) + config.MemberNames |> Option.bind (constructRuleWithConfig MemberNames.rule) + config.ParameterNames |> Option.bind (constructRuleWithConfig ParameterNames.rule) + config.MeasureTypeNames |> Option.bind (constructRuleWithConfig MeasureTypeNames.rule) + config.ActivePatternNames |> Option.bind (constructRuleWithConfig ActivePatternNames.rule) + config.PublicValuesNames |> Option.bind (constructRuleWithConfig PublicValuesNames.rule) + config.NonPublicValuesNames |> Option.bind (constructRuleWithConfig PrivateValuesNames.rule) + config.NonPublicValuesNames |> Option.bind (constructRuleWithConfig InternalValuesNames.rule) + config.PrivateValuesNames |> Option.bind (constructRuleWithConfig PrivateValuesNames.rule) + config.InternalValuesNames |> Option.bind (constructRuleWithConfig InternalValuesNames.rule) + config.MaxNumberOfItemsInTuple |> Option.bind (constructRuleWithConfig MaxNumberOfItemsInTuple.rule) + config.MaxNumberOfFunctionParameters |> Option.bind (constructRuleWithConfig MaxNumberOfFunctionParameters.rule) + config.MaxNumberOfMembers |> Option.bind (constructRuleWithConfig MaxNumberOfMembers.rule) + config.MaxNumberOfBooleanOperatorsInCondition |> Option.bind (constructRuleWithConfig MaxNumberOfBooleanOperatorsInCondition.rule) + config.FavourIgnoreOverLetWild |> Option.bind (constructRuleIfEnabled FavourIgnoreOverLetWild.rule) + config.FavourTypedIgnore |> Option.bind (constructRuleIfEnabled FavourTypedIgnore.rule) + config.WildcardNamedWithAsPattern |> Option.bind (constructRuleIfEnabled WildcardNamedWithAsPattern.rule) + config.UselessBinding |> Option.bind (constructRuleIfEnabled UselessBinding.rule) + config.TupleOfWildcards |> Option.bind (constructRuleIfEnabled TupleOfWildcards.rule) + config.Indentation |> Option.bind (constructRuleIfEnabled Indentation.rule) + config.MaxCharactersOnLine |> Option.bind (constructRuleWithConfig MaxCharactersOnLine.rule) + config.TrailingWhitespaceOnLine |> Option.bind (constructRuleWithConfig TrailingWhitespaceOnLine.rule) + config.MaxLinesInFile |> Option.bind (constructRuleWithConfig MaxLinesInFile.rule) + config.TrailingNewLineInFile |> Option.bind (constructRuleIfEnabled TrailingNewLineInFile.rule) + config.NoTabCharacters |> Option.bind (constructRuleIfEnabled NoTabCharacters.rule) + config.NoPartialFunctions |> Option.bind (constructRuleWithConfig NoPartialFunctions.rule) + |] findDeprecation config deprecatedAllRules allRules diff --git a/src/FSharpLint.Core/Application/Lint.fs b/src/FSharpLint.Core/Application/Lint.fs index d4fbce074..2c7f33430 100644 --- a/src/FSharpLint.Core/Application/Lint.fs +++ b/src/FSharpLint.Core/Application/Lint.fs @@ -185,16 +185,17 @@ module Lint = } let indentationError = - config.LineRules.IndentationRule - |> Option.map (fun rule -> runLineRuleWithContext rule config.Context.IndentationRuleContext lineParams) + Option.map + (fun rule -> runLineRuleWithContext rule config.Context.IndentationRuleContext lineParams) + config.LineRules.IndentationRule let noTabCharactersError = - config.LineRules.NoTabCharactersRule - |> Option.map (fun rule -> runLineRuleWithContext rule config.Context.NoTabCharactersRuleContext lineParams) + Option.map + (fun rule -> runLineRuleWithContext rule config.Context.NoTabCharactersRuleContext lineParams) + config.LineRules.NoTabCharactersRule let lineErrors = - config.LineRules.GenericLineRules - |> Array.collect (fun rule -> runLineRule rule lineParams) + Array.collect (fun rule -> runLineRule rule lineParams) config.LineRules.GenericLineRules [| indentationError |> Option.toArray @@ -460,7 +461,7 @@ module Lint = |> List.filter (not << isIgnoredFile) |> List.map (fun file -> ParseFile.parseFile file checker (Some projectOptions)) - let failedFiles = parsedFiles |> List.choose getFailedFiles + let failedFiles = List.choose getFailedFiles parsedFiles if List.isEmpty failedFiles then parsedFiles diff --git a/src/FSharpLint.Core/Framework/Ast.fs b/src/FSharpLint.Core/Framework/Ast.fs index 2fb82ce54..9f5ba25ff 100644 --- a/src/FSharpLint.Core/Framework/Ast.fs +++ b/src/FSharpLint.Core/Framework/Ast.fs @@ -42,8 +42,7 @@ module Ast = /// Concatenates the nested-list structure of `SynAttributes` into a `SynAttribute list` to keep other code /// mostly unchanged. let extractAttributes (attrs:SynAttributes) = - attrs - |> List.collect (fun attrList -> attrList.Attributes) + List.collect (fun (attrList: SynAttributeList) -> attrList.Attributes) attrs /// Extracts an expression from parentheses e.g. ((x + 4)) -> x + 4 let rec removeParens = function diff --git a/src/FSharpLint.Core/Framework/AstInfo.fs b/src/FSharpLint.Core/Framework/AstInfo.fs index d3c431280..9feb1fd6b 100644 --- a/src/FSharpLint.Core/Framework/AstInfo.fs +++ b/src/FSharpLint.Core/Framework/AstInfo.fs @@ -28,61 +28,62 @@ module AstInfo = | None -> Function let operatorIdentifiers = - [ "op_Nil" - "op_ColonColon" - "op_Addition" - "op_Splice" - "op_SpliceUntyped" - "op_Increment" - "op_Decrement" - "op_Subtraction" - "op_Multiply" - "op_Exponentiation" - "op_Division" - "op_Append" - "op_Concatenate" - "op_Modulus" - "op_BitwiseAnd" - "op_BitwiseOr" - "op_ExclusiveOr" - "op_LeftShift" - "op_LogicalNot" - "op_RightShift" - "op_UnaryPlus" - "op_UnaryNegation" - "op_AddressOf" - "op_IntegerAddressOf" - "op_BooleanAnd" - "op_BooleanOr" - "op_LessThanOrEqual" - "op_Equality" - "op_Inequality" - "op_GreaterThanOrEqual" - "op_LessThan" - "op_GreaterThan" - "op_PipeRight" - "op_PipeRight2" - "op_PipeRight3" - "op_PipeLeft" - "op_PipeLeft2" - "op_PipeLeft3" - "op_Dereference" - "op_ComposeRight" - "op_ComposeLeft" - "op_TypedQuotationUnicode" - "op_ChevronsBar" - "op_Quotation" - "op_QuotationUntyped" - "op_AdditionAssignment" - "op_SubtractionAssignment" - "op_MultiplyAssignment" - "op_DivisionAssignment" - "op_Range" - "op_RangeStep" - "op_Dynamic" - "op_DynamicAssignment" - "op_ArrayLookup" - "op_ArrayAssign" ] |> Set.ofList + Set.ofList + [ "op_Nil" + "op_ColonColon" + "op_Addition" + "op_Splice" + "op_SpliceUntyped" + "op_Increment" + "op_Decrement" + "op_Subtraction" + "op_Multiply" + "op_Exponentiation" + "op_Division" + "op_Append" + "op_Concatenate" + "op_Modulus" + "op_BitwiseAnd" + "op_BitwiseOr" + "op_ExclusiveOr" + "op_LeftShift" + "op_LogicalNot" + "op_RightShift" + "op_UnaryPlus" + "op_UnaryNegation" + "op_AddressOf" + "op_IntegerAddressOf" + "op_BooleanAnd" + "op_BooleanOr" + "op_LessThanOrEqual" + "op_Equality" + "op_Inequality" + "op_GreaterThanOrEqual" + "op_LessThan" + "op_GreaterThan" + "op_PipeRight" + "op_PipeRight2" + "op_PipeRight3" + "op_PipeLeft" + "op_PipeLeft2" + "op_PipeLeft3" + "op_Dereference" + "op_ComposeRight" + "op_ComposeLeft" + "op_TypedQuotationUnicode" + "op_ChevronsBar" + "op_Quotation" + "op_QuotationUntyped" + "op_AdditionAssignment" + "op_SubtractionAssignment" + "op_MultiplyAssignment" + "op_DivisionAssignment" + "op_Range" + "op_RangeStep" + "op_Dynamic" + "op_DynamicAssignment" + "op_ArrayLookup" + "op_ArrayAssign" ] /// Operator identifiers can be made up of "op_" followed by a sequence of operators from this list. let operators = @@ -116,7 +117,7 @@ module AstInfo = if Seq.isEmpty str then true else - let operator = operators |> List.tryFind (fun op -> str.StartsWith(op)) + let operator = List.tryFind (fun (op: string) -> str.StartsWith(op)) operators match operator with | Some(operator) -> str.Substring(operator.Length) |> isSequenceOfOperators diff --git a/src/FSharpLint.Core/Framework/HintParser.fs b/src/FSharpLint.Core/Framework/HintParser.fs index d0171aca2..66cbccbc5 100644 --- a/src/FSharpLint.Core/Framework/HintParser.fs +++ b/src/FSharpLint.Core/Framework/HintParser.fs @@ -480,16 +480,17 @@ module HintParser = char(System.Convert.ToInt32(dec, 10)) let private escapeMap = - [ ('"', '\"') - ('\\', '\\') - ('\'', '\'') - ('n', '\n') - ('t', '\t') - ('b', '\b') - ('r', '\r') - ('a', '\a') - ('f', '\f') - ('v', '\v') ] |> Map.ofList + Map.ofList + [ ('"', '\"') + ('\\', '\\') + ('\'', '\'') + ('n', '\n') + ('t', '\t') + ('b', '\b') + ('r', '\r') + ('a', '\a') + ('f', '\f') + ('v', '\v') ] let private pescapechar: Parser = skipChar '\\' @@ -622,8 +623,7 @@ module HintParser = let private pminus: Parser = pchar '-' let private minusString (minus:char option, charList) = - if minus.IsSome then '-' :: charList else charList - |> charListToString + charListToString (if minus.IsSome then '-' :: charList else charList) let private phexint: Parser = skipChar '0' diff --git a/src/FSharpLint.Core/Framework/Suppression.fs b/src/FSharpLint.Core/Framework/Suppression.fs index 6a5f1b316..da624fa7f 100644 --- a/src/FSharpLint.Core/Framework/Suppression.fs +++ b/src/FSharpLint.Core/Framework/Suppression.fs @@ -29,7 +29,7 @@ let private extractRules (rules:Set) (str:string) = /// Parses a given file to find lines containing rule suppressions. let parseSuppressionInfo (rules:Set) (lines:string list) = - let rules = rules |> Set.map (fun rule -> rule.ToLowerInvariant()) + let rules = Set.map (fun (rule: String) -> rule.ToLowerInvariant()) rules let choose lineNum line = let matched = Regex.Match (line, ".*fsharplint:([a-z\-]+)\s*(.*)$") diff --git a/src/FSharpLint.Core/Framework/Utilities.fs b/src/FSharpLint.Core/Framework/Utilities.fs index eb8083939..e4925e520 100644 --- a/src/FSharpLint.Core/Framework/Utilities.fs +++ b/src/FSharpLint.Core/Framework/Utilities.fs @@ -39,7 +39,7 @@ module ExpressionUtilities = let getSymbolFromIdent (checkFile:FSharpCheckFileResults option) expr = match (checkFile, expr) with | Some(checkFile), Identifier(ident, range) -> - let identNames = ident |> List.map (fun x -> x.idText) + let identNames = List.map (fun (x: Ident) -> x.idText) ident checkFile.GetSymbolUseAtLocation( range.StartLine, @@ -83,7 +83,7 @@ module ExpressionUtilities = /// Converts a LongIdentWithDots to a String. let longIdentWithDotsToString (lidwd: SynLongIdent) = - lidwd.LongIdent |> longIdentToString + longIdentToString lidwd.LongIdent /// Tries to find the source code within a given range. let tryFindTextOfRange (range:Range) (text:string) = @@ -114,7 +114,7 @@ module ExpressionUtilities = /// Converts a list of type args to its string representation. let typeArgsToString (text:string) (typeArgs:SynType list) = - let typeStrings = typeArgs |> List.choose (synTypeToString text) + let typeStrings = List.choose (synTypeToString text) typeArgs if typeStrings.Length = typeArgs.Length then typeStrings |> String.concat "," |> Some else None diff --git a/src/FSharpLint.Core/Rules/Conventions/AsyncExceptionWithoutReturn.fs b/src/FSharpLint.Core/Rules/Conventions/AsyncExceptionWithoutReturn.fs index a93b4496b..19db66c31 100644 --- a/src/FSharpLint.Core/Rules/Conventions/AsyncExceptionWithoutReturn.fs +++ b/src/FSharpLint.Core/Rules/Conventions/AsyncExceptionWithoutReturn.fs @@ -65,9 +65,9 @@ let runner args = | _ -> Array.empty let rule = - { Name = "AsyncExceptionWithoutReturn" - Identifier = Identifiers.AsyncExceptionWithoutReturn - RuleConfig = - { AstNodeRuleConfig.Runner = runner - Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "AsyncExceptionWithoutReturn" + Identifier = Identifiers.AsyncExceptionWithoutReturn + RuleConfig = + { AstNodeRuleConfig.Runner = runner + Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/AvoidSinglePipeOperator.fs b/src/FSharpLint.Core/Rules/Conventions/AvoidSinglePipeOperator.fs index 75fbc016e..89a8d0e8f 100644 --- a/src/FSharpLint.Core/Rules/Conventions/AvoidSinglePipeOperator.fs +++ b/src/FSharpLint.Core/Rules/Conventions/AvoidSinglePipeOperator.fs @@ -10,12 +10,11 @@ open FSharpLint.Framework.Rules let runner (args: AstNodeRuleParams) = let errors range = - { - Range = range - Message = String.Format(Resources.GetString ("RulesAvoidSinglePipeOperator")) - SuggestedFix = None - TypeChecks = List.Empty - } |> Array.singleton + Array.singleton + { Range = range + Message = String.Format(Resources.GetString("RulesAvoidSinglePipeOperator")) + SuggestedFix = None + TypeChecks = List.Empty } let error = match args.AstNode with @@ -47,7 +46,6 @@ let runner (args: AstNodeRuleParams) = let rule = - { Name = "AvoidSinglePipeOperator" - Identifier = Identifiers.AvoidSinglePipeOperator - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "AvoidSinglePipeOperator" + Identifier = Identifiers.AvoidSinglePipeOperator + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/AvoidTooShortNames.fs b/src/FSharpLint.Core/Rules/Conventions/AvoidTooShortNames.fs index 00de53df2..0c606ddc8 100644 --- a/src/FSharpLint.Core/Rules/Conventions/AvoidTooShortNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/AvoidTooShortNames.fs @@ -95,9 +95,9 @@ let runner (args:AstNodeRuleParams) = suggestions |> Array.map (fun suggestion -> { suggestion with TypeChecks = Option.toList typeCheck })) let rule = - { Name = "AvoidTooShortNames" - Identifier = Identifiers.AvoidTooShortNames - RuleConfig = - { AstNodeRuleConfig.Runner = runner - Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "AvoidTooShortNames" + Identifier = Identifiers.AvoidTooShortNames + RuleConfig = + { AstNodeRuleConfig.Runner = runner + Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/Binding/FavourIgnoreOverLetWild.fs b/src/FSharpLint.Core/Rules/Conventions/Binding/FavourIgnoreOverLetWild.fs index 64e09d5c0..f07d327d2 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Binding/FavourIgnoreOverLetWild.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Binding/FavourIgnoreOverLetWild.fs @@ -30,7 +30,6 @@ let private runner (args:AstNodeRuleParams) = /// Checks if any code uses 'let _ = ...' and suggests to use the ignore function. let rule = - { Name = "FavourIgnoreOverLetWild" - Identifier = Identifiers.FavourIgnoreOverLetWild - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "FavourIgnoreOverLetWild" + Identifier = Identifiers.FavourIgnoreOverLetWild + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/Binding/FavourTypedIgnore.fs b/src/FSharpLint.Core/Rules/Conventions/Binding/FavourTypedIgnore.fs index c7706ad5a..b06c2ec63 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Binding/FavourTypedIgnore.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Binding/FavourTypedIgnore.fs @@ -50,9 +50,9 @@ let private runner (args: AstNodeRuleParams) = /// Checks if any code uses untyped ignore let rule = - { Name = "FavourTypedIgnore" - Identifier = Identifiers.FavourTypedIgnore - RuleConfig = - { AstNodeRuleConfig.Runner = runner - Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "FavourTypedIgnore" + Identifier = Identifiers.FavourTypedIgnore + RuleConfig = + { AstNodeRuleConfig.Runner = runner + Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/Binding/TupleOfWildcards.fs b/src/FSharpLint.Core/Rules/Conventions/Binding/TupleOfWildcards.fs index 2fc6757b1..4ede1f3cb 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Binding/TupleOfWildcards.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Binding/TupleOfWildcards.fs @@ -14,7 +14,7 @@ let private checkTupleOfWildcards pattern identifier = | _ -> false let constructorString numberOfWildcards = - let constructorName = identifier |> String.concat "." + let constructorName = String.concat "." identifier let arguments = Array.create numberOfWildcards "_" |> String.concat ", " constructorName + "(" + arguments + ")" @@ -47,14 +47,13 @@ let private runner (args:AstNodeRuleParams) = | AstNode.Pattern(SynPat.LongIdent(identifier, _, _, SynArgPats.Pats([SynPat.Paren(SynPat.Tuple(_, _, range) as pattern, _)]), _, _)) -> let breadcrumbs = args.GetParents 2 if (not << isTupleMemberArgs breadcrumbs) range then - let identifier = identifier.LongIdent |> List.map (fun x -> x.idText) + let identifier = List.map (fun (x: Ident) -> x.idText) identifier.LongIdent checkTupleOfWildcards pattern identifier else Array.empty | _ -> Array.empty let rule = - { Name = "TupleOfWildcards" - Identifier = Identifiers.TupleOfWildcards - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "TupleOfWildcards" + Identifier = Identifiers.TupleOfWildcards + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/Binding/UselessBinding.fs b/src/FSharpLint.Core/Rules/Conventions/Binding/UselessBinding.fs index 759b7554e..762282ba6 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Binding/UselessBinding.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Binding/UselessBinding.fs @@ -57,8 +57,6 @@ let private runner (args:AstNodeRuleParams) = Array.empty let rule = - { Name = "UselessBinding" - Identifier = Identifiers.UselessBinding - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule - + AstNodeRule { Name = "UselessBinding" + Identifier = Identifiers.UselessBinding + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/Binding/WildcardNamedWithAsPattern.fs b/src/FSharpLint.Core/Rules/Conventions/Binding/WildcardNamedWithAsPattern.fs index 3ca062263..e4c3be11a 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Binding/WildcardNamedWithAsPattern.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Binding/WildcardNamedWithAsPattern.fs @@ -23,8 +23,6 @@ let private runner (args:AstNodeRuleParams) = | _ -> Array.empty let rule = - { Name = "WildcardNamedWithAsPattern" - Identifier = Identifiers.WildcardNamedWithAsPattern - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule - + AstNodeRule { Name = "WildcardNamedWithAsPattern" + Identifier = Identifiers.WildcardNamedWithAsPattern + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/CyclomaticComplexity.fs b/src/FSharpLint.Core/Rules/Conventions/CyclomaticComplexity.fs index f8a3065a0..d4a6fc1fd 100644 --- a/src/FSharpLint.Core/Rules/Conventions/CyclomaticComplexity.fs +++ b/src/FSharpLint.Core/Rules/Conventions/CyclomaticComplexity.fs @@ -181,7 +181,7 @@ let runner (config:Config) (args:AstNodeRuleParams) : WarningDetails[] = | SynExpr.MatchBang(_, _, clauses, _, _) | SynExpr.MatchLambda(_, _, clauses, _, _) | SynExpr.Match(_, _, clauses, _, _) -> - let numCases = clauses |> List.sumBy countCasesInMatchClause // determine the number of cases in the match expression + let numCases = List.sumBy countCasesInMatchClause clauses // determine the number of cases in the match expression bindingStack.IncrComplexityOfCurrentScope (numCases + countBooleanOperators expression) // include the number of boolean operators in any when expressions, if applicable | _ -> () | _ -> () @@ -211,8 +211,9 @@ let cleanup () = /// Generator function for a rule instance. let rule config = - { Name = "CyclomaticComplexity" - Identifier = Identifiers.CyclomaticComplexity - RuleConfig = { AstNodeRuleConfig.Runner = runner config - Cleanup = cleanup } } - |> AstNodeRule \ No newline at end of file + AstNodeRule + { Name = "CyclomaticComplexity" + Identifier = Identifiers.CyclomaticComplexity + RuleConfig = + { AstNodeRuleConfig.Runner = runner config + Cleanup = cleanup } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/FavourConsistentThis.fs b/src/FSharpLint.Core/Rules/Conventions/FavourConsistentThis.fs index 7897493ee..38b32b808 100644 --- a/src/FSharpLint.Core/Rules/Conventions/FavourConsistentThis.fs +++ b/src/FSharpLint.Core/Rules/Conventions/FavourConsistentThis.fs @@ -25,11 +25,11 @@ let runner (config: Config) args = match identifiers with | head::_ when isNotConsistent head.idText symbol -> let error = - { Range = range - Message = String.Format(Resources.GetString "RulesFavourConsistentThis", config.Symbol) - SuggestedFix = None - TypeChecks = List.Empty } - |> Array.singleton + Array.singleton + { Range = range + Message = String.Format(Resources.GetString "RulesFavourConsistentThis", config.Symbol) + SuggestedFix = None + TypeChecks = List.Empty } error | _ -> Array.empty else @@ -38,7 +38,6 @@ let runner (config: Config) args = | _ -> Array.empty let rule config = - { Name = "FavourConsistentThis" - Identifier = Identifiers.FavourConsistentThis - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "FavourConsistentThis" + Identifier = Identifiers.FavourConsistentThis + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/FavourReRaise.fs b/src/FSharpLint.Core/Rules/Conventions/FavourReRaise.fs index d08375f4c..3d481a4b1 100644 --- a/src/FSharpLint.Core/Rules/Conventions/FavourReRaise.fs +++ b/src/FSharpLint.Core/Rules/Conventions/FavourReRaise.fs @@ -9,11 +9,11 @@ open FSharpLint.Framework.Rules let private runner (args: AstNodeRuleParams) = let generateError range = - { Range = range - Message = Resources.GetString "RulesFavourReRaise" - SuggestedFix = None - TypeChecks = List.empty } - |> Array.singleton + Array.singleton + { Range = range + Message = Resources.GetString "RulesFavourReRaise" + SuggestedFix = None + TypeChecks = List.empty } let rec checkExpr (expr) maybeIdent = match expr with @@ -43,9 +43,9 @@ let private runner (args: AstNodeRuleParams) = | _ -> Array.empty let rule = - { Name = "FavourReRaise" - Identifier = Identifiers.FavourReRaise - RuleConfig = - { AstNodeRuleConfig.Runner = runner - Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "FavourReRaise" + Identifier = Identifiers.FavourReRaise + RuleConfig = + { AstNodeRuleConfig.Runner = runner + Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/FavourStaticEmptyFields.fs b/src/FSharpLint.Core/Rules/Conventions/FavourStaticEmptyFields.fs index 3e1477272..171e64224 100644 --- a/src/FSharpLint.Core/Rules/Conventions/FavourStaticEmptyFields.fs +++ b/src/FSharpLint.Core/Rules/Conventions/FavourStaticEmptyFields.fs @@ -27,11 +27,11 @@ let private getStaticEmptyErrorMessage (range:FSharp.Compiler.Text.Range) (empt errorMessageKey |> formatError let private generateError (range:FSharp.Compiler.Text.Range) (emptyLiteralType: EmptyLiteralType) = - { Range = range - Message = getStaticEmptyErrorMessage range emptyLiteralType - SuggestedFix = None - TypeChecks = List.Empty } - |> Array.singleton + Array.singleton + { Range = range + Message = getStaticEmptyErrorMessage range emptyLiteralType + SuggestedFix = None + TypeChecks = List.Empty } let private runner (args: AstNodeRuleParams) = match args.AstNode with @@ -45,9 +45,8 @@ let private runner (args: AstNodeRuleParams) = let rule = - { Name = "FavourStaticEmptyFields" - Identifier = Identifiers.FavourStaticEmptyFields - RuleConfig = - { AstNodeRuleConfig.Runner = runner - Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "FavourStaticEmptyFields" + Identifier = Identifiers.FavourStaticEmptyFields + RuleConfig = + { AstNodeRuleConfig.Runner = runner + Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/CanBeReplacedWithComposition.fs b/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/CanBeReplacedWithComposition.fs index 602d82d00..9089c8b5f 100644 --- a/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/CanBeReplacedWithComposition.fs +++ b/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/CanBeReplacedWithComposition.fs @@ -51,7 +51,6 @@ let runner (args:AstNodeRuleParams) = Helper.FunctionReimplementation.checkLambda args validateLambdaCannotBeReplacedWithComposition let rule = - { Name = "CanBeReplacedWithComposition" - Identifier = Identifiers.CanBeReplacedWithComposition - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "CanBeReplacedWithComposition" + Identifier = Identifiers.CanBeReplacedWithComposition + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/ReimplementsFunction.fs b/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/ReimplementsFunction.fs index a4faa6e22..dd7303116 100644 --- a/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/ReimplementsFunction.fs +++ b/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/ReimplementsFunction.fs @@ -53,7 +53,6 @@ let runner (args:AstNodeRuleParams) = Helper.FunctionReimplementation.checkLambda args validateLambdaIsNotPointless let rule = - { Name = "ReimplementsFunction" - Identifier = Identifiers.ReimplementsFunction - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "ReimplementsFunction" + Identifier = Identifiers.ReimplementsFunction + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/MemberNames.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/MemberNames.fs index 486de1b1c..b93a0d09c 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/MemberNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/MemberNames.fs @@ -17,10 +17,9 @@ let private getMemberIdents _ = function | _ -> Array.empty let private isImplementingInterface parents = - parents - |> List.exists (function + List.exists (function | AstNode.MemberDefinition (SynMemberDefn.Interface _) -> true - | _ -> false) + | _ -> false) parents let private getIdentifiers (args:AstNodeRuleParams) = match args.AstNode with diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs index d976059b3..618e09ea4 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs @@ -40,11 +40,11 @@ module QuickFixes = else String.Empty let toPascalCase (ident:Ident) = lazy( - let pascalCaseIdent = ident.idText |> mapFirstChar Char.ToUpper + let pascalCaseIdent = mapFirstChar Char.ToUpper ident.idText Some { FromText = ident.idText; FromRange = ident.idRange; ToText = pascalCaseIdent }) let toCamelCase (ident:Ident) = lazy( - let camelCaseIdent = ident.idText |> mapFirstChar Char.ToLower + let camelCaseIdent = mapFirstChar Char.ToLower ident.idText Some { FromText = ident.idText; FromRange = ident.idRange; ToText = camelCaseIdent }) [] @@ -128,16 +128,14 @@ let private checkIdentifierPart (config:NamingConfig) (identifier:Ident) (idText | _ -> None let prefixError = - config.Prefix - |> Option.bind (fun prefix -> + Option.bind (fun prefix -> prefixRule prefix idText - |> Option.map (formatError2 prefix >> tryAddFix (QuickFixes.addPrefix prefix))) + |> Option.map (formatError2 prefix >> tryAddFix (QuickFixes.addPrefix prefix))) config.Prefix let suffixError = - config.Suffix - |> Option.bind (fun suffix -> + Option.bind (fun suffix -> suffixRule suffix idText - |> Option.map (formatError2 suffix >> tryAddFix (QuickFixes.addSuffix suffix))) + |> Option.map (formatError2 suffix >> tryAddFix (QuickFixes.addSuffix suffix))) config.Suffix [| casingError diff --git a/src/FSharpLint.Core/Rules/Conventions/NestedStatements.fs b/src/FSharpLint.Core/Rules/Conventions/NestedStatements.fs index 53ae801a8..f63585af2 100644 --- a/src/FSharpLint.Core/Rules/Conventions/NestedStatements.fs +++ b/src/FSharpLint.Core/Rules/Conventions/NestedStatements.fs @@ -131,8 +131,9 @@ let cleanup () = skipToIndex <- None let rule config = - { Name = "NestedStatements" - Identifier = Identifiers.NestedStatements - RuleConfig = { AstNodeRuleConfig.Runner = runner config - Cleanup = cleanup } } - |> AstNodeRule + AstNodeRule + { Name = "NestedStatements" + Identifier = Identifiers.NestedStatements + RuleConfig = + { AstNodeRuleConfig.Runner = runner config + Cleanup = cleanup } } diff --git a/src/FSharpLint.Core/Rules/Conventions/NoPartialFunctions.fs b/src/FSharpLint.Core/Rules/Conventions/NoPartialFunctions.fs index 8fb8c2fa9..b26d4bf01 100644 --- a/src/FSharpLint.Core/Rules/Conventions/NoPartialFunctions.fs +++ b/src/FSharpLint.Core/Rules/Conventions/NoPartialFunctions.fs @@ -21,65 +21,67 @@ type private Replacement = | Function of functionName:string let private partialFunctionIdentifiers = - [ - // Option - ("Option.get", PatternMatch) - - // Map - ("Map.find", Function "Map.tryFind") - ("Map.findKey", Function "Map.tryFindKey") - - // Array - ("Array.exactlyOne", Function "Array.tryExactlyOne") - ("Array.get", Function "Array.tryItem") - ("Array.item", Function "Array.tryItem") - ("Array.find", Function "Array.tryFind") - ("Array.findIndex", Function "Array.tryFindIndex") - ("Array.findBack", Function "Array.tryFindBack") - ("Array.head", Function "Array.tryHead") - ("Array.last", Function "Array.tryLast") - ("Array.tail", Function "FSharpx.Collections.Seq.tryHeadTail") - ("Array.reduce", Function "Array.fold") - ("Array.reduceBack", Function "Array.foldBack") - ("Array.pick", Function "Array.tryPick") - - // Seq - ("Seq.exactlyOne", Function "Seq.tryExactlyOne") - ("Seq.item", Function "Seq.tryItem") - ("Seq.find", Function "Seq.tryFind") - ("Seq.findIndex", Function "Seq.tryFindIndex") - ("Seq.findBack", Function "Seq.tryFindBack") - ("Seq.head", Function "Seq.tryHead") - ("Seq.last", Function "Seq.tryLast") - ("Seq.tail", Function "FSharpx.Collections.Seq.tryHeadTail") - ("Seq.reduce", Function "Seq.fold") - ("Seq.reduceBack", Function "Seq.foldBack") - ("Seq.pick", Function "Seq.tryPick") - - // List - ("List.exactlyOne", Function "List.tryExactlyOne") - ("List.item", Function "List.tryItem") - ("List.find", Function "List.tryFind") - ("List.findIndex", Function "List.tryFindIndex") - ("List.findBack", Function "List.tryFindBack") - ("List.head", Function "List.tryHead") - ("List.last", Function "List.tryLast") - ("List.tail", Function "FSharpx.Collections.Seq.tryHeadTail") - ("List.reduce", Function "List.fold") - ("List.reduceBack", Function "List.foldBack") - ("List.pick", Function "List.tryPick") - ] |> Map.ofList + Map.ofList + [ + // Option + ("Option.get", PatternMatch) + + // Map + ("Map.find", Function "Map.tryFind") + ("Map.findKey", Function "Map.tryFindKey") + + // Array + ("Array.exactlyOne", Function "Array.tryExactlyOne") + ("Array.get", Function "Array.tryItem") + ("Array.item", Function "Array.tryItem") + ("Array.find", Function "Array.tryFind") + ("Array.findIndex", Function "Array.tryFindIndex") + ("Array.findBack", Function "Array.tryFindBack") + ("Array.head", Function "Array.tryHead") + ("Array.last", Function "Array.tryLast") + ("Array.tail", Function "FSharpx.Collections.Seq.tryHeadTail") + ("Array.reduce", Function "Array.fold") + ("Array.reduceBack", Function "Array.foldBack") + ("Array.pick", Function "Array.tryPick") + + // Seq + ("Seq.exactlyOne", Function "Seq.tryExactlyOne") + ("Seq.item", Function "Seq.tryItem") + ("Seq.find", Function "Seq.tryFind") + ("Seq.findIndex", Function "Seq.tryFindIndex") + ("Seq.findBack", Function "Seq.tryFindBack") + ("Seq.head", Function "Seq.tryHead") + ("Seq.last", Function "Seq.tryLast") + ("Seq.tail", Function "FSharpx.Collections.Seq.tryHeadTail") + ("Seq.reduce", Function "Seq.fold") + ("Seq.reduceBack", Function "Seq.foldBack") + ("Seq.pick", Function "Seq.tryPick") + + // List + ("List.exactlyOne", Function "List.tryExactlyOne") + ("List.item", Function "List.tryItem") + ("List.find", Function "List.tryFind") + ("List.findIndex", Function "List.tryFindIndex") + ("List.findBack", Function "List.tryFindBack") + ("List.head", Function "List.tryHead") + ("List.last", Function "List.tryLast") + ("List.tail", Function "FSharpx.Collections.Seq.tryHeadTail") + ("List.reduce", Function "List.fold") + ("List.reduceBack", Function "List.foldBack") + ("List.pick", Function "List.tryPick") + ] let private partialInstanceMemberIdentifiers = - [ - ("Option.Value", PatternMatch) - ("Map.Item", Function "Map.tryFind") - ("List.Item", Function "List.tryFind") - ("List.Head", Function "List.tryHead") + Map.ofList + [ + ("Option.Value", PatternMatch) + ("Map.Item", Function "Map.tryFind") + ("List.Item", Function "List.tryFind") + ("List.Head", Function "List.tryHead") - // As an example for future additions (see commented Foo.Bar.Baz tests) - //("Foo.Bar.Baz", PatternMatch) - ] |> Map.ofList + // As an example for future additions (see commented Foo.Bar.Baz tests) + //("Foo.Bar.Baz", PatternMatch) + ] let private checkIfPartialIdentifier (config:Config) (identifier:string) (range:Range) = if List.contains identifier config.AllowedPartials then @@ -200,8 +202,9 @@ let private runner (config:Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "NoPartialFunctions" - Identifier = Identifiers.NoPartialFunctions - RuleConfig = { AstNodeRuleConfig.Runner = runner config - Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "NoPartialFunctions" + Identifier = Identifiers.NoPartialFunctions + RuleConfig = + { AstNodeRuleConfig.Runner = runner config + Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfBooleanOperatorsInCondition.fs b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfBooleanOperatorsInCondition.fs index 8f0da42f2..7aecfdbab 100644 --- a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfBooleanOperatorsInCondition.fs +++ b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfBooleanOperatorsInCondition.fs @@ -57,7 +57,6 @@ let private runner (config:Helper.NumberOfItems.Config) (args:AstNodeRuleParams) | _ -> Array.empty let rule config = - { Name = "MaxNumberOfBooleanOperatorsInCondition" - Identifier = Identifiers.MaxNumberOfBooleanOperatorsInCondition - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "MaxNumberOfBooleanOperatorsInCondition" + Identifier = Identifiers.MaxNumberOfBooleanOperatorsInCondition + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfFunctionParameters.fs b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfFunctionParameters.fs index 2b76f7d61..96920c7e4 100644 --- a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfFunctionParameters.fs +++ b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfFunctionParameters.fs @@ -23,7 +23,6 @@ let private runner (config:Helper.NumberOfItems.Config) (args:AstNodeRuleParams) | _ -> Array.empty let rule config = - { Name = "MaxNumberOfFunctionParameters" - Identifier = Identifiers.MaxNumberOfFunctionParameters - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "MaxNumberOfFunctionParameters" + Identifier = Identifiers.MaxNumberOfFunctionParameters + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfItemsInTuple.fs b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfItemsInTuple.fs index f702667b3..772be2f29 100644 --- a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfItemsInTuple.fs +++ b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfItemsInTuple.fs @@ -39,7 +39,6 @@ let runner (config:Helper.NumberOfItems.Config) (args:AstNodeRuleParams) = Array.empty let rule config = - { Name = "MaxNumberOfItemsInTuple" - Identifier = Identifiers.MaxNumberOfItemsInTuple - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "MaxNumberOfItemsInTuple" + Identifier = Identifiers.MaxNumberOfItemsInTuple + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfMembers.fs b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfMembers.fs index 4a01efa30..0decd9d90 100644 --- a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfMembers.fs +++ b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfMembers.fs @@ -25,8 +25,7 @@ let private validateType (maxMembers:int) members typeRepresentation = let members = match typeRepresentation with | SynTypeDefnRepr.Simple(_) | SynTypeDefnRepr.Exception(_) -> members - | SynTypeDefnRepr.ObjectModel(_, members, _) -> members - |> getMembers + | SynTypeDefnRepr.ObjectModel(_, members, _) -> getMembers members if List.length members > maxMembers then let errorFormatString = Resources.GetString("RulesNumberOfItemsClassMembersError") @@ -42,7 +41,6 @@ let private runner (config:Helper.NumberOfItems.Config) (args:AstNodeRuleParams) | _ -> Array.empty let rule config = - { Name = "MaxNumberOfMembers" - Identifier = Identifiers.MaxNumberOfMembers - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "MaxNumberOfMembers" + Identifier = Identifiers.MaxNumberOfMembers + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithBadUsage.fs b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithBadUsage.fs index 124e3a137..5fdfe7dd7 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithBadUsage.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithBadUsage.fs @@ -52,11 +52,10 @@ let private runner (args: AstNodeRuleParams) = | NullMessage -> "consider using a non-null error messages as parameter" let error = - { Range = range - Message = String.Format(Resources.GetString "RulesFailwithBadUsage", message) - SuggestedFix = suggestedFix - TypeChecks = List.Empty } - |> Array.singleton + Array.singleton { Range = range + Message = String.Format(Resources.GetString "RulesFailwithBadUsage", message) + SuggestedFix = suggestedFix + TypeChecks = List.Empty } error @@ -127,9 +126,9 @@ let private runner (args: AstNodeRuleParams) = let cleanup () = failwithMessages <- Set.empty let rule = - { Name = "FailwithBadUsage" - Identifier = Identifiers.FailwithBadUsage - RuleConfig = - { AstNodeRuleConfig.Runner = runner - Cleanup = cleanup } } - |> AstNodeRule + AstNodeRule + { Name = "FailwithBadUsage" + Identifier = Identifiers.FailwithBadUsage + RuleConfig = + { AstNodeRuleConfig.Runner = runner + Cleanup = cleanup } } diff --git a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithWithSingleArgument.fs b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithWithSingleArgument.fs index 0290bc040..d103f7aed 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithWithSingleArgument.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithWithSingleArgument.fs @@ -5,7 +5,6 @@ open FSharpLint.Framework.Rules let runner = Helper.RaiseWithTooManyArguments.checkRaiseWithTooManyArgs "failwith" 1 "FailwithWithSingleArgument" let rule = - { Name = "FailwithWithSingleArgument" - Identifier = Identifiers.FailwithWithSingleArgument - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "FailwithWithSingleArgument" + Identifier = Identifiers.FailwithWithSingleArgument + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithfWithArgumentsMatchingFormatString.fs b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithfWithArgumentsMatchingFormatString.fs index 047619584..fd6507c72 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithfWithArgumentsMatchingFormatString.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/FailwithfWithArgumentsMatchingFormatString.fs @@ -28,7 +28,6 @@ let private runner (args:AstNodeRuleParams) = let rule = - { Name = "FailwithfWithArgumentsMatchingFormatString" - Identifier = Identifiers.FailwithfWithArgumentsMatchingFormattingString - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "FailwithfWithArgumentsMatchingFormatString" + Identifier = Identifiers.FailwithfWithArgumentsMatchingFormattingString + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/InvalidArgWithTwoArguments.fs b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/InvalidArgWithTwoArguments.fs index 1803e0629..c5b51afd5 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/InvalidArgWithTwoArguments.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/InvalidArgWithTwoArguments.fs @@ -5,7 +5,6 @@ open FSharpLint.Framework.Rules let runner = Helper.RaiseWithTooManyArguments.checkRaiseWithTooManyArgs "invalidArg" 2 "InvalidArgWithTwoArguments" let rule = - { Name = "InvalidArgWithTwoArguments" - Identifier = Identifiers.InvalidOpWithSingleArgument - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "InvalidArgWithTwoArguments" + Identifier = Identifiers.InvalidOpWithSingleArgument + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/InvalidOpWithSingleArgument.fs b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/InvalidOpWithSingleArgument.fs index 9c19ebdc3..f8e70653f 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/InvalidOpWithSingleArgument.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/InvalidOpWithSingleArgument.fs @@ -5,7 +5,6 @@ open FSharpLint.Framework.Rules let runner = Helper.RaiseWithTooManyArguments.checkRaiseWithTooManyArgs "invalidOp" 1 "RulesInvalidOpWithSingleArgument" let rule = - { Name = "InvalidOpWithSingleArgument" - Identifier = Identifiers.InvalidOpWithSingleArgument - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "InvalidOpWithSingleArgument" + Identifier = Identifiers.InvalidOpWithSingleArgument + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/NullArgWithSingleArgument.fs b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/NullArgWithSingleArgument.fs index 84b172b83..69314987d 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/NullArgWithSingleArgument.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/NullArgWithSingleArgument.fs @@ -5,7 +5,6 @@ open FSharpLint.Framework.Rules let runner = Helper.RaiseWithTooManyArguments.checkRaiseWithTooManyArgs "nullArg" 1 "RulesNullArgWithSingleArgument" let rule = - { Name = "NullArgWithSingleArgument" - Identifier = Identifiers.NullArgWithSingleArgument - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "NullArgWithSingleArgument" + Identifier = Identifiers.NullArgWithSingleArgument + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/RaiseWithSingleArgument.fs b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/RaiseWithSingleArgument.fs index 8a2894c8d..fd2da1163 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/RaiseWithSingleArgument.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RaiseWithTooManyArguments/RaiseWithSingleArgument.fs @@ -5,7 +5,6 @@ open FSharpLint.Framework.Rules let runner = Helper.RaiseWithTooManyArguments.checkRaiseWithTooManyArgs "raise" 1 "RulesRaiseWithSingleArgument" let rule = - { Name = "RaiseWithSingleArgument" - Identifier = Identifiers.RaiseWithSingleArgument - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "RaiseWithSingleArgument" + Identifier = Identifiers.RaiseWithSingleArgument + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/RecursiveAsyncFunction.fs b/src/FSharpLint.Core/Rules/Conventions/RecursiveAsyncFunction.fs index 73507244f..9305c6913 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RecursiveAsyncFunction.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RecursiveAsyncFunction.fs @@ -69,7 +69,9 @@ let runner args = | _ -> Array.empty let rule = - { Name = "RecursiveAsyncFunction" - Identifier = Identifiers.RecursiveAsyncFunction - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "RecursiveAsyncFunction" + Identifier = Identifiers.RecursiveAsyncFunction + RuleConfig = + { AstNodeRuleConfig.Runner = runner + Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs b/src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs index 219dc8408..1c4099343 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs @@ -19,7 +19,7 @@ let private implementsIDisposable (fsharpType:FSharpType) = false let private doesNotImplementIDisposable (checkFile:FSharpCheckFileResults) (ident: SynLongIdent) = - let names = ident.LongIdent |> List.map (fun x -> x.idText) + let names = List.map (fun (x: Ident) -> x.idText) ident.LongIdent let symbol = checkFile.GetSymbolUseAtLocation(ident.Range.StartLine, ident.Range.EndColumn, String.Empty, names) match symbol with @@ -54,7 +54,6 @@ let runner args = | _ -> Array.empty let rule = - { Name = "RedundantNewKeyword" - Identifier = Identifiers.RedundantNewKeyword - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "RedundantNewKeyword" + Identifier = Identifiers.RedundantNewKeyword + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInClass.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInClass.fs index 0c7e92bb6..2f145eec6 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInClass.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInClass.fs @@ -14,7 +14,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInClass" - Identifier = Identifiers.MaxLinesInClass - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInClass" + Identifier = Identifiers.MaxLinesInClass + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInConstructor.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInConstructor.fs index 9f7fad7ea..380407cfb 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInConstructor.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInConstructor.fs @@ -14,7 +14,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInConstructor" - Identifier = Identifiers.MaxLinesInConstructor - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInConstructor" + Identifier = Identifiers.MaxLinesInConstructor + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInEnum.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInEnum.fs index dd2b692f1..d49874524 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInEnum.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInEnum.fs @@ -17,7 +17,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInEnum" - Identifier = Identifiers.MaxLinesInEnum - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInEnum" + Identifier = Identifiers.MaxLinesInEnum + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInFunction.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInFunction.fs index 61809da86..112c6dd7e 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInFunction.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInFunction.fs @@ -14,7 +14,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInFunction" - Identifier = Identifiers.MaxLinesInFunction - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInFunction" + Identifier = Identifiers.MaxLinesInFunction + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInLambdaFunction.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInLambdaFunction.fs index 435675986..bc5071439 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInLambdaFunction.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInLambdaFunction.fs @@ -11,7 +11,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInLambdaFunction" - Identifier = Identifiers.MaxLinesInLambdaFunction - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInLambdaFunction" + Identifier = Identifiers.MaxLinesInLambdaFunction + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInMatchLambdaFunction.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInMatchLambdaFunction.fs index fa16e3c67..839aedadd 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInMatchLambdaFunction.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInMatchLambdaFunction.fs @@ -11,7 +11,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInMatchLambdaFunction" - Identifier = Identifiers.MaxLinesInMatchLambdaFunction - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInMatchLambdaFunction" + Identifier = Identifiers.MaxLinesInMatchLambdaFunction + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInMember.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInMember.fs index 1504c90b6..07afca786 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInMember.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInMember.fs @@ -14,7 +14,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInMember" - Identifier = Identifiers.MaxLinesInMember - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInMember" + Identifier = Identifiers.MaxLinesInMember + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInModule.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInModule.fs index 90650eec2..a7cd2875e 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInModule.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInModule.fs @@ -11,7 +11,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInModule" - Identifier = Identifiers.MaxLinesInModule - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInModule" + Identifier = Identifiers.MaxLinesInModule + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInProperty.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInProperty.fs index 70189f93b..1b584fa19 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInProperty.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInProperty.fs @@ -14,7 +14,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInProperty" - Identifier = Identifiers.MaxLinesInProperty - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInProperty" + Identifier = Identifiers.MaxLinesInProperty + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInRecord.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInRecord.fs index 191c9ca30..b8750fc73 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInRecord.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInRecord.fs @@ -17,7 +17,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInRecord" - Identifier = Identifiers.MaxLinesInRecord - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInRecord" + Identifier = Identifiers.MaxLinesInRecord + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInUnion.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInUnion.fs index ca67265eb..6c0051188 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInUnion.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInUnion.fs @@ -17,7 +17,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInUnion" - Identifier = Identifiers.MaxLinesInUnion - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInUnion" + Identifier = Identifiers.MaxLinesInUnion + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInValue.fs b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInValue.fs index 5a2fcebbb..17e9a9612 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInValue.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SourceLength/MaxLinesInValue.fs @@ -14,7 +14,6 @@ let runner (config:Helper.SourceLength.Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "MaxLinesInValue" - Identifier = Identifiers.MaxLinesInValue - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule { Name = "MaxLinesInValue" + Identifier = Identifiers.MaxLinesInValue + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Conventions/SuggestUseAutoProperty.fs b/src/FSharpLint.Core/Rules/Conventions/SuggestUseAutoProperty.fs index 7df216e11..51345c689 100644 --- a/src/FSharpLint.Core/Rules/Conventions/SuggestUseAutoProperty.fs +++ b/src/FSharpLint.Core/Rules/Conventions/SuggestUseAutoProperty.fs @@ -94,9 +94,9 @@ let private runner (args: AstNodeRuleParams) = | _ -> Array.empty let rule = - { Name = "SuggestUseAutoProperty" - Identifier = Identifiers.SuggestUseAutoProperty - RuleConfig = - { AstNodeRuleConfig.Runner = runner - Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "SuggestUseAutoProperty" + Identifier = Identifiers.SuggestUseAutoProperty + RuleConfig = + { AstNodeRuleConfig.Runner = runner + Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/UnneededRecKeyword.fs b/src/FSharpLint.Core/Rules/Conventions/UnneededRecKeyword.fs index 27f610951..b390fee61 100644 --- a/src/FSharpLint.Core/Rules/Conventions/UnneededRecKeyword.fs +++ b/src/FSharpLint.Core/Rules/Conventions/UnneededRecKeyword.fs @@ -16,11 +16,10 @@ let runner (args: AstNodeRuleParams) = let funcName = ident.idText let functionCalls = - symbolUses - |> Seq.filter (fun usage -> + Seq.filter (fun (usage: FSharp.Compiler.CodeAnalysis.FSharpSymbolUse) -> usage.Symbol.DisplayName = funcName && usage.Range.StartLine >= letRange.StartLine - && usage.Range.EndLine <= letRange.EndLine) + && usage.Range.EndLine <= letRange.EndLine) symbolUses if (functionCalls |> Seq.length) <= 1 then @@ -40,9 +39,9 @@ let runner (args: AstNodeRuleParams) = | _ -> Array.empty let rule = - { Name = "UnneededRecKeyword" - Identifier = Identifiers.UnneededRecKeyword - RuleConfig = - { AstNodeRuleConfig.Runner = runner - Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "UnneededRecKeyword" + Identifier = Identifiers.UnneededRecKeyword + RuleConfig = + { AstNodeRuleConfig.Runner = runner + Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Conventions/UsedUnderscorePrefixedElements.fs b/src/FSharpLint.Core/Rules/Conventions/UsedUnderscorePrefixedElements.fs index c270f4ce4..229d1396b 100644 --- a/src/FSharpLint.Core/Rules/Conventions/UsedUnderscorePrefixedElements.fs +++ b/src/FSharpLint.Core/Rules/Conventions/UsedUnderscorePrefixedElements.fs @@ -42,7 +42,6 @@ let runner (args: AstNodeRuleParams) = Array.empty let rule = - { Name = "UsedUnderscorePrefixedElements" - Identifier = Identifiers.UsedUnderscorePrefixedElements - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "UsedUnderscorePrefixedElements" + Identifier = Identifiers.UsedUnderscorePrefixedElements + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchClauseIndentation.fs b/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchClauseIndentation.fs index 777235b64..4951e15d5 100644 --- a/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchClauseIndentation.fs +++ b/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchClauseIndentation.fs @@ -66,7 +66,7 @@ let check (config:Config) (args:AstNodeRuleParams) matchExprRange (clauses:SynMa let runner (config:Config) (args:AstNodeRuleParams) = PatternMatchFormatting.isActualPatternMatch args (check config) let rule config = - { Name = "PatternMatchClauseIndentation" - Identifier = Identifiers.PatternMatchClauseIndentation - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "PatternMatchClauseIndentation" + Identifier = Identifiers.PatternMatchClauseIndentation + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchClausesOnNewLine.fs b/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchClausesOnNewLine.fs index 2a79d93ff..2751408b5 100644 --- a/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchClausesOnNewLine.fs +++ b/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchClausesOnNewLine.fs @@ -26,7 +26,7 @@ let check args _ (clauses:SynMatchClause list) _ = let runner (args:AstNodeRuleParams) = PatternMatchFormatting.isActualPatternMatch args check let rule = - { Name = "PatternMatchClausesOnNewLine" - Identifier = Identifiers.PatternMatchClausesOnNewLine - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "PatternMatchClausesOnNewLine" + Identifier = Identifiers.PatternMatchClausesOnNewLine + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchExpressionIndentation.fs b/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchExpressionIndentation.fs index 1506a5be4..b310396da 100644 --- a/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchExpressionIndentation.fs +++ b/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchExpressionIndentation.fs @@ -32,7 +32,7 @@ let check (args:AstNodeRuleParams) _ (clauses:SynMatchClause list) _ = let runner (args:AstNodeRuleParams) = PatternMatchFormatting.isActualPatternMatch args check let rule = - { Name = "PatternMatchExpressionIndentation" - Identifier = Identifiers.PatternMatchExpressionIndentation - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "PatternMatchExpressionIndentation" + Identifier = Identifiers.PatternMatchExpressionIndentation + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchOrClausesOnNewLine.fs b/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchOrClausesOnNewLine.fs index 310a4a35a..9d006891b 100644 --- a/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchOrClausesOnNewLine.fs +++ b/src/FSharpLint.Core/Rules/Formatting/PatternMatchFormatting/PatternMatchOrClausesOnNewLine.fs @@ -30,7 +30,7 @@ let check args _ (clauses:SynMatchClause list) _ = let runner (args:AstNodeRuleParams) = PatternMatchFormatting.isActualPatternMatch args check let rule = - { Name = "PatternMatchOrClausesOnNewLine" - Identifier = Identifiers.PatternMatchOrClausesOnNewLine - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "PatternMatchOrClausesOnNewLine" + Identifier = Identifiers.PatternMatchOrClausesOnNewLine + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Formatting/Spacing/ClassMemberSpacing.fs b/src/FSharpLint.Core/Rules/Formatting/Spacing/ClassMemberSpacing.fs index 77b282ce2..55439f040 100644 --- a/src/FSharpLint.Core/Rules/Formatting/Spacing/ClassMemberSpacing.fs +++ b/src/FSharpLint.Core/Rules/Formatting/Spacing/ClassMemberSpacing.fs @@ -47,7 +47,7 @@ let runner args = | _ -> Array.empty let rule = - { Name = "ClassMemberSpacing" - Identifier = Identifiers.ClassMemberSpacing - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule + { Name = "ClassMemberSpacing" + Identifier = Identifiers.ClassMemberSpacing + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Formatting/Spacing/ModuleDeclSpacing.fs b/src/FSharpLint.Core/Rules/Formatting/Spacing/ModuleDeclSpacing.fs index cd891e876..72007cd42 100644 --- a/src/FSharpLint.Core/Rules/Formatting/Spacing/ModuleDeclSpacing.fs +++ b/src/FSharpLint.Core/Rules/Formatting/Spacing/ModuleDeclSpacing.fs @@ -47,7 +47,7 @@ let runner args = | _ -> Array.empty let rule = - { Name = "ModuleDeclSpacing" - Identifier = Identifiers.ModuleDeclSpacing - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "ModuleDeclSpacing" + Identifier = Identifiers.ModuleDeclSpacing + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleCommaSpacing.fs b/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleCommaSpacing.fs index 0a2f7898c..971a6504a 100644 --- a/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleCommaSpacing.fs +++ b/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleCommaSpacing.fs @@ -37,7 +37,7 @@ let checkTupleCommaSpacing (args:AstNodeRuleParams) (tupleExprs:SynExpr list) tu let runner (args:AstNodeRuleParams) = TupleFormatting.isActualTuple args checkTupleCommaSpacing let rule = - { Name = "TupleCommaSpacing" - Identifier = Identifiers.TupleCommaSpacing - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "TupleCommaSpacing" + Identifier = Identifiers.TupleCommaSpacing + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleIndentation.fs b/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleIndentation.fs index 939a6d36d..f6596959f 100644 --- a/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleIndentation.fs +++ b/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleIndentation.fs @@ -31,7 +31,7 @@ let checkTupleIndentation _ (tupleExprs:SynExpr list) _ _ = let runner (args:AstNodeRuleParams) = TupleFormatting.isActualTuple args checkTupleIndentation let rule = - { Name = "TupleIndentation" - Identifier = Identifiers.TupleIndentation - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule + { Name = "TupleIndentation" + Identifier = Identifiers.TupleIndentation + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleParentheses.fs b/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleParentheses.fs index 3e6e78d7d..e2521434b 100644 --- a/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleParentheses.fs +++ b/src/FSharpLint.Core/Rules/Formatting/TupleFormatting/TupleParentheses.fs @@ -29,7 +29,7 @@ let checkTupleHasParentheses (args:AstNodeRuleParams) _ range parentNode = let runner (args:AstNodeRuleParams) = TupleFormatting.isActualTuple args checkTupleHasParentheses let rule = - { Name = "TupleParentheses" - Identifier = Identifiers.TupleParentheses - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "TupleParentheses" + Identifier = Identifiers.TupleParentheses + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Formatting/TypePrefixing.fs b/src/FSharpLint.Core/Rules/Formatting/TypePrefixing.fs index 87c147140..8eebcc75d 100644 --- a/src/FSharpLint.Core/Rules/Formatting/TypePrefixing.fs +++ b/src/FSharpLint.Core/Rules/Formatting/TypePrefixing.fs @@ -109,7 +109,7 @@ let runner (config:Config) args = let rule config = - { Name = "TypePrefixing" - Identifier = Identifiers.TypePrefixing - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "TypePrefixing" + Identifier = Identifiers.TypePrefixing + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Formatting/TypedItemSpacing.fs b/src/FSharpLint.Core/Rules/Formatting/TypedItemSpacing.fs index 2c9d5ac48..cf8ce6c5c 100644 --- a/src/FSharpLint.Core/Rules/Formatting/TypedItemSpacing.fs +++ b/src/FSharpLint.Core/Rules/Formatting/TypedItemSpacing.fs @@ -52,8 +52,8 @@ let private checkRange (config:Config) (args:AstNodeRuleParams) (range:Range) = if spacesBeforeColon <> expectedSpacesBefore || spacesAfterColon <> expectedSpacesAfter then let trimmedOtherText = otherText.TrimEnd(' ') let trimmedTypeText = typeText.TrimStart(' ') - let spacesBeforeString = " " |> String.replicate expectedSpacesBefore - let spacesAfterString = " " |> String.replicate expectedSpacesAfter + let spacesBeforeString = String.replicate expectedSpacesBefore " " + let spacesAfterString = String.replicate expectedSpacesAfter " " let suggestedFix = lazy( { FromRange = range; FromText = text; ToText = trimmedOtherText + spacesBeforeString + ":" + spacesAfterString + trimmedTypeText } |> Some) @@ -81,7 +81,7 @@ let runner (config:Config) (args:AstNodeRuleParams) = | _ -> Array.empty let rule config = - { Name = "TypedItemSpacing" - Identifier = Identifiers.TypedItemSpacing - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule \ No newline at end of file + AstNodeRule + { Name = "TypedItemSpacing" + Identifier = Identifiers.TypedItemSpacing + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Formatting/UnionDefinitionIndentation.fs b/src/FSharpLint.Core/Rules/Formatting/UnionDefinitionIndentation.fs index 0276fabf2..b6e5df3fd 100644 --- a/src/FSharpLint.Core/Rules/Formatting/UnionDefinitionIndentation.fs +++ b/src/FSharpLint.Core/Rules/Formatting/UnionDefinitionIndentation.fs @@ -64,7 +64,7 @@ let runner args = Array.empty let rule = - { Name = "UnionDefinitionIndentation" - Identifier = Identifiers.UnionDefinitionIndentation - RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule + { Name = "UnionDefinitionIndentation" + Identifier = Identifiers.UnionDefinitionIndentation + RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs b/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs index cb573f037..a50e5bec1 100644 --- a/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs +++ b/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs @@ -68,10 +68,9 @@ let private matchLambdaArguments (hintArgs:HintParser.LambdaArg list) (actualArg |> List.map matchLambdaArgument let allArgsMatch = - matches - |> List.forall (function + List.forall (function | LambdaArgumentMatch.NoMatch -> false - | _ -> true) + | _ -> true) matches if allArgsMatch then matches @@ -185,7 +184,7 @@ module private MatchExpression = let ident = identAsDecompiledOpName ident Some(Expression.Identifier([ident])) | AstNode.Expression(SynExpr.LongIdent(_, ident, _, _)) -> - let identifier = ident.LongIdent |> List.map (fun ident -> ident.idText) + let identifier = List.map (fun (ident: Ident) -> ident.idText) ident.LongIdent Some(Expression.Identifier(identifier)) | AstNode.Expression(SynExpr.Const(constant, _)) -> matchConst constant |> Option.map Expression.Constant @@ -300,7 +299,7 @@ module private MatchExpression = and private matchFunctionApplication arguments = match (arguments.Expression, arguments.Hint) with | FuncApp(exprs, _), Expression.FunctionApplication(hintExprs) -> - let expressions = exprs |> List.map AstNode.Expression + let expressions = List.map AstNode.Expression exprs doExpressionsMatch expressions hintExprs arguments | _ -> NoMatch @@ -396,7 +395,7 @@ module private MatchPattern = let private matchPattern = function | SynPat.LongIdent(ident, _, _, _, _, _) -> - let identifier = ident.LongIdent |> List.map (fun ident -> ident.idText) + let identifier = List.map (fun (ident: Ident) -> ident.idText) (ident.LongIdent) Some(Pattern.Identifier(identifier)) | SynPat.Const(constant, _) -> matchConst constant |> Option.map Pattern.Constant @@ -742,7 +741,6 @@ let private runner (config:Config) (args:AstNodeRuleParams) = result let rule config = - { Name = "Hints" - Identifier = Identifiers.Hints - RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } - |> AstNodeRule + AstNodeRule { Name = "Hints" + Identifier = Identifiers.Hints + RuleConfig = { AstNodeRuleConfig.Runner = runner config; Cleanup = ignore } } diff --git a/src/FSharpLint.Core/Rules/Typography/Indentation.fs b/src/FSharpLint.Core/Rules/Typography/Indentation.fs index ab3f97d36..9f9de340b 100644 --- a/src/FSharpLint.Core/Rules/Typography/Indentation.fs +++ b/src/FSharpLint.Core/Rules/Typography/Indentation.fs @@ -34,9 +34,8 @@ module ContextBuilder = let private createAbsoluteAndOffsetOverrides expectedIndentation (rangeToUpdate:Range) = let absoluteOverride = (rangeToUpdate.StartLine, (true, expectedIndentation)) let relativeOverrides = - [(rangeToUpdate.StartLine + 1)..rangeToUpdate.EndLine] - |> List.map (fun offsetLine -> - (offsetLine, (false, expectedIndentation))) + List.map (fun offsetLine -> + (offsetLine, (false, expectedIndentation))) [(rangeToUpdate.StartLine + 1)..rangeToUpdate.EndLine] (absoluteOverride::relativeOverrides) let rec private collectRecordFields = function @@ -173,7 +172,6 @@ let runner context args = |> Option.toArray let rule = - { Name = "Indentation" - Identifier = Identifiers.Indentation - RuleConfig = { Runner = runner } } - |> IndentationRule \ No newline at end of file + IndentationRule { Name = "Indentation" + Identifier = Identifiers.Indentation + RuleConfig = { Runner = runner } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Typography/MaxCharactersOnLine.fs b/src/FSharpLint.Core/Rules/Typography/MaxCharactersOnLine.fs index 0575b6b21..d76ced2a9 100644 --- a/src/FSharpLint.Core/Rules/Typography/MaxCharactersOnLine.fs +++ b/src/FSharpLint.Core/Rules/Typography/MaxCharactersOnLine.fs @@ -23,7 +23,6 @@ let checkMaxCharactersOnLine (config:Config) (args:LineRuleParams) = Array.empty let rule config = - { Name = "MaxCharactersOnLine" - Identifier = Identifiers.MaxCharactersOnLine - RuleConfig = { LineRuleConfig.Runner = checkMaxCharactersOnLine config } } - |> LineRule \ No newline at end of file + LineRule { Name = "MaxCharactersOnLine" + Identifier = Identifiers.MaxCharactersOnLine + RuleConfig = { LineRuleConfig.Runner = checkMaxCharactersOnLine config } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Typography/MaxLinesInFile.fs b/src/FSharpLint.Core/Rules/Typography/MaxLinesInFile.fs index a45b432fa..c3a92f34d 100644 --- a/src/FSharpLint.Core/Rules/Typography/MaxLinesInFile.fs +++ b/src/FSharpLint.Core/Rules/Typography/MaxLinesInFile.fs @@ -26,7 +26,6 @@ let checkMaxLinesInFile (config:Config) (args:LineRuleParams) = Array.empty let rule config = - { Name = "MaxLinesInFile" - Identifier = Identifiers.MaxLinesInFile - RuleConfig = { LineRuleConfig.Runner = checkMaxLinesInFile config } } - |> LineRule \ No newline at end of file + LineRule { Name = "MaxLinesInFile" + Identifier = Identifiers.MaxLinesInFile + RuleConfig = { LineRuleConfig.Runner = checkMaxLinesInFile config } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Typography/NoTabCharacters.fs b/src/FSharpLint.Core/Rules/Typography/NoTabCharacters.fs index 5fb3b4def..a54d0122f 100644 --- a/src/FSharpLint.Core/Rules/Typography/NoTabCharacters.fs +++ b/src/FSharpLint.Core/Rules/Typography/NoTabCharacters.fs @@ -18,7 +18,7 @@ module ContextBuilder = current let private isInLiteralString literalStrings range = - literalStrings |> Seq.exists (fun (_, literalRange) -> ExpressionUtilities.rangeContainsOtherRange literalRange range) + Seq.exists (fun (_, literalRange) -> ExpressionUtilities.rangeContainsOtherRange literalRange range) literalStrings let checkNoTabCharacters literalStrings (args:LineRuleParams) = let indexOfTab = args.Line.IndexOf('\t') @@ -36,7 +36,6 @@ let checkNoTabCharacters literalStrings (args:LineRuleParams) = Array.empty let rule = - { Name = "NoTabCharacters" - Identifier = Identifiers.NoTabCharacters - RuleConfig = { Runner = checkNoTabCharacters } } - |> NoTabCharactersRule \ No newline at end of file + NoTabCharactersRule { Name = "NoTabCharacters" + Identifier = Identifiers.NoTabCharacters + RuleConfig = { Runner = checkNoTabCharacters } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Typography/TrailingNewLineInFile.fs b/src/FSharpLint.Core/Rules/Typography/TrailingNewLineInFile.fs index 0eccac9c4..d2a19af05 100644 --- a/src/FSharpLint.Core/Rules/Typography/TrailingNewLineInFile.fs +++ b/src/FSharpLint.Core/Rules/Typography/TrailingNewLineInFile.fs @@ -17,7 +17,6 @@ let checkTrailingNewLineInFile (args:LineRuleParams) = Array.empty let rule = - { Name = "TrailingNewLineInFile" - Identifier = Identifiers.TrailingNewLineInFile - RuleConfig = { LineRuleConfig.Runner = checkTrailingNewLineInFile } } - |> LineRule \ No newline at end of file + LineRule { Name = "TrailingNewLineInFile" + Identifier = Identifiers.TrailingNewLineInFile + RuleConfig = { LineRuleConfig.Runner = checkTrailingNewLineInFile } } \ No newline at end of file diff --git a/src/FSharpLint.Core/Rules/Typography/TrailingWhitespaceOnLine.fs b/src/FSharpLint.Core/Rules/Typography/TrailingWhitespaceOnLine.fs index a4c3dbe7e..512c7fde4 100644 --- a/src/FSharpLint.Core/Rules/Typography/TrailingWhitespaceOnLine.fs +++ b/src/FSharpLint.Core/Rules/Typography/TrailingWhitespaceOnLine.fs @@ -55,7 +55,6 @@ let checkTrailingWhitespaceOnLine (config:Config) (args:LineRuleParams) = Array.empty let rule config = - { Name = "TrailingWhitespaceOnLine" - Identifier = Identifiers.TrailingWhitespaceOnLine - RuleConfig = { LineRuleConfig.Runner = checkTrailingWhitespaceOnLine config } } - |> LineRule \ No newline at end of file + LineRule { Name = "TrailingWhitespaceOnLine" + Identifier = Identifiers.TrailingWhitespaceOnLine + RuleConfig = { LineRuleConfig.Runner = checkTrailingWhitespaceOnLine config } } \ No newline at end of file