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

When cutting off function invocations, should place each param in its own line (or align them to the 1st param) #907

Closed
knocte opened this issue Jun 11, 2020 · 2 comments · Fixed by #929

Comments

@knocte
Copy link
Contributor

knocte commented Jun 11, 2020

Issue created from fantomas-online

Please describe here fantomas problem you encountered

Code

module Caching =
    type MainCache() =
        member __.RetrieveLastCompoundBalance (address: PublicAddress)
                                              (currency: Currency): NotFresh<decimal> =
            lock cacheFiles.CachedNetworkData (fun _ ->
                match balance with
                | NotAvailable -> NotAvailable
                | Cached (balance, time) ->
                    if compoundBalance < 0.0m then
                        ReportProblem compoundBalance None currency address sessionCachedNetworkData
                    ()
            )
            ()

Result

module Caching =
    type MainCache() =
        member __.RetrieveLastCompoundBalance (address: PublicAddress)
                                              (currency: Currency): NotFresh<decimal> =
            lock cacheFiles.CachedNetworkData (fun _ ->
                match balance with
                | NotAvailable -> NotAvailable
                | Cached (balance, time) ->
                    if compoundBalance < 0.0m then
                        ReportProblem compoundBalance None currency address
                            sessionCachedNetworkData
                    ())
            ()

Expected Result

The way that fantomas has cut off the parameters to the ReportProblem function looks a bit weird.

I think it should either do this:

module Caching =
    type MainCache() =
        member __.RetrieveLastCompoundBalance (address: PublicAddress)
                                              (currency: Currency): NotFresh<decimal> =
            lock cacheFiles.CachedNetworkData (fun _ ->
                match balance with
                | NotAvailable -> NotAvailable
                | Cached (balance, time) ->
                    if compoundBalance < 0.0m then
                        ReportProblem
                            compoundBalance None currency address sessionCachedNetworkData
                    ())
            ()

or this:

module Caching =
    type MainCache() =
        member __.RetrieveLastCompoundBalance (address: PublicAddress)
                                              (currency: Currency): NotFresh<decimal> =
            lock cacheFiles.CachedNetworkData (fun _ ->
                match balance with
                | NotAvailable -> NotAvailable
                | Cached (balance, time) ->
                    if compoundBalance < 0.0m then
                        ReportProblem
                            compoundBalance
                            None
                            currency
                            address
                            sessionCachedNetworkData
                    ())
            ()

or this:

module Caching =
    type MainCache() =
        member __.RetrieveLastCompoundBalance (address: PublicAddress)
                                              (currency: Currency): NotFresh<decimal> =
            lock cacheFiles.CachedNetworkData (fun _ ->
                match balance with
                | NotAvailable -> NotAvailable
                | Cached (balance, time) ->
                    if compoundBalance < 0.0m then
                        ReportProblem compoundBalance
                                      None
                                      currency
                                      address
                                      sessionCachedNetworkData
                    ())
            ()

Options

Fantomas Master at 06/10/2020 08:33:01 - 50ed1b7

Name Value
IndentSpaceNum 4
PageWidth 80
SemicolonAtEndOfLine false
SpaceBeforeParameter true
SpaceBeforeLowercaseInvocation true
SpaceBeforeUppercaseInvocation false
SpaceBeforeClassConstructor false
SpaceBeforeMember false
SpaceBeforeColon false
SpaceAfterComma true
SpaceBeforeSemicolon false
SpaceAfterSemicolon true
IndentOnTryWith false
SpaceAroundDelimiter true
MaxIfThenElseShortWidth 40
MaxInfixOperatorExpression 50
MaxRecordWidth 40
MaxArrayOrListWidth 40
MaxValueBindingWidth 40
MaxFunctionBindingWidth 0
MultilineBlockBracketsOnSameColumn false
NewlineBetweenTypeDefinitionAndMembers false
KeepIfThenInSameLine false
StrictMode false
@knocte
Copy link
Contributor Author

knocte commented Jun 11, 2020

And from the 3 possible expected results I gave above, this would be more in sync with what fantomas does currently, if the parameters are not currified:

                    if compoundBalance < 0.0m then
                        ReportProblem
                            compoundBalance
                            None
                            currency
                            address
                            sessionCachedNetworkData

knocte added a commit to nblockchain/geewallet that referenced this issue Jun 11, 2020
Source will be formatted using this command:
fantomas --config fantomas-config.json --recurse src/GWallet.Backend/

This version of fantomas doesn't crash anymore when formatting it:
dotnet tool install -g fantomas-tool --add-source https://www.myget.org/F/fantomas/api/v3/index.json --framework netcoreapp3.1 --version 4.0.0-alpha-008-alpha-190

Last issues left to fix (by order of priority, top is more important):

- fsprojects/fantomas#898 (comment)

- fsprojects/fantomas#907

- fsprojects/fantomas#905

- fsprojects/fantomas#908

- fsprojects/fantomas#712

- fsprojects/fantomas#904
@nojaf
Copy link
Contributor

nojaf commented Jun 15, 2020

It indeed makes most sense that Fantomas would go for:

     ReportProblem
         compoundBalance
         None
         currency
         address
         sessionCachedNetworkData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants