jfmengels / elm-review

Analyzes Elm projects, to help find mistakes before your users find them.
https://package.elm-lang.org/packages/jfmengels/elm-review/latest/
Other
255 stars 13 forks source link

NoLeftOverPizza #78

Closed sparksp closed 3 years ago

sparksp commented 4 years ago

What the rule should do:

Forbid simple uses of right pizza (|>) that would not add any parens if removed.

What problems does it solve:

Pizza can make the place look untidy.

Example of things the rule would report:

    context |> rememberElmJsonProject project

Example of things the rule would not report:

    getContext model |> rememberElmJsonProject project
    context
        |> rememberElmJsonProject project
        |> rememberSomethingElse something

When (not) to enable this rule:

If you really like pizza then this rule might not be for you. Right pizza are often used to show a pipeline, but right pizza may also be used to change the focus of an expression - this rule may complain about such expressions.

I am looking for:

lydell commented 4 years ago

I would like to see this for left pizza. getName <| person can be refactored to getName person.

jfmengels commented 4 years ago

@lydell elm-review-noleftpizza already offers that with NoLeftPizza.rule NoLeftPizza.Redundant.

lydell commented 4 years ago

Thanks! Given the name – no left pizza – I didn’t expect finding that there. But I guess it makes sense now.

jfmengels commented 4 years ago

It wasn't there in the first iteration ;)

Back on the subject, I agree with this rule, this is a small pet peeve of mine and I often refactor things to remove this way manually. I think this could be auto-fixed, but I guess it can be a painful one to write. I know that some of my colleagues will be very annoyed at this kind of reports if they need to fix it manually.