Skip to content

Commit

Permalink
Merge pull request #2 from adireddy/dev
Browse files Browse the repository at this point in the history
added ignoreRangeOperator for SpacingCheck
  • Loading branch information
Adi committed May 6, 2015
2 parents 1d95216 + 0b4224d commit d99cf74
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 6 deletions.
2 changes: 2 additions & 0 deletions checkstyle/checks/SpacingCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SpacingCheck extends Check {
public var spaceAroundBinop = true;
public var noSpaceAroundUnop = true;
public var spaceIfCondition = true;
public var ignoreRangeOperator = true;

override function _actualRun() {
var lastExpr = null;
Expand All @@ -27,6 +28,7 @@ class SpacingCheck extends Check {

switch e.expr {
case EBinop(bo, l, r) if (spaceAroundBinop):
if (ignoreRangeOperator && binopString(bo) == "...") return;
if (r.pos.min - l.pos.max < binopSize(bo) + 2) logPos('No space around ${binopString(bo)}', e.pos, Reflect.field(SeverityLevel, severity));
case EUnop(uo, post, e2) if (noSpaceAroundUnop):
var dist = 0;
Expand Down
4 changes: 2 additions & 2 deletions haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
],
"description": "Automated code analysis ideal for projects that want to enforce a coding standard.",
"contributors": ["adireddy"],
"releasenote": "added type check",
"version": "1.0.4",
"releasenote": "added ignoreRangeOperator config for SpacingCheck",
"version": "1.0.5",
"url": "https://github.com/adireddy/haxe-checkstyle",
"dependencies": {

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "checkstyle",
"version": "1.0.4",
"version": "1.0.5",
"description": "Automated code analysis ideal for projects that want to enforce a coding standard.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -31,4 +31,4 @@
"grunt-zip": "^0.16.0",
"jsdoc": "^3.2.2"
}
}
}
3 changes: 2 additions & 1 deletion resources/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
"severity": "INFO",
"spaceIfCondition": true,
"spaceAroundBinop": true,
"spaceAroundBinop": true
"spaceAroundBinop": true,
"ignoreRangeOperator": true
}
},
{
Expand Down
Binary file modified run.n
Binary file not shown.
15 changes: 15 additions & 0 deletions test/IndentationCharacterCheckTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class IndentationCharacterCheckTest extends CheckTestCase {
var msg = checkMessage(IndentationTests.TEST3, check);
assertEquals(msg, 'Wrong indentation character (space)');
}

public function testMultilineIfIndentation() {
var msg = checkMessage(IndentationTests.TEST4, new IndentationCharacterCheck());
assertEquals(msg, '');
}
}

class IndentationTests {
Expand All @@ -40,4 +45,14 @@ class IndentationTests {
"class Test {
public function new() {}
}";

public static inline var TEST4:String =
"class Test {
public function new() {
if (actionType == 'STREET' ||
(actionType == 'BASKET' && ( actionNumber == 2 || actionNumber == 4) )) {
return BetAreaModel.STREET;
}
}
}";
}
16 changes: 15 additions & 1 deletion test/SpacingCheckTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class SpacingCheckTest extends CheckTestCase {
var msg = checkMessage(SpacingTests.TEST3, new SpacingCheck());
assertEquals(msg, 'Space around ++');
}

public function testFor() {
var msg = checkMessage(SpacingTests.TEST4, new SpacingCheck());
assertEquals(msg, '');
}
}

class SpacingTests {
Expand All @@ -36,9 +41,18 @@ class SpacingTests {
}";

public static inline var TEST3:String =
"class Test {
"class Test {
public function test() {
var a = a ++;
}
}";

public static inline var TEST4:String =
"class Test {
public function test() {
for(i in 0...10) {
}
}
}";
}

0 comments on commit d99cf74

Please sign in to comment.