Closed olivroy closed 5 months ago
The recent updates focus on enhancing file management functions in R scripts, including better conflict handling in renaming operations and making functions more robust and informative. Changes also include deprecation of outdated parameters, addition of new utility functions, and updates to documentation and testing to align with these improvements.
File Path | Change Summary |
---|---|
R/.../files-conflicts.R |
Updated solve_file_name_conflict to return count of conflicts and added logic for message display. |
R/.../rename-files.R |
Revamped rename_files2 with new parameters; deprecated force . Improved conflict handling logic. |
R/utils.R |
Added basename_remove_ext function. |
R/screenshot.R |
Updated screenshot function to include checks and new warn_conflicts parameter. |
TODO.R |
Updated to reflect deprecation of an RStudio addin feature in light of new version capabilities. |
man/.../rename_files2.Rd |
Enhanced documentation for rename_files2 with additional parameters and detailed behavior description. |
tests/... |
Extensive updates in test cases to reflect changes in file renaming logic and new utility functions. |
🐇✨ In the land of code and script,
A rabbit hopped, its updates slick.
Files renamed with care, no conflicts to stick,
With each line of code, the changes click.
Celebrate we do, with a carrot thick!
🥕🎉
tests/testthat/_snaps/rename-files.md (3)
Near line 43: Possible spelling mistake found. Context: ...b.R' without issue. # rename_files2(): priorizes references if name is generic or widely... --- Near line 43: You might be missing the article “the” here. Context: ...ename_files2(): priorizes references if name is generic or widely used in files ... --- Near line 75: It seems that the correct verb form here is “return”. Context: ...iles in some locations. # Helper files returns the expected input Code comp...
tests/testthat/_ref/my-analysis.R (2)
`6-6`: The comment provides context about the data being manipulated, which is good for maintainability. --- `10-11`: Using `fs::path()` for constructing file paths is a best practice in R for ensuring cross-platform compatibility.TODO.R (1)
`2-2`: Updating the TODO comment to reflect that the RStudio addin is no longer needed with RStudio 2023.12 helps keep the documentation current and prevents unnecessary work.tests/testthat/_snaps/rename-files.md (6)
`8-10`: The added instructions in the snapshot provide clear guidance on how to handle file path changes, which enhances user understanding and interaction with the function. --- `17-26`: The snapshot updates reflect the new `overwrite` parameter and provide a detailed view of the function's behavior when testing messages without action, which is crucial for accurate documentation. --- `31-32`: Setting `warn_conflicts` to "none" and observing the function's behavior in this scenario is well-documented in the snapshot, which is important for understanding edge cases. --- `50-51`: The snapshot effectively demonstrates how the function prioritizes references when dealing with generic or widely used file names, which is a critical aspect of the functionality. --- `58-65`: The handling of overridden preferences is clearly documented in the snapshot, showing how the function behaves with the `warn_conflicts` set to "all". This is essential for users who need to understand the impact of this setting. --- `70-85`: The introduction of the `check_referenced_files()` function in the code snapshot provides a clear example of its usage and the type of feedback it generates, which is valuable for debugging and ensuring file integrity.tests/testthat/test-rename-files.R (7)
`2-14`: Setting up a temporary directory and creating test files at the beginning of the test script is a good practice as it isolates the test environment and ensures that tests do not interfere with each other or with the user's files. --- `15-17`: The TODO comment about adding a test for `my-streets-raw.csv` is clear and actionable. It's good to see that this task is being tracked for future implementation. --- `26-38`: > :memo: **NOTE** > This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [20-32] The test cases for preventing dangerous file renaming are comprehensive, covering scenarios with missing extensions and non-existent files. This thorough testing is crucial for ensuring the robustness of the `rename_files2()` function. --- `41-131`: > :memo: **NOTE** > This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [35-46] The test cases for preventing file renaming due to conflicts are well-structured, using snapshots to capture the expected behavior. This approach helps verify that the function behaves as expected in scenarios with potential conflicts. --- `54-56`: The test case for renaming files when forced provides a clear example of the function's behavior with the `warn_conflicts` set to "none" and `overwrite` enabled. This is important for understanding how the function handles forceful actions. --- `64-85`: The test cases for handling short file names and overridden preferences are effectively documented, showing how the function behaves in these specific scenarios. This detailed testing is essential for ensuring that the function can handle a variety of input conditions. --- `92-130`: The test cases for deprecated parameters and checking referenced files are comprehensive, covering the expected deprecation warnings and the behavior of the `check_referenced_files()` function. This thorough testing ensures that deprecated features are handled correctly and that the function's file checking capabilities are robust.R/screenshot.R (1)
`168-178`: > :memo: **NOTE** > This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [171-196] The conditional check for the presence of certain file types before setting the `bullets` variable is a good practice, as it ensures that the function behaves correctly based on the content of the directory. Additionally, the use of the `warn_conflicts` parameter in the `rename_files2()` call is aligned with the function's need to handle potential naming conflicts without user intervention.
Goal
to have cleaner code Move into helper functions Clarify how we want `warn_conflicts to behave
Todo
rename_files2()
so that the flow is smoother.Note
adding a suffix often means we are adding precision, I would expect
rename_files2()
to be less picky. all goodTests
Add some for individuals parts
It is okay to recalculate things many times.
Summary by CodeRabbit