Skip to content

Commit 063a637

Browse files
pypmannetjiesAlexHaxe
authored andcommitted
Fixes for #349 (#350)
* Fixes for #349 Changed the excludes to use the string as a regular expression except in the case where a "path" option is provided. Where a path is provided, it should work as before. Removed the appended class name because the simpler provided path will still match paths checked against it. * Fixed some compilation errors * Fixed pull request issues * Added the path option to excludes in order to let excludes work as they did before.
1 parent aa81ca1 commit 063a637

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

checkstyle.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@
518518
}
519519
],
520520
"exclude": {
521+
"path": "RELATIVE_TO_SOURCE",
521522
"all": [],
522523
"Dynamic": [
523524
"checkstyle/Main",

src/checkstyle/Checker.hx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ class Checker {
279279
var slashes:EReg = ~/[\/\\]/g;
280280
cls = slashes.replace(cls, ":");
281281
for (exclude in excludesForCheck) {
282-
var regStr:String = slashes.replace(exclude, ":") + ":.*?" + cls.substring(cls.lastIndexOf(":") + 1, cls.length) + "$";
283-
var r = new EReg(regStr, "i");
282+
var r = new EReg(exclude, "i");
284283
if (r.match(cls)) return true;
285284
}
286285
return false;

src/checkstyle/Main.hx

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ class Main {
144144
function parseExcludes(config:ExcludeConfig) {
145145
var excludes = Reflect.fields(config);
146146
var pathType = Reflect.field(config, "path");
147-
if (pathType == null) pathType = RELATIVE_TO_SOURCE;
148147
for (exclude in excludes) {
149148
if (exclude == "path") continue;
150149
createExcludeMapElement(exclude);
@@ -159,21 +158,38 @@ class Main {
159158
}
160159

161160
function updateExcludes(exclude:String, val:String, pathType:ExcludePath) {
162-
if (pathType == RELATIVE_TO_SOURCE) {
163-
for (p in paths) {
164-
//var basePath = ~/[\/\\]/.split(p)[0];
165-
var path = p + "/" + val.split(".").join("/");
166-
if (exclude == "all") allExcludes.push(path);
167-
else excludesMap.get(exclude).push(path);
168-
}
161+
if (pathType == null) {
162+
addToExclude(exclude, val);
169163
}
170164
else {
171-
var path = val.split(".").join("/");
172-
if (exclude == "all") allExcludes.push(path);
173-
else excludesMap.get(exclude).push(path);
165+
if (pathType == RELATIVE_TO_SOURCE) {
166+
for (path in paths) {
167+
addNormalisedPathToExclude(exclude, path + ":" + val);
168+
}
169+
}
170+
else {
171+
addNormalisedPathToExclude(exclude, val);
172+
}
174173
}
175174
}
176175

176+
function addNormalisedPathToExclude(exclude:String, path:String) {
177+
var path = normalisePath(path);
178+
addToExclude(exclude, path);
179+
}
180+
181+
function normalisePath(path:String):String {
182+
var slashes:EReg = ~/[\/\\]/g;
183+
path = path.split(".").join(":");
184+
path = slashes.replace(path, ":");
185+
return path;
186+
}
187+
188+
function addToExclude(exclude:String, value:String) {
189+
if (exclude == "all") allExcludes.push(value);
190+
else excludesMap.get(exclude).push(value);
191+
}
192+
177193
function createCheck(checkConf:CheckConfig):Check {
178194
var check:Check = info.build(checkConf.type);
179195
if (check == null) {

0 commit comments

Comments
 (0)