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

[Refactoring] Replace Paths.get with Path.of #43093

Conversation

Shadow-Devil
Copy link
Contributor

@Shadow-Devil Shadow-Devil commented Jul 13, 2024

Purpose

It is recommended to use Path.of instead of Paths.get.

If we’re working with a version between Java 7 and 10, we have no other choice but to use Paths.get(). Otherwise, if we’re working with a later version, we should go for Path.of(). The Paths class may indeed be deprecated in a future Java release, as it’s stated in the class’ comments. Moreover, using directly the factory method from Path spares an additional input.

https://www.baeldung.com/java-paths-get-path-of#which-one-should-we-use

Other Improvements:

  • Path.of("a", "b", "c") can be replaced with Path.of("a/b/c"). The Path API is handling OS specific handling.
  • path.resolve("a").resolve("b").resolve("c") can be replaced with path.resolve("a/b/c").

Both improvements are shorter and can be copy-pasted as Linux paths.

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

Copy link

codecov bot commented Jul 13, 2024

Codecov Report

Attention: Patch coverage is 72.90640% with 55 lines in your changes missing coverage. Please review.

Project coverage is 77.50%. Comparing base (35407ff) to head (c61fc38).
Report is 88 commits behind head on master.

Files with missing lines Patch % Lines
...ntime/transactions/TransactionResourceManager.java 0.00% 3 Missing ⚠️
...src/main/java/io/ballerina/cli/cmd/DocCommand.java 57.14% 2 Missing and 1 partial ⚠️
...java/io/ballerina/projects/internal/BalaFiles.java 25.00% 3 Missing ⚠️
...allerinalang/bindgen/utils/BindgenMvnResolver.java 50.00% 3 Missing ⚠️
...llerinalang/docgen/docs/BallerinaDocGenerator.java 0.00% 3 Missing ⚠️
.../java/io/ballerina/cli/launcher/LauncherUtils.java 0.00% 2 Missing ⚠️
...rc/main/java/io/ballerina/projects/BalaWriter.java 81.81% 2 Missing ⚠️
...nalang/repository/fs/LocalFSPackageRepository.java 0.00% 2 Missing ⚠️
...in/java/org/wso2/ballerinalang/util/RepoUtils.java 50.00% 2 Missing ⚠️
...ballerina/connector/BallerinaConnectorService.java 0.00% 2 Missing ⚠️
... and 28 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #43093      +/-   ##
============================================
- Coverage     77.51%   77.50%   -0.01%     
- Complexity    58594    58596       +2     
============================================
  Files          3438     3438              
  Lines        219234   219259      +25     
  Branches      28917    28924       +7     
============================================
+ Hits         169934   169938       +4     
- Misses        39880    39902      +22     
+ Partials       9420     9419       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shadow-Devil
Copy link
Contributor Author

Fixed review suggestions in 52a7874

@Shadow-Devil Shadow-Devil force-pushed the replace-paths-get-with-path-of branch from 0857e6a to 566872d Compare July 20, 2024 19:52
@Shadow-Devil Shadow-Devil force-pushed the replace-paths-get-with-path-of branch 2 times, most recently from bdb5a15 to 8f8438e Compare August 2, 2024 12:50
Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added Stale and removed Stale labels Aug 21, 2024
Copy link

github-actions bot commented Sep 8, 2024

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@Shadow-Devil
Copy link
Contributor Author

@gimantha Thank you for fixing the merge conflicts 😄

@gimantha gimantha merged commit ca94ad5 into ballerina-platform:master Oct 4, 2024
16 of 18 checks passed
@Shadow-Devil Shadow-Devil deleted the replace-paths-get-with-path-of branch October 4, 2024 07:15
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