Skip to content

Commit bc792d5

Browse files
authored
Merge pull request #56 from firewave/vfile
fixed some issues with potentially non-existent files
2 parents 4b97ac0 + e98a363 commit bc792d5

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ Deployment.
5757

5858
### 1.6.0 - XXXX-XX-XX
5959

60-
Parse `--xml` output instead of text output. (Contribution by @firewave)
60+
- Parse `--xml` output instead of text output. (Contribution by @firewave)
61+
- Fixed scanning of files with whitespaces in name. (Contribution by @firewave)
62+
- Only scan files which actually exist. (Contribution by @firewave)
63+
- Use unique file names for temporary files used for analysis. (Contribution by @firewave)
6164

6265
### 1.5.1 - 2020-11-12
6366

resources/META-INF/plugin.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
]]></description>
6262

6363
<change-notes><![CDATA[
64-
Parse --xml output instead of text output. (Contribution by @firewave)<br/>
64+
- Parse --xml output instead of text output. (Contribution by @firewave)<br/>
65+
- Fixed scanning of files with whitespaces in name. (Contribution by @firewave)
66+
- Only scan files which actually exist. (Contribution by @firewave)
67+
- Use unique file names for temporary files used for analysis. (Contribution by @firewave)
6568
]]>
6669
</change-notes>
6770

src/com/github/johnthagen/cppcheck/CppCheckInspectionImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public static String executeCommandOnFile(@NotNull final String command,
182182
final GeneralCommandLine cmd = new GeneralCommandLine()
183183
.withExePath(command)
184184
.withParameters(ParametersListUtil.parse(options))
185-
.withParameters(ParametersListUtil.parse(filePath));
185+
.withParameters(ParametersListUtil.parse("\"" + filePath + "\""));
186186

187187
// Need to be able to get python from the system env
188188
if (cppcheckMisraPath != null && !cppcheckMisraPath.isEmpty()) {

src/com/github/johnthagen/cppcheck/CppcheckInspection.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.intellij.openapi.vfs.VirtualFile;
1414
import com.intellij.openapi.wm.StatusBar;
1515
import com.intellij.psi.PsiFile;
16+
import org.apache.commons.lang3.RandomStringUtils;
1617
import org.jetbrains.annotations.NotNull;
1718
import org.jetbrains.annotations.Nullable;
1819
import org.xml.sax.SAXException;
@@ -29,7 +30,7 @@ public ProblemDescriptor[] checkFile(@NotNull PsiFile file,
2930
@NotNull InspectionManager manager,
3031
boolean isOnTheFly) {
3132
final VirtualFile vFile = file.getVirtualFile();
32-
if (vFile == null || !isCFamilyFile(vFile)) {
33+
if (vFile == null || !vFile.isInLocalFileSystem() || !isCFamilyFile(vFile)) {
3334
return ProblemDescriptor.EMPTY_ARRAY;
3435
}
3536

@@ -55,7 +56,7 @@ public ProblemDescriptor[] checkFile(@NotNull PsiFile file,
5556

5657
File tempFile = null;
5758
try {
58-
tempFile = FileUtil.createTempFile("", vFile.getName(), true);
59+
tempFile = FileUtil.createTempFile(RandomStringUtils.randomAlphanumeric(8) + "_", vFile.getName(), true);
5960
FileUtil.writeToFile(tempFile, document.getText());
6061
final String cppcheckOutput =
6162
CppCheckInspectionImpl.executeCommandOnFile(cppcheckPath, prependIncludeDir(cppcheckOptions, vFile),

0 commit comments

Comments
 (0)