style checks ============ uncontroversial checks ---------------------- if() ^ no space between control keyword and parenthesis (this does not apply to "function-like" keywords) (note that the parenthesis is usually not required) f (); ^ space between function name and arguments parenthesis. applies to both declarations and calls. x ; ^ space between expression and semicolon x ^; x ?; ^ space before ^ or ? operator @ x; ^ space after @ operator int ^ int ? int *+> int #[10] ^ space before type suffix (but spacing is allowed inside #[]). also, note that "int own^ x" is allowed, but "int own ^ x" isn't. f(); g( ); h; ^ statement starts in the middle of a line and spans multiple lines fi();{ } ^ statement starts in the middle of a line and spans multiple lines if x { } ^ closing bracket not aligned with statement header if x { } ^ closing bracket not alogined with statement header if x { ^ opening bracket is on separate line but not aligned with statement header. if x // empty lines here { ^ one or more empty lines between statement header and opening bracket (but it's allowed to have empty lines before a bare compound statement) if x { } if y { z; } ^ statement after multiline statement should start on a separate line (but comments are allowed) if x continue; return 1; ^ wrong indentation return; (optional whitespace) } ^ void return at the end of function (note that if there's code commented out after the return, it should be accepted) /* int x; * bla bla */ ^ block comment hides code to the left of it. - mixing tabs and spaces in indentation - trailing whitespace after a line (but not for indentation) - no newline at the end of the file - enforce that the source files are UTF-8 encoded - forbid certain bytes and UTF-8 characters: 0x00-0x1F, except 0x09, 0x0A, 0x0D and form feed 0x7F-0xA0 (some of these affect terminals, and 0x85 can apparently cause problems in Python) 0xFE 0xFF U+2028, U+2029 (Unicode linefeed) U+FDD0, U+FFFF, U+1FFFF, any overlong UTF-8 sequence any Unicode combininig marks not in NFC order (or perhaps _any_ combining marks) - forbid those outside of comments: U+200B, U+200C, U+200D, (ZWSP etc.) perhaps U+200E U+200F (ltr, rtl mark) also, ‐ (Unicode hyphen) can be deceptive perhaps any Unicode whitespace character? perhaps any Unicode operator-like or character-like character? - perhaps have an option to allow/forbid Unicode outside of comments and strings controversial checks -------------------- if a{ ^ no space before { else{ ^ no space before { }else ^ no space/newline after } 1 * 2+3 ^ deceptive use of spaces (this could be used for alignment) 1_00_000 ^ confusing usage of _ in number. (but in some countries numbers might be written like this) also, numbers like 1_000_00 can be used for currencies. - no newline between function header and { - newline between control statement header and { - newline between } and "else" or "while" - using not 4 spaces for indentation - using tabs for indentation bad checks, won't be added -------------------------- - checking for too many / to few spaces in the middle of a line, or in the beginning of second (or later) line in a multi-line expression/definition/statement/etc, because this is in fact very useful for alignment. - checking that statements begin at the beginning of a line, because it's useful to be able to call functions in a table, e.g.: a1(1); b1(2); c1(3); a2(1); b2(2); c2(3);