Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lead by example #666

Closed
nojaf opened this issue Feb 3, 2020 · 6 comments · Fixed by #1090
Closed

Lead by example #666

nojaf opened this issue Feb 3, 2020 · 6 comments · Fixed by #1090

Comments

@nojaf
Copy link
Contributor

nojaf commented Feb 3, 2020

Description

Fantomas should format itself.
@jindraivanek what configuration options would you prefer if we pull this off?
I like to put KeepNewlineAfter on true.

I'm a bit worried that we will face the performance issue when formatting CodePrinter.fs.

@jindraivanek
Copy link
Contributor

what configuration options would you prefer if we pull this off?

I would prefer default configuration.

I'm a bit worried that we will face the performance issue when formatting CodePrinter.fs.

Indeed, it leads to Stack overflow. Same for AstTransformer.fs.

@auduchinok
Copy link
Contributor

what configuration options would you prefer if we pull this off? I like to put KeepNewlineAfter on true.

I would prefer default configuration.

Have you thought about making it the default?

@nojaf
Copy link
Contributor Author

nojaf commented Feb 7, 2020

I think the main reason not to have it as default is that fact that it brings inconsistencies in codebases.
For example https://jindraivanek.gitlab.io/fantomas-ui/#?fantomas=preview&code=DYUwLgBAhhC8EHYCwAoUkBGcKoniAHEA&config=N4Ig0gphAOByEHcA2BLAdhAggMwC4QCcQAuXAgVwgF8g

The fact that b is formatted differently is not based on any logical rule but mainly how that developer in the team felt that day.

@knocte
Copy link
Contributor

knocte commented Mar 23, 2020

Indeed, it leads to Stack overflow

That doesn't sound like a performance issue but a bug; is the bug filed somewhere?

@jindraivanek
Copy link
Contributor

@knocte It was fixed in #674 :)

@nojaf
Copy link
Contributor Author

nojaf commented May 15, 2020

Every once and while I try to format Fantomas with the latest Fantomas on the master branch.

❯ .\src\Fantomas.CoreGlobalTool\bin\Release\netcoreapp3.1\fantomas-tool.exe .\src\ --recurse --profile
Processing .\src\Fantomas\AssemblyInfo.fs
Line count: 20
Time taken: 00:00:00.6335284 s
.\src\Fantomas\AssemblyInfo.fs has been written.
Processing .\src\Fantomas\AstTransformer.fs
Line count: 3412
Time taken: 00:00:06.7715936 s
.\src\Fantomas\AstTransformer.fs has been written.
Processing .\src\Fantomas\CodeFormatter.fs
Line count: 74
Time taken: 00:00:00.0449502 s
.\src\Fantomas\CodeFormatter.fs has been written.
Processing .\src\Fantomas\CodeFormatter.fsi
Line count: 78
Time taken: 00:00:00.0672252 s
.\src\Fantomas\CodeFormatter.fsi has been written.
Processing .\src\Fantomas\CodeFormatter.fsx
Line count: 4
Time taken: 00:00:00.0027137 s
.\src\Fantomas\CodeFormatter.fsx has been written.
Processing .\src\Fantomas\CodeFormatterImpl.fs
Line count: 1412
Time taken: 00:00:02.3721627 s
.\src\Fantomas\CodeFormatterImpl.fs has been written.
Processing .\src\Fantomas\CodePrinter.fs
Line count: 5674
Time taken: 00:00:38.1317375 s
.\src\Fantomas\CodePrinter.fs has been written.
Processing .\src\Fantomas\ConfigFile.fs
Line count: 122
Time taken: 00:00:00.0424725 s
.\src\Fantomas\ConfigFile.fs has been written.
Processing .\src\Fantomas\Context.fs
Line count: 2036
Time taken: 00:00:06.5343069 s
.\src\Fantomas\Context.fs has been written.
Processing .\src\Fantomas\Dbg.fs
Line count: 160
Time taken: 00:00:00.0662134 s
.\src\Fantomas\Dbg.fs has been written.
Processing .\src\Fantomas\EditorConfig.fs
Line count: 14
Time taken: 00:00:00.0041450 s
.\src\Fantomas\EditorConfig.fs has been written.
Processing .\src\Fantomas\FakeHelpers.fs
Line count: 290
Time taken: 00:00:00.1054283 s
.\src\Fantomas\FakeHelpers.fs has been written.
Processing .\src\Fantomas\FormatConfig.fs
Line count: 156
Time taken: 00:00:00.0367495 s
.\src\Fantomas\FormatConfig.fs has been written.
Processing .\src\Fantomas\JsonConfig.fs
Line count: 40
Time taken: 00:00:00.0384237 s
.\src\Fantomas\JsonConfig.fs has been written.
Processing .\src\Fantomas\Queue.fs
Line count: 264
Time taken: 00:00:00.0959729 s
.\src\Fantomas\Queue.fs has been written.
Processing .\src\Fantomas\RangeHelpers.fs
Line count: 56
Time taken: 00:00:00.0157040 s
.\src\Fantomas\RangeHelpers.fs has been written.
Processing .\src\Fantomas\SourceOrigin.fs
Line count: 12
Time taken: 00:00:00.0028508 s
.\src\Fantomas\SourceOrigin.fs has been written.
Processing .\src\Fantomas\SourceParser.fs
Line count: 2754
Time taken: 00:00:09.3776431 s
.\src\Fantomas\SourceParser.fs has been written.
Processing .\src\Fantomas\SourceTransformer.fs
Line count: 260
Time taken: 00:00:00.0717684 s
.\src\Fantomas\SourceTransformer.fs has been written.
Processing .\src\Fantomas\TokenParser.fs
Line count: 1008
Time taken: 00:00:01.6480482 s
.\src\Fantomas\TokenParser.fs has been written.
Processing .\src\Fantomas\TokenParserBoolExpr.fs
Line count: 616
Time taken: 00:00:00.9755313 s
.\src\Fantomas\TokenParserBoolExpr.fs has been written.
Processing .\src\Fantomas\Trivia.fs
Line count: 810
Time taken: 00:00:00.6074680 s
.\src\Fantomas\Trivia.fs has been written.
Processing .\src\Fantomas\TriviaContext.fs
Line count: 174
Time taken: 00:00:00.1065514 s
.\src\Fantomas\TriviaContext.fs has been written.
Processing .\src\Fantomas\TriviaHelpers.fs
Line count: 186
Time taken: 00:00:00.0575654 s
.\src\Fantomas\TriviaHelpers.fs has been written.
Processing .\src\Fantomas\TriviaTypes.fs
Line count: 114
Time taken: 00:00:00.0108739 s
.\src\Fantomas\TriviaTypes.fs has been written.
Processing .\src\Fantomas\Utils.fs
Line count: 262
Time taken: 00:00:00.1944116 s
.\src\Fantomas\Utils.fs has been written.
Processing .\src\Fantomas\Version.fs
Line count: 22
Time taken: 00:00:00.0068082 s
.\src\Fantomas\Version.fs has been written.
Processing .\src\Fantomas.CoreGlobalTool\Program.fs
Line count: 724
Time taken: 00:00:00.5725054 s
.\src\Fantomas.CoreGlobalTool\Program.fs has been written.
Processing .\src\Fantomas.CoreGlobalTool.Tests\ByteOrderMarkTests.fs
Line count: 80
Time taken: 00:00:00.0227983 s
.\src\Fantomas.CoreGlobalTool.Tests\ByteOrderMarkTests.fs has been written.
Processing .\src\Fantomas.CoreGlobalTool.Tests\CheckTests.fs
Line count: 76
Time taken: 00:00:00.0142106 s
.\src\Fantomas.CoreGlobalTool.Tests\CheckTests.fs has been written.
Processing .\src\Fantomas.CoreGlobalTool.Tests\TestHelpers.fs
Line count: 102
Time taken: 00:00:00.0582156 s
.\src\Fantomas.CoreGlobalTool.Tests\TestHelpers.fs has been written.
Processing .\src\Fantomas.Tests\ActivePatternTests.fs
Line count: 122
Time taken: 00:00:00.0188704 s
.\src\Fantomas.Tests\ActivePatternTests.fs has been written.
Processing .\src\Fantomas.Tests\AppTests.fs
Line count: 156
Time taken: 00:00:00.0162830 s
.\src\Fantomas.Tests\AppTests.fs has been written.
Processing .\src\Fantomas.Tests\AttributeTests.fs
Line count: 670
Time taken: 00:00:00.0821015 s
.\src\Fantomas.Tests\AttributeTests.fs has been written.
Processing .\src\Fantomas.Tests\CheckTests.fs
Line count: 128
Time taken: 00:00:00.0222813 s
.\src\Fantomas.Tests\CheckTests.fs has been written.
Processing .\src\Fantomas.Tests\ClassTests.fs
Line count: 1084
Time taken: 00:00:00.1373056 s
.\src\Fantomas.Tests\ClassTests.fs has been written.
Processing .\src\Fantomas.Tests\CommentTests.fs
Line count: 1594
Time taken: 00:00:00.2335332 s
.\src\Fantomas.Tests\CommentTests.fs has been written.
Processing .\src\Fantomas.Tests\ComparisonTests.fs
Line count: 72
Time taken: 00:00:00.0117314 s
.\src\Fantomas.Tests\ComparisonTests.fs has been written.
Processing .\src\Fantomas.Tests\CompilerDirectivesTests.fs
Line count: 2940
Time taken: 00:00:00.4918787 s
.\src\Fantomas.Tests\CompilerDirectivesTests.fs has been written.
Processing .\src\Fantomas.Tests\ComputationExpressionTests.fs
Line count: 558
Time taken: 00:00:00.0585740 s
.\src\Fantomas.Tests\ComputationExpressionTests.fs has been written.
Processing .\src\Fantomas.Tests\ContextTests.fs
Line count: 170
Time taken: 00:00:00.0541202 s
.\src\Fantomas.Tests\ContextTests.fs has been written.
Processing .\src\Fantomas.Tests\ControlStructureTests.fs
Line count: 878
Time taken: 00:00:00.1143775 s
.\src\Fantomas.Tests\ControlStructureTests.fs has been written.
Processing .\src\Fantomas.Tests\DynamicOperatorTests.fs
Line count: 68
Time taken: 00:00:00.0118580 s
.\src\Fantomas.Tests\DynamicOperatorTests.fs has been written.
Processing .\src\Fantomas.Tests\ElmishTests.fs
Line count: 242
Time taken: 00:00:00.0213606 s
.\src\Fantomas.Tests\ElmishTests.fs has been written.
Processing .\src\Fantomas.Tests\FormatAstTests.fs
Line count: 254
Time taken: 00:00:00.0481771 s
.\src\Fantomas.Tests\FormatAstTests.fs has been written.
Processing .\src\Fantomas.Tests\FormatConfigEditorConfigurationFileTests.fs
Line count: 4
Time taken: 00:00:00.0025162 s
.\src\Fantomas.Tests\FormatConfigEditorConfigurationFileTests.fs has been written.
Processing .\src\Fantomas.Tests\FormatConfigJsonConfigurationFileTests.fs
Line count: 402
Time taken: 00:00:00.1451803 s
.\src\Fantomas.Tests\FormatConfigJsonConfigurationFileTests.fs has been written.
Processing .\src\Fantomas.Tests\FormattingPropertyTests.fs
Line count: 1022
Time taken: 00:00:03.1263451 s
.\src\Fantomas.Tests\FormattingPropertyTests.fs has been written.
Processing .\src\Fantomas.Tests\FormattingSelectionOnlyTests.fs
Line count: 302
Time taken: 00:00:00.0835363 s
.\src\Fantomas.Tests\FormattingSelectionOnlyTests.fs has been written.
Processing .\src\Fantomas.Tests\FSharpScriptTests.fs
Line count: 202
Time taken: 00:00:00.0581230 s
.\src\Fantomas.Tests\FSharpScriptTests.fs has been written.
Processing .\src\Fantomas.Tests\FsUnit.fs
Line count: 154
Time taken: 00:00:00.0412177 s
.\src\Fantomas.Tests\FsUnit.fs has been written.
Processing .\src\Fantomas.Tests\FunctionDefinitionTests.fs
Line count: 1088
Time taken: 00:00:00.1975345 s
.\src\Fantomas.Tests\FunctionDefinitionTests.fs has been written.
Processing .\src\Fantomas.Tests\IfThenElseTests.fs
Line count: 1834
Time taken: 00:00:00.4569998 s
.\src\Fantomas.Tests\IfThenElseTests.fs has been written.
Processing .\src\Fantomas.Tests\InterfaceTests.fs
Line count: 398
Time taken: 00:00:00.0543430 s
.\src\Fantomas.Tests\InterfaceTests.fs has been written.
Processing .\src\Fantomas.Tests\LambdaTests.fs
Line count: 612
Time taken: 00:00:00.0875554 s
.\src\Fantomas.Tests\LambdaTests.fs has been written.
Processing .\src\Fantomas.Tests\LazyTests.fs
Line count: 82
Time taken: 00:00:00.0131086 s
.\src\Fantomas.Tests\LazyTests.fs has been written.
Processing .\src\Fantomas.Tests\LetBindingTests.fs
Line count: 1096
Time taken: 00:00:00.1530732 s
.\src\Fantomas.Tests\LetBindingTests.fs has been written.
Processing .\src\Fantomas.Tests\ListTests.fs
Line count: 3138
Time taken: 00:00:00.6076255 s
.\src\Fantomas.Tests\ListTests.fs has been written.
Processing .\src\Fantomas.Tests\LongIdentWithDotsTests.fs
Line count: 248
Time taken: 00:00:00.0198159 s
.\src\Fantomas.Tests\LongIdentWithDotsTests.fs has been written.
Processing .\src\Fantomas.Tests\ModuleTests.fs
Line count: 1008
Time taken: 00:00:00.1168719 s
.\src\Fantomas.Tests\ModuleTests.fs has been written.
Processing .\src\Fantomas.Tests\MultilineBlockBracketsOnSameColumnArrayOrListTests.fs
Line count: 360
Time taken: 00:00:00.0478609 s
.\src\Fantomas.Tests\MultilineBlockBracketsOnSameColumnArrayOrListTests.fs has been written.
Processing .\src\Fantomas.Tests\MultilineBlockBracketsOnSameColumnRecordTests.fs
Line count: 1036
Time taken: 00:00:00.1506103 s
.\src\Fantomas.Tests\MultilineBlockBracketsOnSameColumnRecordTests.fs has been written.
Processing .\src\Fantomas.Tests\NewlineBetweenTypeDefinitionAndMembersTests.fs
Line count: 404
Time taken: 00:00:00.0477174 s
.\src\Fantomas.Tests\NewlineBetweenTypeDefinitionAndMembersTests.fs has been written.
Processing .\src\Fantomas.Tests\NoTrailingSpacesTests.fs
Line count: 50
Time taken: 00:00:00.0085461 s
.\src\Fantomas.Tests\NoTrailingSpacesTests.fs has been written.
Processing .\src\Fantomas.Tests\OperatorTests.fs
Line count: 890
Time taken: 00:00:00.1797378 s
.\src\Fantomas.Tests\OperatorTests.fs has been written.
Processing .\src\Fantomas.Tests\PatternMatchingTests.fs
Line count: 936
Time taken: 00:00:00.1462348 s
.\src\Fantomas.Tests\PatternMatchingTests.fs has been written.
Processing .\src\Fantomas.Tests\PipingTests.fs
Line count: 156
Time taken: 00:00:00.0175642 s
.\src\Fantomas.Tests\PipingTests.fs has been written.
Processing .\src\Fantomas.Tests\QuotationTests.fs
Line count: 62
Time taken: 00:00:00.0107726 s
.\src\Fantomas.Tests\QuotationTests.fs has been written.
Processing .\src\Fantomas.Tests\RecordTests.fs
Line count: 1874
Time taken: 00:00:00.3535472 s
.\src\Fantomas.Tests\RecordTests.fs has been written.
Processing .\src\Fantomas.Tests\SignatureTests.fs
Line count: 1108
Time taken: 00:00:00.1582133 s
.\src\Fantomas.Tests\SignatureTests.fs has been written.
Processing .\src\Fantomas.Tests\SpaceBeforeClassConstructorTests.fs
Line count: 226
Time taken: 00:00:00.0332451 s
.\src\Fantomas.Tests\SpaceBeforeClassConstructorTests.fs has been written.
Processing .\src\Fantomas.Tests\SpaceBeforeLowercaseInvocationTests.fs
Line count: 84
Time taken: 00:00:00.0182367 s
.\src\Fantomas.Tests\SpaceBeforeLowercaseInvocationTests.fs has been written.
Processing .\src\Fantomas.Tests\SpaceBeforeMemberTests.fs
Line count: 84
Time taken: 00:00:00.0105312 s
.\src\Fantomas.Tests\SpaceBeforeMemberTests.fs has been written.
Processing .\src\Fantomas.Tests\SpaceBeforeParameterTests.fs
Line count: 156
Time taken: 00:00:00.0354483 s
.\src\Fantomas.Tests\SpaceBeforeParameterTests.fs has been written.
Processing .\src\Fantomas.Tests\SpaceBeforeSemicolonTests.fs
Line count: 240
Time taken: 00:00:00.0405288 s
.\src\Fantomas.Tests\SpaceBeforeSemicolonTests.fs has been written.
Processing .\src\Fantomas.Tests\SpaceBeforeUppercaseInvocationTests.fs
Line count: 100
Time taken: 00:00:00.0221866 s
.\src\Fantomas.Tests\SpaceBeforeUppercaseInvocationTests.fs has been written.
Processing .\src\Fantomas.Tests\SpecialConstructsTests.fs
Line count: 72
Time taken: 00:00:00.0124441 s
.\src\Fantomas.Tests\SpecialConstructsTests.fs has been written.
Processing .\src\Fantomas.Tests\StringTests.fs
Line count: 398
Time taken: 00:00:00.0493156 s
.\src\Fantomas.Tests\StringTests.fs has been written.
Processing .\src\Fantomas.Tests\StructTests.fs
Line count: 212
Time taken: 00:00:00.0210633 s
.\src\Fantomas.Tests\StructTests.fs has been written.
Processing .\src\Fantomas.Tests\SynConstTests.fs
Line count: 318
Time taken: 00:00:00.0283935 s
.\src\Fantomas.Tests\SynConstTests.fs has been written.
Processing .\src\Fantomas.Tests\SynExprSetTests.fs
Line count: 88
Time taken: 00:00:00.0120577 s
.\src\Fantomas.Tests\SynExprSetTests.fs has been written.
Processing .\src\Fantomas.Tests\TestHelpers.fs
Line count: 414
Time taken: 00:00:00.1716740 s
.\src\Fantomas.Tests\TestHelpers.fs has been written.
Processing .\src\Fantomas.Tests\TokenParserBoolExprTests.fs
Line count: 516
Time taken: 00:00:00.3144126 s
.\src\Fantomas.Tests\TokenParserBoolExprTests.fs has been written.
Processing .\src\Fantomas.Tests\TokenParserTests.fs
Line count: 1028
Time taken: 00:00:00.5781528 s
.\src\Fantomas.Tests\TokenParserTests.fs has been written.
Processing .\src\Fantomas.Tests\TriviaTests.fs
Line count: 1080
Time taken: 00:00:00.4713149 s
.\src\Fantomas.Tests\TriviaTests.fs has been written.
Processing .\src\Fantomas.Tests\TupleTests.fs
Line count: 56
Time taken: 00:00:00.0093070 s
.\src\Fantomas.Tests\TupleTests.fs has been written.
Processing .\src\Fantomas.Tests\TypeDeclarationTests.fs
Line count: 2136
Time taken: 00:00:00.4421736 s
.\src\Fantomas.Tests\TypeDeclarationTests.fs has been written.
Processing .\src\Fantomas.Tests\TypeProviderTests.fs
Line count: 154
Time taken: 00:00:00.0239734 s
.\src\Fantomas.Tests\TypeProviderTests.fs has been written.
Processing .\src\Fantomas.Tests\UnionTests.fs
Line count: 752
Time taken: 00:00:00.1194746 s
.\src\Fantomas.Tests\UnionTests.fs has been written.
Processing .\src\Fantomas.Tests\UtilsTests.fs
Line count: 210
Time taken: 00:00:00.0159610 s
.\src\Fantomas.Tests\UtilsTests.fs has been written.
Processing .\src\Fantomas.Tests\ValidationTests.fs
Line count: 56
Time taken: 00:00:00.0106932 s
.\src\Fantomas.Tests\ValidationTests.fs has been written.
Processing .\src\Fantomas.Tests\VerboseSyntaxConversionTests.fs
Line count: 56
Time taken: 00:00:00.0064673 s
.\src\Fantomas.Tests\VerboseSyntaxConversionTests.fs has been written.

Fantomas can format itself for some weeks now.
I'm currently waiting for a good moment to make a PR as 90 files change.
Of course, once we merge the formatted code base we should continue formatting it in each PR.
So yeah, my vague plan is to have every active PR merged in, then release another alpha and use that version to start formatting Fantomas.

nojaf added a commit to nojaf/fantomas that referenced this issue Sep 4, 2020
nojaf added a commit that referenced this issue Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants