Skip to content

Commit 9fd0281

Browse files
authored
Merge pull request #330 from HaxeCheckstyle/exclude-path
enum for exclude path
2 parents 795fee0 + 8352e7e commit 9fd0281

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

checkstyle.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@
518518
}
519519
],
520520
"exclude": {
521-
"path": "relative",
522521
"all": [],
523522
"Dynamic": [
524523
"checkstyle/Main",

src/checkstyle/Main.hx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ 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";
3836

3937
var info:ChecksInfo;
4038
var checker:Checker;
@@ -146,7 +144,7 @@ class Main {
146144
function parseExcludes(config:ExcludeConfig) {
147145
var excludes = Reflect.fields(config);
148146
var pathType = Reflect.field(config, "path");
149-
if (pathType == null) pathType = PATH_TYPE_RELATIVE;
147+
if (pathType == null) pathType = RELATIVE_TO_SOURCE;
150148
for (exclude in excludes) {
151149
if (exclude == "path") continue;
152150
createExcludeMapElement(exclude);
@@ -160,8 +158,8 @@ class Main {
160158
if (excludesMap.get(exclude) == null) excludesMap.set(exclude, []);
161159
}
162160

163-
function updateExcludes(exclude:String, val:String, pathType:String) {
164-
if (pathType == PATH_TYPE_RELATIVE) {
161+
function updateExcludes(exclude:String, val:String, pathType:ExcludePath) {
162+
if (pathType == RELATIVE_TO_SOURCE) {
165163
for (p in paths) {
166164
//var basePath = ~/[\/\\]/.split(p)[0];
167165
var path = p + "/" + val.split(".").join("/");
@@ -425,4 +423,10 @@ typedef CodeclimateConfig = {
425423
@:optional var include_paths:Array<String>;
426424
@:optional var config:String;
427425
@:optional var exclude:String;
426+
}
427+
428+
@:enum
429+
abstract ExcludePath(String) {
430+
var RELATIVE_TO_PROJECT = "RELATIVE_TO_PROJECT";
431+
var RELATIVE_TO_SOURCE = "RELATIVE_TO_SOURCE";
428432
}

0 commit comments

Comments
 (0)