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

Stricter paths #7147

Merged
merged 3 commits into from
Apr 26, 2024
Merged

Stricter paths #7147

merged 3 commits into from
Apr 26, 2024

Conversation

BraisGabin
Copy link
Member

@BraisGabin BraisGabin commented Apr 8, 2024

Part of #7140

This PR makes our core more strict to how the paths should look like. I know that KtFiles will be removed. but that's the reason I'm doing this now. Our tests were a bit "loose" on the paths. With this change our tests are a better representation of what happen in the real life and can spot real bugs once we start to refactor this part of the code to remove KtFiles.

Comment on lines +56 to +58
require(absolutePath.isAbsolute) { "absolutePath should be absolute" }
require(basePath?.isAbsolute != false) { "basePath should be absolute" }
require(relativePath?.isAbsolute != true) { "relativePath should not be absolute" }
Copy link
Member Author

@BraisGabin BraisGabin Apr 8, 2024

Choose a reason for hiding this comment

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

Main change

@BraisGabin BraisGabin marked this pull request as draft April 8, 2024 15:36
Copy link

codecov bot commented Apr 8, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 84.67%. Comparing base (d4f3f99) to head (23381a1).

Files Patch % Lines
...ls/src/main/kotlin/io/github/detekt/psi/KtFiles.kt 0.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7147      +/-   ##
============================================
- Coverage     84.70%   84.67%   -0.03%     
  Complexity     3983     3983              
============================================
  Files           578      578              
  Lines         12151    12153       +2     
  Branches       2495     2498       +3     
============================================
- Hits          10292    10291       -1     
  Misses          625      625              
- Partials       1234     1237       +3     

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

@BraisGabin
Copy link
Member Author

BraisGabin commented Apr 12, 2024

Still working on make Windows tests happy :'(. My main problem right now is that / is not an absolute path on Windows... So to get the/a root I need to do Path("/").absolute(). This gets me / on Unix and D:\ (for example) on Windows.

The main problem is that I don't have windows so I need to use CI to debug the problems :'(

Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍 although I'm not really expert on paths so you probably want to wait anothe review.

Also there are conflicts to resolve


assertThat(filePath.toString())
.isEqualTo("FilePath(absolutePath=${ps}a${ps}b${ps}c, basePath=null, relativePath=null)")
Copy link
Member

Choose a reason for hiding this comment

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

nice :)

@cortinico cortinico added this to the 2.0.0 milestone Apr 22, 2024
@BraisGabin BraisGabin merged commit 78fa964 into main Apr 26, 2024
20 of 21 checks passed
@BraisGabin BraisGabin deleted the stricter-paths branch April 26, 2024 07:47
@BraisGabin BraisGabin mentioned this pull request Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants