Skip to content
This repository was archived by the owner on Aug 9, 2025. It is now read-only.

Commit 072abeb

Browse files
committed
Bugfix, fix for #16 (missing "\" between concatenated paths) - for real this time
1 parent 7103af9 commit 072abeb

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

CPPCheckPlugin/AnalyzerCppcheck.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ public override void analyze(List<SourceFile> filesToAnalyze, OutputWindowPane o
5555
{
5656
if (!path.ToLower().Contains("qt"))
5757
{
58-
String includeArgument = @" -I""" + (path.EndsWith("\\") ? path : path+@"\\") + @"""";
58+
String includeArgument = " -I\"" + path + "\"";
5959
cppheckargs = cppheckargs + " " + includeArgument;
6060
}
6161
}
6262

6363
foreach (SourceFile file in filesToAnalyze)
6464
{
65-
cppheckargs += @" """ + file.FilePath + @"""";
65+
cppheckargs += " \"" + file.FilePath + "\"";
6666
}
6767

6868
if (filesToAnalyze.Count > 1) // For single file only checking current configuration (for speed)
@@ -134,8 +134,6 @@ protected override HashSet<string> readSuppressions(string projectBasePath)
134134
if (currentGroup == "cppcheck")
135135
{
136136
var components = line.Split(':');
137-
// if (components.Length >= 2 && components[1] == "*") // id and "*" for a file specified
138-
// components[1] = @"""" + projectBasePath + @"*"""; // adding path to this specific project
139137
if (components.Length >= 2 && !components[1].StartsWith("*")) // id and some path without "*"
140138
components[1] = "*" + components[1]; // adding * in front
141139

CPPCheckPlugin/CPPCheckPluginPackage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,13 @@ private void checkCurrentProject()
124124
}
125125
foreach (dynamic file in project.Files)
126126
{
127-
// Only checking cpp files (performance)
128127
Type fileObjectType = file.GetType();
129128
// Automatic property binding fails with VS2013 for some unknown reason, using Reflection directly instead.
130129
var vcFileInterface = fileObjectType.GetInterface("Microsoft.VisualStudio.VCProjectEngine.VCFile");
131130
var fileType = vcFileInterface.GetProperty("FileType").GetValue(file);
132131
Type fileTypeEnumType = fileType.GetType();
133132
var fileTypeEnumConstant = Enum.GetName(fileTypeEnumType, fileType);
134-
if (fileTypeEnumConstant == "eFileTypeCppCode")
133+
if (fileTypeEnumConstant == "eFileTypeCppCode") // Only checking cpp files (performance)
135134
{
136135
String fileName = file.Name;
137136
// Ignoring Qt MOC and UI files

CPPCheckPlugin/SourceFile.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System;
33
using System.Diagnostics;
4+
using System.IO;
45

56
namespace VSPackage.CPPCheckPlugin
67
{
@@ -15,8 +16,11 @@ public SourceFile(string fullPath, string projectBasePath)
1516
// All include paths being added are resolved against projectBasePath
1617
public void addIncludePath(string path)
1718
{
18-
if (!String.IsNullOrEmpty(_projectBasePath))
19-
_includePaths.Add(cleanPath(path.Contains(":") ? path : (_projectBasePath + path)));
19+
if (!String.IsNullOrEmpty(_projectBasePath) && !String.IsNullOrEmpty(path))
20+
{
21+
Debug.WriteLine("Processing path: " + path);
22+
_includePaths.Add(cleanPath(path.Contains(":") ? path : Path.Combine(_projectBasePath, path)));
23+
}
2024
}
2125

2226
public void addIncludePaths(List<string> paths)

0 commit comments

Comments
 (0)