Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positive with EmptyLinesCheck. #310

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/checkstyle/checks/whitespace/EmptyLinesCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ class EmptyLinesCheck extends LineCheckBase {
for (i in 0...checker.lines.length) {
var line = checker.lines[i];
var ranges = getRanges(line);
if (ranges.length == 1 && ranges[0].type != TEXT) continue;
//if (ranges.length == 1 && ranges[0].type != TEXT) continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why leave the old logic in, but commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I'm a dumb dumb.

if (ranges.length == 1) {
switch (ranges[0].type) {
case TEXT:
case COMMENT(isBlock): if (isBlock) continue;
case STRING(isInterpolated): continue;
}
}

if (~/^\s*$/.match(line)) {
if (!inGroup) {
Expand Down
4 changes: 2 additions & 2 deletions test/checks/whitespace/EmptyLinesCheckTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ abstract EmptyLinesCheckTests(String) to String {
var TEST4 =
"class Test {

// comments
// comments (with text before)

public function new() {
var b:Int;
Expand All @@ -136,7 +136,7 @@ abstract EmptyLinesCheckTests(String) to String {
var TEST5 =
"class Test {

// comments
// comments (with no text before)

var a:Int;
}";
Expand Down