Skip to content

style_files -> vectorized style_file #273

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

Merged
merged 2 commits into from
Nov 9, 2017

Conversation

lorenzwalthert
Copy link
Collaborator

Closes #219. Should we depreciate style_file() in favour of style_files() or should we rename style_files() to style_file() and only use the current implementation of style_file() internally (e.g. as style_file_one())?

@lorenzwalthert lorenzwalthert requested a review from krlmlr November 5, 2017 22:10
@krlmlr
Copy link
Member

krlmlr commented Nov 8, 2017

I prefer the latter option, keep API and rename style_file() -> style_file_one() .

@@ -10,12 +10,17 @@ test_that("styler can style directory", {
expect_false(all(style_dir(testthat_file("public-api", "xyzdir"))))
})

test_that("styler can style file", {
test_that("styler can style files", {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to test character(0) as argument, or a TRUE return value if contents change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if I understand you correctly. Well, the idea was just to check whether calling the function causes an error or not. Since the files were already styled, we don't expect any changes. So you wanted to test whether the output of style_file() is character(0)?

Copy link
Member

Choose a reason for hiding this comment

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

Seems that style_file() returns a logical vector, but the test only tests FALSE return values. Is there a test for a TRUE return value? If not, we might need one.

Likewise, empty input should lead to logical(0) .

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes we have never explicitly tested for a return value other than TRUE because the majority of our tests works with test_collection() that transforms an input with a transformer function (in our case style_text()) and compares the output to a reference.
Do you think we need a test for it? If yes, we'd probably best write a function that takes as input the path of a mal-styled file, copies it to a temp directory, styles it, saves the direct return value of style_file()and then discards the files in the temp directory. I just hoped to get around that because it may bear additional problems with paths for covr or testthat for limited gain, but if you want, I can implement that.

Copy link
Member

Choose a reason for hiding this comment

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

No, that's not a priority, I was just wondering when looking at the tests.

@codecov-io
Copy link

Codecov Report

Merging #273 into master will increase coverage by 0.28%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #273      +/-   ##
==========================================
+ Coverage   92.87%   93.16%   +0.28%     
==========================================
  Files          28       28              
  Lines        1123     1155      +32     
==========================================
+ Hits         1043     1076      +33     
+ Misses         80       79       -1
Impacted Files Coverage Δ
R/ui.R 100% <100%> (ø) ⬆️
R/token-create.R 100% <0%> (ø) ⬆️
R/relevel.R 100% <0%> (ø) ⬆️
R/nested_to_tree.R 100% <0%> (ø) ⬆️
R/initialize.R 100% <0%> (+2.43%) ⬆️

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 2ebf31c...d760b7c. Read the comment docs.

@lorenzwalthert lorenzwalthert merged commit 2f897d5 into r-lib:master Nov 9, 2017
@lorenzwalthert lorenzwalthert deleted the style-files branch November 21, 2017 09:11
krlmlr added a commit that referenced this pull request Nov 27, 2017
- Adapt documentation (#290).
- Add roundtrip (#287).
- Fix AppVeyor builds.
- Fix token insertion / comment interaction (#279).
- Clarify labelling strategy (#285).
- Fixing and extending Rstudioaddins (#283).
- Fix eq assign parsing (#276).
- style_files -> vectorized style_file (#273).
- Refactoring (#270).
- Fix CI (#275).
- Fix covr (#274).
- Renaming files (#271).
- Handle styling of an unsaved active file (#243).
- Test R 3.1 and R 3.2 (#249).
- Allow empty {} without line break (#261).
- Wrap expr in expr before enclosing with curly braces (#263).
- Avoid checking for hard-coded dot (#262).
- Account for dependency renaming (utf8 changed to enc) (#264).
- Indention of function declaration and closing braces (#260).
- Only remove line break before closing with strict option (#252).
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.

3 participants