Skip to content

Breaking short chained methods #164

@csilvers

Description

@csilvers

For most chained methods, the new chain-split-dots behavior makes sense. But there are a few types where it doesn't. For instance, we have this code:

suite.Assert().Equal("some long string", myvar)

golines reformats it like this:

suite.Assert()
    .Equal("some long string", myvar)

whereas the more natural reformatting would be:

suite.Assert().Equal(
    "some long string", 
    myvar,
)

The heuristic in my head is: if all parts of the chain fit on one line, except for the arguments to the last function in the chain, treat it like a single function call rather than a chained function call.

So this is a feature request: to add another option (besides chain-split-dots and no-chain-split-dots) that could implement that heuristic. I'd also be ok with just changing the behavior of chain-split-dots to match that heuristic, but it may be too invasive for existing users...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions