From 8c4326ba1b2d45b7f99bd35b7c7b6ce4cc19e48e Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Sun, 22 Apr 2018 15:02:04 +0200 Subject: [PATCH] fix wrap indentation (#388) * fix wrap indentation * refactored NO -> NONE * fixed checkstyle issues in unittests --- CHANGES.md | 2 +- .../coding/SimplifyBooleanExpressionCheck.hx | 4 +- .../metrics/CyclomaticComplexityCheck.hx | 8 +- .../checks/whitespace/IndentationCheck.hx | 42 +++- test/TestMain.hx | 2 +- test/checks/block/EmptyBlockCheckTest.hx | 16 +- test/checks/coding/NestedForDepthCheckTest.hx | 4 +- test/checks/coding/NestedIfDepthCheckTest.hx | 4 +- test/checks/coding/NestedTryDepthCheckTest.hx | 4 +- .../coding/VariableInitialisationCheckTest.hx | 10 +- test/checks/literal/ERegLiteralCheckTest.hx | 12 +- .../literal/HexadecimalLiteralCheckTest.hx | 8 +- .../checks/modifier/ModifierOrderCheckTest.hx | 28 +-- .../naming/CatchParameterNameCheckTest.hx | 4 +- test/checks/naming/ConstantNameCheckTest.hx | 8 +- .../naming/LocalVariableNameCheckTest.hx | 8 +- test/checks/naming/MemberNameCheckTest.hx | 20 +- test/checks/naming/MethodNameCheckTest.hx | 8 +- test/checks/naming/ParameterNameCheckTest.hx | 12 +- test/checks/naming/TypeNameCheckTest.hx | 12 +- test/checks/size/LineLengthCheckTest.hx | 8 +- test/checks/size/MethodLengthCheckTest.hx | 8 +- test/checks/size/ParameterNumberCheckTest.hx | 16 +- test/checks/type/AnonymousCheckTest.hx | 4 +- test/checks/type/DynamicCheckTest.hx | 16 +- test/checks/type/ReturnCheckTest.hx | 44 ++-- test/checks/type/TypeCheckTest.hx | 8 +- test/checks/whitespace/EmptyLinesCheckTest.hx | 60 +++--- .../IndentationCharacterCheckTest.hx | 24 +-- .../checks/whitespace/IndentationCheckTest.hx | 37 +++- test/checks/whitespace/SpacingCheckTest.hx | 44 ++-- .../whitespace/TabForAligningCheckTest.hx | 4 +- test/token/TokenTreeBuilderTest.hx | 202 +++++++++--------- 33 files changed, 374 insertions(+), 317 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1f3d10eb..221e1651 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,9 @@ ## next version (2.2.1) + - New check IndentationCheck [#387](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/387) - Added CHANGES.md - Added a reset function for checks ([#279](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/279)) - Added unittest for [#78](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/78) - - Added IndentationCheck [#387](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/387) - Updated formula for number of pre-parsed files [#386](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/386) - Removed conditional section for unittest [#181](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/181) diff --git a/src/checkstyle/checks/coding/SimplifyBooleanExpressionCheck.hx b/src/checkstyle/checks/coding/SimplifyBooleanExpressionCheck.hx index 4ce414e2..599ad0ee 100644 --- a/src/checkstyle/checks/coding/SimplifyBooleanExpressionCheck.hx +++ b/src/checkstyle/checks/coding/SimplifyBooleanExpressionCheck.hx @@ -33,8 +33,8 @@ class SimplifyBooleanExpressionCheck extends Check { function checkToken(token:TokenTree) { var parent = token.parent; if (parent.is(Binop(OpEq)) || parent.is(Binop(OpNotEq)) || parent.is(Unop(OpNot)) || - parent.is(Binop(OpOr)) || parent.is(Binop(OpAnd)) || parent.is(Binop(OpBoolOr)) || - parent.is(Binop(OpBoolAnd))) { + parent.is(Binop(OpOr)) || parent.is(Binop(OpAnd)) || parent.is(Binop(OpBoolOr)) || + parent.is(Binop(OpBoolAnd))) { logPos("Boolean expression can be simplified", token.pos); } } diff --git a/src/checkstyle/checks/metrics/CyclomaticComplexityCheck.hx b/src/checkstyle/checks/metrics/CyclomaticComplexityCheck.hx index 5998ac67..a2205590 100644 --- a/src/checkstyle/checks/metrics/CyclomaticComplexityCheck.hx +++ b/src/checkstyle/checks/metrics/CyclomaticComplexityCheck.hx @@ -49,10 +49,10 @@ class CyclomaticComplexityCheck extends Check { return switch (e.expr) { case ExprDef.EArray(e1, e2) : evaluateExpr(e1) + evaluateExpr(e2); case ExprDef.EBinop(op, e1, e2) : evaluateExpr(e1) + evaluateExpr(e2) + switch (op) { - case haxe.macro.Expr.Binop.OpBoolAnd : 1; - case haxe.macro.Expr.Binop.OpBoolOr : 1; - default : 0; - }; + case haxe.macro.Expr.Binop.OpBoolAnd : 1; + case haxe.macro.Expr.Binop.OpBoolOr : 1; + default : 0; + }; case ExprDef.EParenthesis(e) : evaluateExpr(e); case ExprDef.EObjectDecl(fields) : fields.map(function(f):Expr { diff --git a/src/checkstyle/checks/whitespace/IndentationCheck.hx b/src/checkstyle/checks/whitespace/IndentationCheck.hx index f73f0009..7ddca2b7 100644 --- a/src/checkstyle/checks/whitespace/IndentationCheck.hx +++ b/src/checkstyle/checks/whitespace/IndentationCheck.hx @@ -23,6 +23,8 @@ class IndentationCheck extends Check { var wrappedStatements:Array = calcWrapStatements(); var tolerateViolations:Array = calcIgnoreLineIndentation(); + correctWrappedIndentation(lineIndentation, wrappedStatements); + var splitChar:String = character; if (splitChar == "tab") splitChar = "\t"; for (i in 0...checker.lines.length) { @@ -48,6 +50,7 @@ class IndentationCheck extends Check { if (tolerate) return; if (wrapped) { switch (wrapPolicy) { + case NONE: case EXACT: case LARGER: if (actual >= expected) return; @@ -56,6 +59,35 @@ class IndentationCheck extends Check { log('Indentation mismatch: expected: $expected, actual: $actual', line + 1, 0); } + function correctWrappedIndentation(lineIndentation:Array, wrappedStatements:Array) { + if (wrapPolicy == NONE) return; + var currentIndent:Int = 0; + for (i in 0...lineIndentation.length) { + if (!wrappedStatements[i]) { + currentIndent = lineIndentation[i]; + continue; + } + if (currentIndent < lineIndentation[i]) { + currentIndent = -1; + continue; + } + if (currentIndent == lineIndentation[i]) { + lineIndentation[i]++; + } + } + var currentIndent:Int = 0; + for (i in 0...lineIndentation.length) { + var newIndent = lineIndentation[i]; + if (newIndent == currentIndent) continue; + if (newIndent > currentIndent) { + currentIndent++; + lineIndentation[i] = currentIndent; + continue; + } + currentIndent = newIndent; + } + } + function calcLineIndentation():Array { var lineIndentation:Array = [for (i in 0...checker.lines.length) 0]; @@ -65,7 +97,10 @@ class IndentationCheck extends Check { switch (token.tok) { case BkOpen: var child:TokenTree = token.getFirstChild(); - if (child.is(BrOpen)) continue; + if (child.is(BrOpen)) { + // only indent once, if directly next to each other `[{` + if (token.pos.min + 1 == child.pos.min) continue; + } increaseBlockIndent(token, lineIndentation); case BrOpen: increaseBlockIndent(token, lineIndentation); @@ -111,6 +146,8 @@ class IndentationCheck extends Check { var tokenList:Array = checker.getTokenTree().filter(searchFor, ALL); for (token in tokenList) { var pos = token.getPos(); + var child:TokenTree = token.getFirstChild(); + if (child.is(BkOpen)) continue; ignoreRange(pos, wrapped); } return wrapped; @@ -130,7 +167,7 @@ class IndentationCheck extends Check { }); for (token in tokenList) { switch (token.tok) { - case POpen, Const(CString(_)): + case Const(CString(_)): ignoreRange(token.getPos(), ignoreIndentation); case Comment(_): if (ignoreComments) ignoreRange(token.getPos(), ignoreIndentation, false); @@ -179,6 +216,7 @@ class IndentationCheck extends Check { @:enum abstract WrappedIndentationPolicy(String) { + var NONE = "none"; var EXACT = "exact"; var LARGER = "larger"; } \ No newline at end of file diff --git a/test/TestMain.hx b/test/TestMain.hx index 57f0c64d..5c9edb8f 100644 --- a/test/TestMain.hx +++ b/test/TestMain.hx @@ -51,7 +51,7 @@ class TestMain { var missingStatements:Array = cls.getMissingStatements(); for (stmt in missingStatements) { - for (line in stmt.lines) coverageData[line] = 0; + for (line in stmt.lines) coverageData[line + 1] = 0; } var missingBranches:Array = cls.getMissingBranches(); for (branch in missingBranches) { diff --git a/test/checks/block/EmptyBlockCheckTest.hx b/test/checks/block/EmptyBlockCheckTest.hx index 3a120dba..112f6a9d 100644 --- a/test/checks/block/EmptyBlockCheckTest.hx +++ b/test/checks/block/EmptyBlockCheckTest.hx @@ -102,28 +102,28 @@ abstract EmptyBlockCheckTests(String) to String { } }"; - var BLOCK_WITH_STATEMENT = - "class Test { + var BLOCK_WITH_STATEMENT = " + class Test { public function new() { var a:Int; } }"; - var BLOCK_WITH_STATEMENT2 = - "class Test { + var BLOCK_WITH_STATEMENT2 = " + class Test { public function new() { var a:Int; } }"; - var BLOCK_WITH_COMMENT = - "class Test { + var BLOCK_WITH_COMMENT = " + class Test { public function new() { // comment } }"; - var EMPTY_OBJECT_DECL = - "class Test { + var EMPTY_OBJECT_DECL = " + class Test { public function new() { var a = {}; } diff --git a/test/checks/coding/NestedForDepthCheckTest.hx b/test/checks/coding/NestedForDepthCheckTest.hx index 65e02c2e..b7958cf6 100644 --- a/test/checks/coding/NestedForDepthCheckTest.hx +++ b/test/checks/coding/NestedForDepthCheckTest.hx @@ -70,8 +70,8 @@ abstract NestedForDepthCheckTests(String) to String { } }"; - var TEST2 = - "abstractAndClass Test { + var TEST2 = " + abstractAndClass Test { public function test1(param:Array) { for (outerParam in params) { // level 0 for (middleParam in params) { // level 1 diff --git a/test/checks/coding/NestedIfDepthCheckTest.hx b/test/checks/coding/NestedIfDepthCheckTest.hx index 2bb688ec..8fc581d2 100644 --- a/test/checks/coding/NestedIfDepthCheckTest.hx +++ b/test/checks/coding/NestedIfDepthCheckTest.hx @@ -59,8 +59,8 @@ abstract NestedIfDepthCheckTests(String) to String { } }"; - var TEST2 = - "abstractAndClass Test { + var TEST2 = " + abstractAndClass Test { public function test1(param:Int) { if (param == 1) { // level 0 return 1; diff --git a/test/checks/coding/NestedTryDepthCheckTest.hx b/test/checks/coding/NestedTryDepthCheckTest.hx index c89745fb..6c804656 100644 --- a/test/checks/coding/NestedTryDepthCheckTest.hx +++ b/test/checks/coding/NestedTryDepthCheckTest.hx @@ -65,8 +65,8 @@ abstract NestedTryDepthCheckTests(String) to String { } }"; - var TEST2 = - "abstractAndClass Test { + var TEST2 = " + abstractAndClass Test { public function test1() { try { // level 0 try { // level 0 diff --git a/test/checks/coding/VariableInitialisationCheckTest.hx b/test/checks/coding/VariableInitialisationCheckTest.hx index 0c3c97b6..9f7800a0 100644 --- a/test/checks/coding/VariableInitialisationCheckTest.hx +++ b/test/checks/coding/VariableInitialisationCheckTest.hx @@ -7,7 +7,7 @@ class VariableInitialisationCheckTest extends CheckTestCase Dynamic;"; + var TEST6 = " + typedef Test = String -> Dynamic;"; - var ISSUE_43 = - "class Test { + var ISSUE_43 = " + class Test { function test() { cast (Type.createInstance(Array, [])); } diff --git a/test/checks/type/ReturnCheckTest.hx b/test/checks/type/ReturnCheckTest.hx index 77895910..7458678d 100644 --- a/test/checks/type/ReturnCheckTest.hx +++ b/test/checks/type/ReturnCheckTest.hx @@ -117,8 +117,8 @@ abstract ReturnCheckTests(String) to String { public function test():Void {} }"; - var TEST2 = - "abstractAndClass Test { + var TEST2 = " + abstractAndClass Test { public function test1() { if (true) { return 0; @@ -126,8 +126,8 @@ abstract ReturnCheckTests(String) to String { } }"; - var TEST2A = - "abstractAndClass Test { + var TEST2A = " + abstractAndClass Test { public function test1() { switch (true) { case true: @@ -136,8 +136,8 @@ abstract ReturnCheckTests(String) to String { } }"; - var TEST2B = - "abstractAndClass Test { + var TEST2B = " + abstractAndClass Test { public function test1() { try { return 0; @@ -148,23 +148,23 @@ abstract ReturnCheckTests(String) to String { } }"; - var TEST3 = - "abstractAndClass Test { + var TEST3 = " + abstractAndClass Test { public function test2() { var x = 1; return; } }"; - var TEST4 = - "abstractAndClass Test { + var TEST4 = " + abstractAndClass Test { public function test3():Void { return; } }"; - var TEST5 = - "abstractAndClass Test { + var TEST5 = " + abstractAndClass Test { public function test4() { var x = function(i){ return i * i; @@ -178,8 +178,8 @@ abstract ReturnCheckTests(String) to String { function test4():Void; }"; - var TEST_FOR = - "abstractAndClass Test { + var TEST_FOR = " + abstractAndClass Test { public function test1() { for (i in 0 ... 10) { return 5; @@ -187,8 +187,8 @@ abstract ReturnCheckTests(String) to String { } }"; - var TEST_WHILE = - "abstractAndClass Test { + var TEST_WHILE = " + abstractAndClass Test { public function test1() { while (true) { return 5; @@ -196,13 +196,13 @@ abstract ReturnCheckTests(String) to String { } }"; - var INTERFACE = - "interface Test { + var INTERFACE = " + interface Test { public function test1(); }"; - var CORRECT_RETURN_ANONYMOUS = - "abstractAndClass Test { + var CORRECT_RETURN_ANONYMOUS = " + abstractAndClass Test { public function test7() { var x = function(i):Int{ return i * i; @@ -211,8 +211,8 @@ abstract ReturnCheckTests(String) to String { } }"; - var CORRECT_RETURN = - "abstractAndClass Test { + var CORRECT_RETURN = " + abstractAndClass Test { public function test1():Int { return 5; } diff --git a/test/checks/type/TypeCheckTest.hx b/test/checks/type/TypeCheckTest.hx index b6740d0a..770d85f4 100644 --- a/test/checks/type/TypeCheckTest.hx +++ b/test/checks/type/TypeCheckTest.hx @@ -40,14 +40,14 @@ abstract TypeCheckTests(String) to String { static inline var A = 1; }"; - var TEST3 = - "@:enum + var TEST3 = " + @:enum abstract Test(Int) { var VALUE = 0; }"; - var TEST4 = - "@:enum + var TEST4 = " + @:enum abstract Test(Int) { static inline var VALUE = 0; }"; diff --git a/test/checks/whitespace/EmptyLinesCheckTest.hx b/test/checks/whitespace/EmptyLinesCheckTest.hx index e14a078d..4e9be696 100644 --- a/test/checks/whitespace/EmptyLinesCheckTest.hx +++ b/test/checks/whitespace/EmptyLinesCheckTest.hx @@ -90,8 +90,8 @@ abstract EmptyLinesCheckTests(String) to String { }"; - var TEST2 = - "class Test { + var TEST2 = " + class Test { public function new() { @@ -124,8 +124,8 @@ abstract EmptyLinesCheckTests(String) to String { } }"; - var TEST3 = - "class Test { + var TEST3 = " + class Test { public function new() { @@ -135,8 +135,8 @@ abstract EmptyLinesCheckTests(String) to String { } }"; - var TEST4 = - "class Test { + var TEST4 = " + class Test { // comments (with text before) @@ -145,16 +145,16 @@ abstract EmptyLinesCheckTests(String) to String { } }"; - var TEST5 = - "class Test { + var TEST5 = " + class Test { // comments (with no text before) var a:Int; }"; - var TEST6 = - "class Test { + var TEST6 = " + class Test { /** *comments @@ -163,8 +163,8 @@ abstract EmptyLinesCheckTests(String) to String { var a:Int; }"; - var TEST7 = - "class Test { + var TEST7 = " + class Test { /** *comments @@ -188,23 +188,23 @@ abstract EmptyLinesCheckTests(String) to String { class Test {}"; - var TEST10 = - "class Test { + var TEST10 = " + class Test { public function new() { var b:Int; } }"; - var TEST11 = - "class Test { + var TEST11 = " + class Test { public function new() { var b:Int; } }"; - var TEST12 = - "class Test + var TEST12 = " + class Test { public function new() { @@ -212,39 +212,39 @@ abstract EmptyLinesCheckTests(String) to String { } }"; - var TEST13 = - "interface Test { + var TEST13 = " + interface Test { var b:Int; }"; - var TEST14 = - "interface Test { + var TEST14 = " + interface Test { function test():Void; }"; - var TEST15 = - "interface Test + var TEST15 = " + interface Test { function test():Void; }"; - var TEST16 = - "abstract Test(Int) { + var TEST16 = " + abstract Test(Int) { var A = 10; }"; - var TEST17 = - "abstract Test(Int) { + var TEST17 = " + abstract Test(Int) { var A = 10; }"; - var TEST18 = - "abstract Test(Int) + var TEST18 = " + abstract Test(Int) { var A = 10; }"; diff --git a/test/checks/whitespace/IndentationCharacterCheckTest.hx b/test/checks/whitespace/IndentationCharacterCheckTest.hx index 599c3bf4..2dfc3da4 100644 --- a/test/checks/whitespace/IndentationCharacterCheckTest.hx +++ b/test/checks/whitespace/IndentationCharacterCheckTest.hx @@ -59,19 +59,19 @@ abstract IndentationCharacterCheckTests(String) to String { public function new() {} }"; - var TEST2 = - "class Test { + var TEST2 = " + class Test { var a:Int; public function new() {} }"; - var TEST3 = - "class Test { + var TEST3 = " + class Test { public function new() {} }"; - var TEST4 = - "class Test { + var TEST4 = " + class Test { public function new() { if (actionType == 'STREET' || (actionType == 'BASKET' && ( actionNumber == 2 || actionNumber == 4) )) { @@ -80,22 +80,22 @@ abstract IndentationCharacterCheckTests(String) to String { } }"; - var TEST5_1 = - "class Test { + var TEST5_1 = " + class Test { public function new() { // breaking comment with quote ' } }"; - var TEST5_2 = - "class Test { + var TEST5_2 = " + class Test { public function new() { // bad indentation here } }"; - var TEST6 = - "class Test { + var TEST6 = " + class Test { public function new() { // breaking comment with quote ' // bad indentation here diff --git a/test/checks/whitespace/IndentationCheckTest.hx b/test/checks/whitespace/IndentationCheckTest.hx index 14fed766..e0e7b4c1 100644 --- a/test/checks/whitespace/IndentationCheckTest.hx +++ b/test/checks/whitespace/IndentationCheckTest.hx @@ -10,7 +10,6 @@ class IndentationCheckTest extends CheckTestCase { var check = new IndentationCheck(); check.severity = SeverityLevel.INFO; assertNoMsg(check, CORRECT_TAB_INDENT); - assertNoMsg(check, WRAPPED_PARAMS); assertMsg(check, CORRECT_SPACE_INDENT, "Indentation mismatch: expected: 1, actual: 0"); } @@ -47,13 +46,19 @@ class IndentationCheckTest extends CheckTestCase { public function testWrap() { var check = new IndentationCheck(); check.severity = SeverityLevel.INFO; - assertNoMsg(check, WRAPPED_PARAMS); + assertNoMsg(check, LARGER_WRAPPED_PARAMS); + assertNoMsg(check, EXACT_WRAPPED_PARAMS); assertNoMsg(check, WRAPPED_STRING); - assertMsg(check, WRONG_WRAPPED_PARAMS, "Indentation mismatch: expected: 2, actual: 1"); - check.wrapPolicy = LARGER; - assertNoMsg(check, WRAPPED_PARAMS); + assertMsg(check, NONE_WRAPPED_PARAMS, "Indentation mismatch: expected: 2, actual: 1"); + check.wrapPolicy = EXACT; assertNoMsg(check, WRAPPED_STRING); - assertMsg(check, WRONG_WRAPPED_PARAMS, "Indentation mismatch: expected: 2, actual: 1"); + assertMsg(check, LARGER_WRAPPED_PARAMS, "Indentation mismatch: expected: 2, actual: 6"); + assertMsg(check, NONE_WRAPPED_PARAMS, "Indentation mismatch: expected: 2, actual: 1"); + + check.wrapPolicy = NONE; + assertNoMsg(check, NONE_WRAPPED_PARAMS); + assertMsg(check, LARGER_WRAPPED_PARAMS, "Indentation mismatch: expected: 1, actual: 6"); + assertMsg(check, EXACT_WRAPPED_PARAMS, "Indentation mismatch: expected: 1, actual: 2"); } } @@ -124,6 +129,10 @@ long comment default: doSomething(); } + doSomething({ + a: 1, + b: 2 + }); } }"; @@ -163,7 +172,7 @@ class Test { public function new() {} }"; - var WRAPPED_PARAMS = " + var LARGER_WRAPPED_PARAMS = " class Test { public function new(param1:Int, param2:Int, @@ -179,13 +188,23 @@ class Test { } }"; - var WRONG_WRAPPED_PARAMS = " + var EXACT_WRAPPED_PARAMS = " +class Test { + public function new(param1:Int, + param2:Int, + param3:Int, + param4:Int) { + doSomething(); + } +}"; + + var NONE_WRAPPED_PARAMS = " class Test { public function new(param1:Int, param2:Int, param3:Int, param4:Int) { - doSomething(); + doSomething(); } }"; diff --git a/test/checks/whitespace/SpacingCheckTest.hx b/test/checks/whitespace/SpacingCheckTest.hx index 7894feb7..9f7ecdc8 100644 --- a/test/checks/whitespace/SpacingCheckTest.hx +++ b/test/checks/whitespace/SpacingCheckTest.hx @@ -125,22 +125,22 @@ abstract SpacingCheckTests(String) to String { } }"; - var TEST2 = - "class Test { + var TEST2 = " + class Test { public function test() { var a = a+1; } }"; - var TEST3 = - "class Test { + var TEST3 = " + class Test { public function test() { var a = a ++; } }"; - var TEST4A = - "class Test { + var TEST4A = " + class Test { public function test() { for(i in 0...10) { @@ -148,8 +148,8 @@ abstract SpacingCheckTests(String) to String { } }"; - var TEST4B = - "class Test { + var TEST4B = " + class Test { public function test() { for (i in 0...10) { @@ -157,22 +157,22 @@ abstract SpacingCheckTests(String) to String { } }"; - var TEST5A = - "class Test { + var TEST5A = " + class Test { public function test() { while(true) {} } }"; - var TEST5B = - "class Test { + var TEST5B = " + class Test { public function test() { while (true) {} } }"; - var TEST6A = - "class Test { + var TEST6A = " + class Test { public function test() { switch(0) { case 1: @@ -181,8 +181,8 @@ abstract SpacingCheckTests(String) to String { } }"; - var TEST6B = - "class Test { + var TEST6B = " + class Test { public function test() { switch (0) { case 1: @@ -191,24 +191,24 @@ abstract SpacingCheckTests(String) to String { } }"; - var TEST7A = - "class Test { + var TEST7A = " + class Test { public function test() { try {} catch(e:Dynamic) {} } }"; - var TEST7B = - "class Test { + var TEST7B = " + class Test { public function test() { try {} catch (e:Dynamic) {} } }"; - var TEST8 = - "class Test { + var TEST8 = " + class Test { public function test() { if( true diff --git a/test/checks/whitespace/TabForAligningCheckTest.hx b/test/checks/whitespace/TabForAligningCheckTest.hx index 12e3ae04..894ddc60 100644 --- a/test/checks/whitespace/TabForAligningCheckTest.hx +++ b/test/checks/whitespace/TabForAligningCheckTest.hx @@ -28,8 +28,8 @@ abstract TabForAligningCheckTests(String) to String { }"; - var TEST2 = - "class Test { + var TEST2 = " + class Test { public function test() { var a:Array = ['one', 'two', 'three']; diff --git a/test/token/TokenTreeBuilderTest.hx b/test/token/TokenTreeBuilderTest.hx index 24e57c2e..564687f5 100644 --- a/test/token/TokenTreeBuilderTest.hx +++ b/test/token/TokenTreeBuilderTest.hx @@ -91,31 +91,31 @@ abstract TokenTreeBuilderTests(String) to String { import checkstyle.TokenTreeBuilder; "; var IMPORT_GOLD = - " Kwd(KwdPackage)\n" + - " Const(CIdent(checkstyle))\n" + - " Dot\n" + - " Const(CIdent(checks))\n" + - " Semicolon\n" + - " Kwd(KwdImport)\n" + - " Const(CIdent(haxeparser))\n" + - " Dot\n" + - " Binop(OpMult)\n" + - " Semicolon\n" + - " Kwd(KwdImport)\n" + - " Const(CIdent(checkstyle))\n" + - " Dot\n" + - " Const(CIdent(TokenTree))\n" + - " Semicolon\n" + - " Kwd(KwdImport)\n" + - " Const(CIdent(checkstyle))\n" + - " Dot\n" + - " Const(CIdent(TokenStream))\n" + - " Semicolon\n" + - " Kwd(KwdImport)\n" + - " Const(CIdent(checkstyle))\n" + - " Dot\n" + - " Const(CIdent(TokenTreeBuilder))\n" + - " Semicolon\n"; + " Kwd(KwdPackage)\n" + + " Const(CIdent(checkstyle))\n" + + " Dot\n" + + " Const(CIdent(checks))\n" + + " Semicolon\n" + + " Kwd(KwdImport)\n" + + " Const(CIdent(haxeparser))\n" + + " Dot\n" + + " Binop(OpMult)\n" + + " Semicolon\n" + + " Kwd(KwdImport)\n" + + " Const(CIdent(checkstyle))\n" + + " Dot\n" + + " Const(CIdent(TokenTree))\n" + + " Semicolon\n" + + " Kwd(KwdImport)\n" + + " Const(CIdent(checkstyle))\n" + + " Dot\n" + + " Const(CIdent(TokenStream))\n" + + " Semicolon\n" + + " Kwd(KwdImport)\n" + + " Const(CIdent(checkstyle))\n" + + " Dot\n" + + " Const(CIdent(TokenTreeBuilder))\n" + + " Semicolon\n"; var AT_ANNOTATION = ' @SuppressWarnings("checkstyle:MagicNumber") @@ -125,25 +125,25 @@ abstract TokenTreeBuilderTests(String) to String { // EOF '; var AT_ANNOTATION_GOLD = - " At\n" + - " Const(CIdent(SuppressWarnings))\n" + - " POpen\n" + - " Const(CString(checkstyle:MagicNumber))\n" + - " PClose\n" + - " At\n" + - " Const(CIdent(SuppressWarnings))\n" + - " POpen\n" + - " BkOpen\n" + - " Const(CString(checkstyle:MagicNumber))\n" + - " Comma\n" + - " Const(CString(checkstyle:AvoidStarImport))\n" + - " BkClose\n" + - " PClose\n" + - " At\n" + - " DblDot\n" + - " Const(CIdent(from))\n" + - " At\n" + - " Const(CIdent(Before))\n"; + " At\n" + + " Const(CIdent(SuppressWarnings))\n" + + " POpen\n" + + " Const(CString(checkstyle:MagicNumber))\n" + + " PClose\n" + + " At\n" + + " Const(CIdent(SuppressWarnings))\n" + + " POpen\n" + + " BkOpen\n" + + " Const(CString(checkstyle:MagicNumber))\n" + + " Comma\n" + + " Const(CString(checkstyle:AvoidStarImport))\n" + + " BkClose\n" + + " PClose\n" + + " At\n" + + " DblDot\n" + + " Const(CIdent(from))\n" + + " At\n" + + " Const(CIdent(Before))\n"; var IF = ' if (tokDef != null) return; @@ -162,61 +162,61 @@ abstract TokenTreeBuilderTests(String) to String { } '; var IF_GOLD = - " Kwd(KwdIf)\n" + - " POpen\n" + - " Const(CIdent(tokDef))\n" + - " Binop(OpNotEq)\n" + - " Kwd(KwdNull)\n" + - " PClose\n" + - " Kwd(KwdReturn)\n" + - " Semicolon\n" + - " Kwd(KwdIf)\n" + - " POpen\n" + - " Const(CIdent(tokDef))\n" + - " Binop(OpNotEq)\n" + - " Kwd(KwdNull)\n" + - " PClose\n" + - " Kwd(KwdReturn)\n" + - " Semicolon\n" + - " Kwd(KwdElse)\n" + - " Kwd(KwdThrow)\n" + - " Const(CString(error))\n" + - " Semicolon\n" + - " Kwd(KwdIf)\n" + - " POpen\n" + - " Const(CIdent(token))\n" + - " Dot\n" + - " Const(CIdent(hasChildren))\n" + - " POpen\n" + - " PClose\n" + - " PClose\n" + - " BrOpen\n" + - " Kwd(KwdReturn)\n" + - " Const(CIdent(token))\n" + - " Dot\n" + - " Const(CIdent(children))\n" + - " Semicolon\n" + - " BrClose\n" + - " Kwd(KwdIf)\n" + - " POpen\n" + - " Const(CIdent(token))\n" + - " Dot\n" + - " Const(CIdent(hasChildren))\n" + - " POpen\n" + - " PClose\n" + - " PClose\n" + - " BrOpen\n" + - " Kwd(KwdReturn)\n" + - " Const(CIdent(token))\n" + - " Dot\n" + - " Const(CIdent(children))\n" + - " Semicolon\n" + - " BrClose\n" + - " Kwd(KwdElse)\n" + - " BrOpen\n" + - " Kwd(KwdReturn)\n" + - " BkOpen\n" + - " BkClose\n" + - " Semicolon\n" + - " BrClose\n"; + " Kwd(KwdIf)\n" + + " POpen\n" + + " Const(CIdent(tokDef))\n" + + " Binop(OpNotEq)\n" + + " Kwd(KwdNull)\n" + + " PClose\n" + + " Kwd(KwdReturn)\n" + + " Semicolon\n" + + " Kwd(KwdIf)\n" + + " POpen\n" + + " Const(CIdent(tokDef))\n" + + " Binop(OpNotEq)\n" + + " Kwd(KwdNull)\n" + + " PClose\n" + + " Kwd(KwdReturn)\n" + + " Semicolon\n" + + " Kwd(KwdElse)\n" + + " Kwd(KwdThrow)\n" + + " Const(CString(error))\n" + + " Semicolon\n" + + " Kwd(KwdIf)\n" + + " POpen\n" + + " Const(CIdent(token))\n" + + " Dot\n" + + " Const(CIdent(hasChildren))\n" + + " POpen\n" + + " PClose\n" + + " PClose\n" + + " BrOpen\n" + + " Kwd(KwdReturn)\n" + + " Const(CIdent(token))\n" + + " Dot\n" + + " Const(CIdent(children))\n" + + " Semicolon\n" + + " BrClose\n" + + " Kwd(KwdIf)\n" + + " POpen\n" + + " Const(CIdent(token))\n" + + " Dot\n" + + " Const(CIdent(hasChildren))\n" + + " POpen\n" + + " PClose\n" + + " PClose\n" + + " BrOpen\n" + + " Kwd(KwdReturn)\n" + + " Const(CIdent(token))\n" + + " Dot\n" + + " Const(CIdent(children))\n" + + " Semicolon\n" + + " BrClose\n" + + " Kwd(KwdElse)\n" + + " BrOpen\n" + + " Kwd(KwdReturn)\n" + + " BkOpen\n" + + " BkClose\n" + + " Semicolon\n" + + " BrClose\n"; } \ No newline at end of file