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

Allow short relative paths in imports #573

Merged
merged 2 commits into from Oct 14, 2020

Conversation

dmdashenkov
Copy link
Contributor

This PR fixes a crash in FileReference.directory(). Currently, the method throws an exception if the file reference has no directory, i.e. it's a simple file name (possibly, with the "./" prefix). This PR fixes that crash.

@dmdashenkov dmdashenkov self-assigned this Oct 13, 2020
@codecov
Copy link

codecov bot commented Oct 13, 2020

Codecov Report

Merging #573 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##             master     #573   +/-   ##
=========================================
  Coverage     77.35%   77.36%           
- Complexity     2981     2984    +3     
=========================================
  Files           499      499           
  Lines         11499    11503    +4     
  Branches        666      667    +1     
=========================================
+ Hits           8895     8899    +4     
  Misses         2377     2377           
  Partials        227      227           

@dmdashenkov
Copy link
Contributor Author

@armiol, PTAL.

Copy link
Collaborator

@armiol armiol left a comment

Choose a reason for hiding this comment

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

@dmdashenkov please see my comments.

@Test
@DisplayName("obtain the empty directory path")
void emptyDirectory() {
FileReference file = FileReference.of("./neighbour.txt");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Honestly, I would expect that the / symbol here would be a system-specific path delimiter. I don't know, but it seems to me that some Windows versions would gladly interpret .\neighbour.txt as a file in the current folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As this is an imported file reference, we only use this / type of slashes.

/**
* Obtains the reference to the current directory.
*/
public static DirectoryReference currentDir() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar to my comment below, I would expect that the reference to the current dir would be either "." or "." + File.separatorChar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is to remove the "." symbols, as they are not very helpful for resolving imports.

@dmdashenkov dmdashenkov merged commit c4d15f3 into master Oct 14, 2020
@dmdashenkov dmdashenkov deleted the allow-short-relative-paths-in-imports branch October 14, 2020 13:35
@alexander-yevsyukov alexander-yevsyukov added this to To Do in 1.7 via automation Oct 21, 2020
@alexander-yevsyukov alexander-yevsyukov moved this from To Do to Done in 1.7 Oct 21, 2020
This was referenced Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
1.7
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants