Skip to content

Commit

Permalink
MaxLinesIn*: remove skip properties
Browse files Browse the repository at this point in the history
To respect YAGNI.

Also comments on TestMaxLinesInModule replaced with a variable
because the rule now skips comments.
  • Loading branch information
Mersho committed Dec 27, 2023
1 parent 24d2fbc commit deb3af6
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 186 deletions.
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0022.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Consider using a named function rather than a lambda function.
"maxLinesInLambdaFunction": {
"enabled": false,
"config": {
"maxLines": 7,
"skipBlankLines": false,
"skipComments": false
"maxLines": 7
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0023.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Use active patterns to help reduce the number of matches/extract code out into c
"maxLinesInMatchLambdaFunction": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0024.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,7 @@ Refactor to extract out code into smaller composable functions.
"maxLinesInValue": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0025.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Refactor to extract out code into smaller composable functions.
"maxLinesInFunction": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0026.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Extract code out into private methods or functions.
"maxLinesInMember": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0027.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Extract code out into private methods or functions.
"maxLinesInConstructor": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0028.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Extract code out into private methods or functions.
"MaxLinesInProperty": {
"enabled": false,
"config": {
"maxLines": 70,
"skipBlankLines": false,
"skipComments": false
"maxLines": 70
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0029.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Extract code out into smaller modules.
"maxLinesInModule": {
"enabled": false,
"config": {
"maxLines": 1000,
"skipBlankLines": false,
"skipComments": false
"maxLines": 1000
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0030.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Extract code out into smaller composed records.
"maxLinesInRecord": {
"enabled": false,
"config": {
"maxLines": 500,
"skipBlankLines": false,
"skipComments": false
"maxLines": 500
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0031.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Extract code out into smaller enums.
"maxLinesInEnum": {
"enabled": false,
"config": {
"maxLines": 500,
"skipBlankLines": false,
"skipComments": false
"maxLines": 500
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0032.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Extract code out into smaller composed discriminated unions.
"maxLinesInUnion": {
"enabled": false,
"config": {
"maxLines": 500,
"skipBlankLines": false,
"skipComments": false
"maxLines": 500
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0033.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Extract code out into smaller composable classes.
"maxLinesInClass": {
"enabled": false,
"config": {
"maxLines": 500,
"skipBlankLines": false,
"skipComments": false
"maxLines": 500
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
10 changes: 1 addition & 9 deletions docs/content/how-tos/rules/FL0062.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ Refactor to extract code out into another file.
"maxLinesInFile": {
"enabled": false,
"config": {
"maxLinesInFile": 1000,
"skipBlankLines": false,
"skipComments": false
"maxLinesInFile": 1000
}
}
}

*Introduced in `0.23.0`:*

The default setting will be false if the option is not provided in the Rule Settings:
* *skipBlankLines* - A boolean property that determines whether blank lines will be skipped. (Default false)
* *skipComments* - A boolean property that determines whether commented lines will be skipped. (Default false)
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ open FSharpLint.Framework.ExpressionUtilities
type Config =
{
MaxLines:int
SkipBlankLines: bool
SkipComments: bool
}

type private MultilineCommentMarker =
Expand Down Expand Up @@ -62,25 +60,16 @@ let checkSourceLengthRule (config:Config) range fileContents errorName =
match tryFindTextOfRange range fileContents with
| Some(sourceCode) ->
let sourceCode =
if config.SkipComments then
stripMultilineComments sourceCode
else
sourceCode
stripMultilineComments sourceCode

let commentLinesCount =
if config.SkipComments then
singleLineCommentRegex.Matches(sourceCode).Count
else
0
singleLineCommentRegex.Matches(sourceCode).Count

let sourceCodeLines = sourceCode.Split([| '\n'; '\r' |])
let blankLinesCount =
if config.SkipBlankLines then
sourceCodeLines
|> Seq.filter (fun line -> line.Trim().Length > 0)
|> Seq.length
else
0
sourceCodeLines
|> Seq.filter (fun line -> line.Trim().Length > 0)
|> Seq.length

let skipResult = sourceCodeLines.Length - commentLinesCount - blankLinesCount
if skipResult > config.MaxLines then
Expand Down
52 changes: 13 additions & 39 deletions src/FSharpLint.Core/fsharplint.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,97 +49,73 @@
"maxLinesInLambdaFunction": {
"enabled": false,
"config": {
"maxLines": 7,
"skipBlankLines": false,
"skipComments": false
"maxLines": 7
}
},
"maxLinesInMatchLambdaFunction": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
},
"maxLinesInValue": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
},
"maxLinesInFunction": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
},
"maxLinesInMember": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
},
"maxLinesInConstructor": {
"enabled": false,
"config": {
"maxLines": 100,
"skipBlankLines": false,
"skipComments": false
"maxLines": 100
}
},
"maxLinesInProperty": {
"enabled": false,
"config": {
"maxLines": 70,
"skipBlankLines": false,
"skipComments": false
"maxLines": 70
}
},
"maxLinesInModule": {
"enabled": false,
"config": {
"maxLines": 1000,
"skipBlankLines": false,
"skipComments": false
"maxLines": 1000
}
},
"maxLinesInRecord": {
"enabled": false,
"config": {
"maxLines": 500,
"skipBlankLines": false,
"skipComments": false
"maxLines": 500
}
},
"maxLinesInEnum": {
"enabled": false,
"config": {
"maxLines": 500,
"skipBlankLines": false,
"skipComments": false
"maxLines": 500
}
},
"maxLinesInUnion": {
"enabled": false,
"config": {
"maxLines": 500,
"skipBlankLines": false,
"skipComments": false
"maxLines": 500
}
},
"maxLinesInClass": {
"enabled": false,
"config": {
"maxLines": 500,
"skipBlankLines": false,
"skipComments": false
"maxLines": 500
}
},
"interfaceNames": {
Expand Down Expand Up @@ -320,9 +296,7 @@
"maxLinesInFile": {
"enabled": false,
"config": {
"maxLinesInFile": 1000,
"skipBlankLines": false,
"skipComments": false
"maxLinesInFile": 1000
}
},
"trailingNewLineInFile": { "enabled": false },
Expand Down
Loading

0 comments on commit deb3af6

Please sign in to comment.