Skip to content

Commit 60bd33a

Browse files
committed
added path option to exclude
1 parent 33107e8 commit 60bd33a

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/checkstyle/Main.hx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class Main {
3333
static var CODE_CLIMATE_REPORTER:String = "codeclimate";
3434
static var SHOW_MISSING_CHECKS:Bool = false;
3535
static var exitCode:Int;
36+
static var PATH_TYPE_RELATIVE:String = "relative";
37+
static var PATH_TYPE_ABSOLUTE:String = "absolute";
3638

3739
var info:ChecksInfo;
3840
var checker:Checker;
@@ -143,21 +145,32 @@ class Main {
143145

144146
function parseExcludes(config:ExcludeConfig) {
145147
var excludes = Reflect.fields(config);
148+
var pathType = Reflect.field(config, "path");
149+
if (pathType == null) pathType = PATH_TYPE_RELATIVE;
146150
for (exclude in excludes) {
151+
if (exclude == "path") continue;
147152
createExcludeMapElement(exclude);
148153
var excludeValues:Array<String> = Reflect.field(config, exclude);
149154
if (excludeValues == null || excludeValues.length == 0) continue;
150-
for (val in excludeValues) updateExcludes(exclude, val);
155+
for (val in excludeValues) updateExcludes(exclude, val, pathType);
151156
}
152157
}
153158

154159
function createExcludeMapElement(exclude:String) {
155160
if (excludesMap.get(exclude) == null) excludesMap.set(exclude, []);
156161
}
157162

158-
function updateExcludes(exclude:String, val:String) {
159-
for (p in paths) {
160-
var path = p + "/" + val.split(".").join("/");
163+
function updateExcludes(exclude:String, val:String, pathType:String) {
164+
if (pathType == PATH_TYPE_RELATIVE) {
165+
for (p in paths) {
166+
//var basePath = ~/[\/\\]/.split(p)[0];
167+
var path = p + "/" + val.split(".").join("/");
168+
if (exclude == "all") allExcludes.push(path);
169+
else excludesMap.get(exclude).push(path);
170+
}
171+
}
172+
else {
173+
var path = val.split(".").join("/");
161174
if (exclude == "all") allExcludes.push(path);
162175
else excludesMap.get(exclude).push(path);
163176
}

0 commit comments

Comments
 (0)