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

Line break after pipe #503

Merged
merged 5 commits into from May 3, 2019

Conversation

@lorenzwalthert
Copy link
Collaborator

commented May 2, 2019

This PR implements the rule that %>% must usually be followed by a new line. 99% of the cases are:

blue %>% green() 
# is turned into
blue %>%
  green()

Exceptions are various constellations within function calls. This is discouraged practice anyways but we don't want to make things worse

call(a, b %>% c())

# won't be turned into
call(
  a, b %>% 
    c()
)
# or similar

See test files added in this PR for more examples.

Reason: It's not non-invasive and comes at a technically high cost (relatively large slow-down for edge case), more complex code.

call(d = g(b) %>% 
  c)

should probably be turned into

call(
  d = g(b) %>% 
    c
)

But it is not, again because of the same reasons. A more natural choice would be

call(d = g(b) %>% c)

in many cases.

This closes #470.

@lorenzwalthert lorenzwalthert force-pushed the lorenzwalthert:line-break-pipe branch from 28df8ba to f8b39ef May 3, 2019

@codecov-io

This comment has been minimized.

Copy link

commented May 3, 2019

Codecov Report

Merging #503 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #503      +/-   ##
==========================================
- Coverage   90.26%   90.25%   -0.02%     
==========================================
  Files          39       39              
  Lines        1675     1672       -3     
==========================================
- Hits         1512     1509       -3     
  Misses        163      163
Impacted Files Coverage Δ
R/style-guides.R 100% <100%> (ø) ⬆️
R/rules-line-break.R 100% <100%> (ø) ⬆️
R/transform-files.R 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 37381a3...f8b39ef. Read the comment docs.

@lorenzwalthert lorenzwalthert merged commit 88722c7 into r-lib:master May 3, 2019

1 of 2 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.