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

Check for spaces around assignment #50

Closed
Gama11 opened this issue Feb 28, 2016 · 7 comments
Closed

Check for spaces around assignment #50

Gama11 opened this issue Feb 28, 2016 · 7 comments

Comments

@Gama11
Copy link
Member

Gama11 commented Feb 28, 2016

There are two different styles you might want to enforce here:

var c:Int = 0;

function foo(b:Bool = false)
{
    var a = b;
}

and

var c:Int=0;

function foo(b:Bool=false)
{
    var a=b;
}
@AlexHaxe
Copy link
Member

see WhitespaceAroundCheck in token-tree branch for first style, currently there is no check for second style

@Gama11
Copy link
Member Author

Gama11 commented Feb 28, 2016

Ah, cool, I'll have to check that out. I only really care about the first style personally, but I could see somebody wanting the second.

How stable is that branch? I guess there's a reason why it's separate?

@AlexHaxe
Copy link
Member

It is a fairly new feature, and it might not work on all different token constellations - Haxe is very flexible and if you use a more let's say "creative style", it might fail, or show false positives/negatives.

But since those cases won't get fixed, if nobody uses it and reports bugs, you should give it a try. token-tree branch also comes with a few additional checks.

@Gama11
Copy link
Member Author

Gama11 commented Feb 29, 2016

This now works fine for my use case with the recent fixes, but I guess it should be left open to cover the inverse (enforcing no spaces)?.

@AlexHaxe
Copy link
Member

Yes, we should support the opposite of WhitespaceAround for people who prefer that coding style.
The question is, if we just add a flag to WhitespaceAround to invert its check function, or if we write new checks like NoWhitespaceBefore/After (like java checkstyle, though I am not sure, if they can be used to enforce no whitespace around e.g. =).
If we add a flag to WhitespaceAround, should we differentiate between whitespace and linebreaks, so do we need four modes: enforce whitespace, no whitespace, allow linebreaks before and allow linebreaks after?

@Gama11
Copy link
Member Author

Gama11 commented Feb 29, 2016

There's a similar issue with WhitespaceAfter btw, some people add spaces before and after parens in function calls.

trace( "Hello World" )

vs

trace("Hello World")

or even

trace ("Hello World")

That would also requie a WhitespaceBefore to enforce I guess?

@AlexHaxe
Copy link
Member

AlexHaxe commented Mar 9, 2016

I am marking this as a duplicate of #135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants