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

Rule to recommend not to use the pipe operator if it's only used once #595

Merged
merged 20 commits into from
Dec 5, 2023

Conversation

tehraninasab
Copy link
Contributor

Fixes #594

@knocte
Copy link
Collaborator

knocte commented Dec 21, 2022

I've realised that this is going too far and the rule is going to raise too many warnings.

Let's have this new test:

let someFunc someParam =
    someOtherFunc1 someParam
    |> someOtherFunc2

And the rule should not give errors for the above, even if the pipe operator is only used once. Why? Because the alternative would be someOtherFunc2 (someOtherFunc1 someParam), and using the operator in this case is avoiding the use of parentheses, which is fair enough.

BTW let's rename the rule to AvoidOnePipeOperator, to make it crystal clear that multiple pipes are fine.

@tehraninasab tehraninasab force-pushed the avoid-one-pipe-squashed branch from 5ae0654 to 20f0bcd Compare December 21, 2022 10:42
@tehraninasab
Copy link
Contributor Author

I've realised that this is going too far and the rule is going to raise too many warnings.

Let's have this new test:

let someFunc someParam =
    someOtherFunc1 someParam
    |> someOtherFunc2

And the rule should not give errors for the above, even if the pipe operator is only used once. Why? Because the alternative would be someOtherFunc2 (someOtherFunc1 someParam), and using the operator in this case is avoiding the use of parentheses, which is fair enough.

BTW let's rename the rule to AvoidOnePipeOperator, to make it crystal clear that multiple pipes are fine.

Added the test and fixed the rule to pass it. But, the name of the rule is already AvoidOnePipeOperator

@knocte
Copy link
Collaborator

knocte commented Dec 22, 2022

But, the name of the rule is already AvoidOnePipeOperator

Sorry, I meant AvoidSinglePipeOperator.

@knocte
Copy link
Collaborator

knocte commented Apr 24, 2023

Why is CI red?

@tehraninasab tehraninasab force-pushed the avoid-one-pipe-squashed branch from 7b7a2ad to f481812 Compare May 11, 2023 12:07
@knocte knocte merged commit de3bd65 into fsprojects:master Dec 5, 2023
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 this pull request may close these issues.

Rule to recommend not to use the pipe operator if it's only used once
2 participants