Skip to content

Commit 795fee0

Browse files
authored
Merge pull request #329 from HaxeCheckstyle/exclude-path-option
exclude path option
2 parents e708e4c + b2b4fe3 commit 795fee0

File tree

4 files changed

+52
-38
lines changed

4 files changed

+52
-38
lines changed

checkstyle.json

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -518,59 +518,60 @@
518518
}
519519
],
520520
"exclude": {
521+
"path": "relative",
521522
"all": [],
522523
"Dynamic": [
523-
"checkstyle.Main",
524-
"checkstyle.Checker",
525-
"checkstyle.ChecksInfo",
526-
"checkstyle.checks.Check",
527-
"checkstyle.checks.Directive",
528-
"checkstyle.checks.whitespace.SpacingCheck",
529-
"checkstyle.checks.imports.UnusedImportCheck",
524+
"checkstyle/Main",
525+
"checkstyle/Checker",
526+
"checkstyle/ChecksInfo",
527+
"checkstyle/checks/Check",
528+
"checkstyle/checks/Directive",
529+
"checkstyle/checks/whitespace/SpacingCheck",
530+
"checkstyle/checks/imports/UnusedImportCheck",
530531
"TestMain",
531-
"misc.ExtensionsTest",
532-
"token.TokenTreeBuilderParsingTest"
532+
"misc/ExtensionsTest",
533+
"token/TokenTreeBuilderParsingTest"
533534
],
534535
"MultipleStringLiterals": [
535536
"checks",
536537
"token"
537538
],
538539
"CyclomaticComplexity": [
539-
"checkstyle.checks.Check",
540-
"checkstyle.utils.ExprUtils",
541-
"checkstyle.utils.ComplexTypeUtils",
542-
"checkstyle.checks.metrics.CyclomaticComplexityCheck",
543-
"checkstyle.checks.block.LeftCurlyCheck",
544-
"checkstyle.checks.block.RightCurlyCheck",
545-
"checkstyle.checks.naming.MethodNameCheck",
546-
"checkstyle.checks.type.ReturnCheck",
547-
"checkstyle.checks.whitespace.OperatorWrapCheck",
548-
"checkstyle.checks.whitespace.WhitespaceAfterCheck",
549-
"checkstyle.checks.whitespace.WhitespaceAroundCheck",
550-
"checkstyle.checks.block.EmptyBlockCheck",
551-
"checkstyle.checks.whitespace.EmptyLinesCheck",
552-
"checkstyle.token.walk.WalkStatement"
540+
"checkstyle/checks/Check",
541+
"checkstyle/utils/ExprUtils",
542+
"checkstyle/utils/ComplexTypeUtils",
543+
"checkstyle/checks/metrics/CyclomaticComplexityCheck",
544+
"checkstyle/checks/block/LeftCurlyCheck",
545+
"checkstyle/checks/block/RightCurlyCheck",
546+
"checkstyle/checks/naming/MethodNameCheck",
547+
"checkstyle/checks/type/ReturnCheck",
548+
"checkstyle/checks/whitespace/OperatorWrapCheck",
549+
"checkstyle/checks/whitespace/WhitespaceAfterCheck",
550+
"checkstyle/checks/whitespace/WhitespaceAroundCheck",
551+
"checkstyle/checks/block/EmptyBlockCheck",
552+
"checkstyle/checks/whitespace/EmptyLinesCheck",
553+
"checkstyle/token/walk/WalkStatement"
553554
],
554555
"LeftCurly": [
555-
"checkstyle.checks.metrics.CyclomaticComplexityCheck"
556+
"checkstyle/checks/metrics/CyclomaticComplexityCheck"
556557
],
557558
"RightCurly": [
558-
"checkstyle.checks.metrics.CyclomaticComplexityCheck"
559+
"checkstyle/checks/metrics/CyclomaticComplexityCheck"
559560
],
560561
"MethodCount": [
561-
"checkstyle.token.TokenTreeBuilder"
562+
"checkstyle/token/TokenTreeBuilder"
562563
],
563564
"MethodLength": [
564-
"checkstyle.checks.whitespace.WhitespaceAfterCheck",
565-
"checkstyle.checks.whitespace.WhitespaceAroundCheck",
566-
"checkstyle.checks.whitespace.EmptyLinesCheck",
567-
"checkstyle.token.walk.WalkStatement"
565+
"checkstyle/checks/whitespace/WhitespaceAfterCheck",
566+
"checkstyle/checks/whitespace/WhitespaceAroundCheck",
567+
"checkstyle/checks/whitespace/EmptyLinesCheck",
568+
"checkstyle/token/walk/WalkStatement"
568569
],
569570
"NestedForDepth": [
570571
"TestMain"
571572
],
572573
"MemberName": [
573-
"checkstyle.Main"
574+
"checkstyle/Main"
574575
]
575576
}
576577
}

haxelib.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"contributors": [
1717
"adireddy"
1818
],
19-
"releasenote": "new PublicAccessorCheck and bug fixes",
20-
"version": "2.1.12",
19+
"releasenote": "added path option in exclude config",
20+
"version": "2.1.13",
2121
"url": "https://github.com/HaxeCheckstyle/haxe-checkstyle",
2222
"dependencies": {
2323

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "checkstyle",
3-
"version": "2.1.12",
3+
"version": "2.1.13",
44
"description": "Automated code analysis ideal for projects that want to enforce a coding standard.",
55
"repository": {
66
"type": "git",

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)