mpeterv / luacheck

A tool for linting and static analysis of Lua code.
MIT License
1.92k stars 322 forks source link

Clarify white-space warning 611 "line contains only whitespace" #113

Closed mikeyyuen closed 7 years ago

mikeyyuen commented 7 years ago

Hello, I was looking for context about why this warning exists

["611"] = "line contains only whitespace"

I didn't find anything in the docs just this previous issue https://github.com/mpeterv/luacheck/issues/79

If possible i'd like to submit a PR against https://github.com/mpeterv/luacheck/blob/master/docsrc/warnings.rst#formatting-issues-6xx so users can understand why this is important.

Thanks

mpeterv commented 7 years ago

It's a form of trailing whitespace which is useless and is forbidden in many formatting styles. Feel free to send a PR with a clarification.

mikeyyuen commented 7 years ago

Understood, working on wording for a PR, I found some general convenience reasons why trailing is part of style guides.

From: https://softwareengineering.stackexchange.com/a/121560

Reasons that it's important to me:

  • When I hit the "End" key, I expect the cursor to go to the end of the line (depending what editor I'm using and how it's configured) and I expect to be able to start typing right away. If the cursor gets there and I have to delete 3 or 4 characters, it's annoying. Especially if it's inconsistent throughout the file(s).
  • When I have string literals that span multiple lines, trailing whitespace can make the output string look incorrect when it's used.

Does that sound about right?

I didn't find anything Lua specific nor anything that covered white space only lines, is that expected? Or am I looking in the wrong place?

mikeyyuen commented 7 years ago

https://github.com/mpeterv/luacheck/pull/114 Let me know if that sounds ok?

mpeterv commented 7 years ago

Thanks for the PR, merged