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

Ensure filesystems are created so paths can be gotten #2504

Merged
merged 1 commit into from
Mar 24, 2020

Conversation

josephlbarnett
Copy link
Contributor

When getting resources from the classpath, the ZipFileSystem
needs to be initialized manually.

Fixes #2503

@@ -78,5 +79,10 @@ fun CliArgs.extractUris(): Collection<URI> {
val pathUris = config?.let { MultipleExistingPathConverter().convert(it).map(Path::toUri) } ?: emptyList()
val resourceUris = configResource?.let { MultipleClasspathResourceConverter().convert(it).map(URL::toURI) }
?: emptyList()
resourceUris.forEach {
runCatching {
FileSystems.newFileSystem(it, emptyMap<String, Any>())
Copy link
Member

@arturbosch arturbosch Mar 24, 2020

Choose a reason for hiding this comment

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

Thanks for analyzing this issue!

I would prefer the second answer on stackoverflow

private FileSystem initFileSystem(URI uri) throws IOException
{
    try
    {
        return FileSystems.getFileSystem(uri);
    }
    catch( FileSystemNotFoundException e )
    {
        Map<String, String> env = new HashMap<>();
        env.put("create", "true");
        return FileSystems.newFileSystem(uri, env);
    }
}

Your code could be refactored to resourceUris.forEach(checkFileSystem).
The create=true part sounds to be important.

@josephlbarnett josephlbarnett force-pushed the filesystem-creation branch 2 times, most recently from 12ae0ad to 5637d6f Compare March 24, 2020 17:54
Copy link
Member

@schalkms schalkms left a comment

Choose a reason for hiding this comment

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

Thanks for helping us out and submitting the fix! 🙂

When getting resources from the classpath, the ZipFileSystem
needs to be initialized manually.

Fixes detekt#2503
@codecov-io
Copy link

codecov-io commented Mar 24, 2020

Codecov Report

Merging #2504 into master will decrease coverage by 0.02%.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2504      +/-   ##
============================================
- Coverage     80.07%   80.04%   -0.03%     
  Complexity     2257     2257              
============================================
  Files           378      378              
  Lines          6635     6641       +6     
  Branches       1180     1180              
============================================
+ Hits           5313     5316       +3     
- Misses          740      743       +3     
  Partials        582      582
Impacted Files Coverage Δ Complexity Δ
.../io/gitlab/arturbosch/detekt/cli/Configurations.kt 74.41% <50%> (-3.96%) 0 <0> (ø)

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 2c929e1...4f55636. Read the comment docs.

@schalkms
Copy link
Member

schalkms commented Mar 24, 2020

added this to the 1.8.0 milestone 1 hour ago

@arturbosch this should be included in v1.7.1 in my opinion.

@arturbosch arturbosch merged commit d1a4c60 into detekt:master Mar 24, 2020
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.

FileSystemNotFoundException in detekt 1.7.0 when using --config-resource
4 participants