jednano / eclint

Validate or fix code that doesn't adhere to EditorConfig settings or infer settings from existing code.
MIT License
305 stars 28 forks source link

fix does not fully fix all issues #35

Closed lhoang29 closed 9 years ago

lhoang29 commented 9 years ago

I'm applying eclint to this file here: https://github.com/eisber/vowpal_wabbit/blob/master/vowpalwabbit/gd.cc.

'check' showed some issues and 'fix' fixed some of them. Running 'check' again still shows there are more issues, but now 'fix' doesn't do anything to the file. Any ideas? The editorconfig file being used is here: https://github.com/eisber/vowpal_wabbit/blob/master/.editorconfig

I'm on Ubuntu 14.04, npm 1.4.28, node v0.10.40, installed eclint by 'sudo npm install -g eclint'

jednano commented 9 years ago

You'll have to isolate the problem to be more specific about which issues are not being fixed.

lhoang29 commented 9 years ago

Sure, here are the remaining issues. Doing fix after this does nothing.

vowpalwabbit/gd.cc: line 5: invalid indent size: 1, expected: 2 vowpalwabbit/gd.cc: line 157: invalid indent size: 11, expected: 2 vowpalwabbit/gd.cc: line 176: invalid indent size: 5, expected: 2 vowpalwabbit/gd.cc: line 177: invalid indent size: 3, expected: 2 vowpalwabbit/gd.cc: line 228: invalid indent size: 19, expected: 2 vowpalwabbit/gd.cc: line 325: invalid indent size: 1, expected: 2 vowpalwabbit/gd.cc: line 326: invalid indent size: 3, expected: 2 vowpalwabbit/gd.cc: line 327: invalid indent size: 3, expected: 2 vowpalwabbit/gd.cc: line 328: invalid indent size: 1, expected: 2 vowpalwabbit/gd.cc: line 330: invalid indent size: 1, expected: 2 vowpalwabbit/gd.cc: line 331: invalid indent size: 3, expected: 2 vowpalwabbit/gd.cc: line 332: invalid indent size: 1, expected: 2 vowpalwabbit/gd.cc: line 334: invalid indent size: 1, expected: 2 vowpalwabbit/gd.cc: line 335: invalid indent size: 1, expected: 2 vowpalwabbit/gd.cc: line 336: invalid indent size: 3, expected: 2 vowpalwabbit/gd.cc: line 337: invalid indent size: 3, expected: 2 vowpalwabbit/gd.cc: line 338: invalid indent size: 3, expected: 2 vowpalwabbit/gd.cc: line 339: invalid indent size: 1, expected: 2 vowpalwabbit/gd.cc: line 593: invalid indent size: 11, expected: 2 vowpalwabbit/gd.cc: line 597: invalid indent size: 11, expected: 2 vowpalwabbit/gd.cc: line 624: invalid indent size: 9, expected: 2 vowpalwabbit/gd.cc: line 625: invalid indent size: 3, expected: 2 vowpalwabbit/gd.cc: line 634: invalid indent size: 11, expected: 2 vowpalwabbit/gd.cc: line 638: invalid indent size: 11, expected: 2 vowpalwabbit/gd.cc: line 799: invalid indent size: 13, expected: 2 vowpalwabbit/gd.cc: line 810: invalid indent size: 17, expected: 2 vowpalwabbit/gd.cc: line 816: invalid indent size: 17, expected: 2 vowpalwabbit/gd.cc: line 861: invalid indent size: 11, expected: 2 vowpalwabbit/gd.cc: line 862: invalid indent size: 5, expected: 2 vowpalwabbit/gd.cc: line 998: invalid indent size: 3, expected: 2

jednano commented 9 years ago

Ah, indent size. Of course! Indent size is a tricky thing to fix. In fact, I'm pretty sure it's impossible to fix w/o an AST parser for whatever language you're writing. As such, there's no way to fix this issue if you don't do it manually.

lhoang29 commented 9 years ago

Ah. How do others deal with this? Perhaps a combination of eclint with some other language-specific tool (e.g. astyle)?

jednano commented 9 years ago

The only way to "fix" indentation is to parse into AST and restyle it. EditorConfig isn't aware of your programming language at all, so "others" don't fix it in this context. If they do, I've never seen it, nor do I think it's possible. Even the AST fix destroys any whitespace for alignment you may have, so that's not perfect.

lhoang29 commented 9 years ago

I understand, what I meant was to use a combination of eclint with another tool that can handle the language-specific structure. For instance, using eclint in the first round and astyle (http://astyle.sourceforge.net/) next to fix indent works for me. This isn't perfect, but I can leverage most of the editorconfig settings.

jednano commented 9 years ago

That would be a viable solution! Closing.