Skip to content

adapt line break rules. - #172

Merged
lorenzwalthert merged 3 commits into
r-lib:masterfrom
lorenzwalthert:fix_line_break
Sep 7, 2017
Merged

lorenzwalthert merged 3 commits into
r-lib:masterfrom
lorenzwalthert:fix_line_break

Conversation

@lorenzwalthert

@lorenzwalthert lorenzwalthert commented Aug 30, 2017 •

Copy link
Copy Markdown
Collaborator

Closes #171.

@codecov

codecov Bot commented Aug 30, 2017 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@10708a3). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #172   +/-   ##
=========================================
  Coverage          ?   93.25%           
=========================================
  Files             ?       20           
  Lines             ?      801           
  Branches          ?        0           
=========================================
  Hits              ?      747           
  Misses            ?       54           
  Partials          ?        0
Impacted Files Coverage Δ
R/rules-line_break.R 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 10708a3...c40e81e. Read the comment docs.

@krlmlr krlmlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

)

call(am # comment
) # FIXME: maybe move ')' up and switch position with the comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better push am to its own line then.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. So that means when checking whether an expression is multi-line, we also consider the closing ). So in general,

call(a
)

Becomes

call(
  a
)

Instead of

call(a)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say only if a comment is involved, but both solutions work.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I prefer the former then.

@lorenzwalthert

Copy link
Copy Markdown
Collaborator Author

Because the multi_line attribute is not available at that stage, we can only check via lag_newlines whether an expression spans multiple lines. That means for example that

call(
  1,
  call2(3, 4, call(
    3,
    4, call(5, 6, call(
      2
    )
    )
  )
  )
)

Will become

call(
  1,
  call2(3, 4, call(
    3,
    4, call(5, 6, call(
      2
    ))
  ))
)

I think it's fine, since if you open multiple parentheses on one line, why not also closing them on the same line? It also plays nicely with indention. @krlmlr what do you think? Alternatively, we had to leave

call(a
)

As is.

@lorenzwalthert
lorenzwalthert merged commit 4d97411 into r-lib:master Sep 7, 2017
@lorenzwalthert
lorenzwalthert deleted the fix_line_break branch September 7, 2017 15:37
krlmlr added a commit that referenced this pull request Oct 23, 2017
- Hotfix: utf8 should not be verbose (#245).
- Allow styling of Rmd files(#233).
- Remove duplicate @family (#244).
- Fixing token insertion (#242).
- Capitalize Addin titles (#241).
- Explicit `NULL` creation to make styler compatible with R3.2.0 (#237).
- Improve vignettes (#232).
- Allow exclusion of files with `style_pkg()` and `style_dir()`.
- Correct styling with long strings (#230).
- Add tools for re-indenting tokens (#217).
- Math token spacing (#221).
- Remove outdated line and col information (#218).
- Empty input for styling does not cause an error (#227, #228).
- Tools to insert tokens + application on `if`-`else` clauses (#212).
- Improve example in documentation (#222).
- Fix spacing around in (#214).
- Maintenance: renaming functions / files, extend helper, documentation, if_else etc. (#204).
- Disallow line break after ( for function calls (#210).
- Preserve space between `!` and bang (#209).
- Simplify RStudio Addin (#208, #211).
- Indention based on square brackets (#207).
- Add vignette on introducing styler (#203).
- Indent function declaration without curly braces correctly (#202).
- Fix indention in if-else statement (#200).
- Sorting key (#196).
- Use safe sequences (#197).
- Fix space between two commas (#195).
- Keep single-line pipes on one line (#74).
- Remove tidyr and dplyr dependency (#182, #183, @jimhester).
- Fix parsing inconsistency (#188).
- Substitute create filler (#190).
- Introducing class vertical (#189).
- Adapt line break rules (#172).
- Fix `R CMD check` (#185).
- Force argument evaluation for proper error handling (#179).
- Add nonstrict version of set_space_before_comment (#174).
- Add installation instructions to README (#175).
- Addin to style highlighted region (#143).
- Improve spelling (#168).
- Add coverage badge
- Change badge from WIP to active
- Add the number of files to message (#166).
- Improve documentation (#164).
- Add informative messages while styling files (#165).
- More examples in help file (#161).
- No line breaks after pipe if comment is next token (#160).
- Fixing spacing around `!` (non-bang-bang) (#157).
- Finalize function documentation (#154).
- Review vignette (#158).
- Update bang-bang rule (#156).
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.

2 participants