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

Introduce FilesCreateTempFileToFile Refaster rule #1162

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Stephan202
Copy link
Member

Suggested commit message:

Introduce `FilesCreateTempFileToFile` Refaster rule

Inspired by apache/maven-install-plugin#47, found through #1159.

@Stephan202 Stephan202 added this to the 0.17.0 milestone Apr 30, 2024
@Stephan202 Stephan202 force-pushed the sschroevers/create-temp-file-rules branch from 879ba3a to 25204a9 Compare April 30, 2024 04:28
@Stephan202 Stephan202 changed the title Introduce temporary file creation Refaster rules Introduce FilesCreateTempFileToFile Refaster rule Apr 30, 2024
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

1 similar comment
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

sonarcloud bot commented Apr 30, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarCloud


@AfterTemplate
File after(String prefix, String suffix) throws IOException {
return Files.createTempFile(prefix, suffix).toFile();
Copy link
Member Author

Choose a reason for hiding this comment

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

SonarCloud now compains about this line, while the [documentation](https://rules.sonarsource.com/java/type/Security Hotspot/RSPEC-5443) literally says:

File f = Files.createTempFile("prefix", "suffix").toFile();  // Compliant

I suppose this is something to be reported upstream (either it's incorrect, or unclear).

Copy link
Contributor

@mohamedsamehsalah mohamedsamehsalah left a comment

Choose a reason for hiding this comment

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

Clean 🚀


/**
* Prefer {@link Files#createTempFile(String, String, FileAttribute[])} over alternatives that
* create files will more liberal permissions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* create files will more liberal permissions.
* create files with more liberal permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants