These are ideas for things the boo compiler could check, using a special compiler step. It is similar to pychecker or pylint. See also the Boo Optimizations page.
- All class/enum/struct/property/method names should begin with a capital letter and ideally be PascalCased.
- Interface names should start with capital I followed by PascalCase name.
- Don't have local variables or parameters names that start with an underscore. That is for fields, esp. non-public fields.
- Don't create a local variable (or parameter) with the same name as a field.
- Don't have an unnecessary modifier like "public" if the default is already public. No need for "protected" modifier on a field.
- parameter names should be camelCase.
- Use type inference instead of declaration when possible. "x as int = 4". Better to just say "x=4".
- "print x" preferred over "print(x)" when used as a statement
- "return x" preferred over "return(x)" when used as a statement (I don't think return(x) is valid code)
No mixing of tabs and spaces for indentation.
The indentation scheme that we have now can cause problems by mixing spaces and tabs.
The code above will not
assert falsebecause a space is hidden inside the indentation tabs.
The best way in my opinion to handle this situation is to eliminate spaces as indentation altogether, but an alternate situation would be to stop indentation from working in the case that spaces and tabs are mixed.
- Convert s=="" to s.Length==0, apparently it is faster, but also warn if user did not also check that s is not null. I also put this suggestion on the Boo Optimizations page.
- Check for if/elif/while statements that have parentheses around the entire conditional, e.g.
if (i == 2):.
- If a return type is specified, ensure a return statement is used. Boo silently inserts a "return null" otherwise: http://jira.codehaus.org/browse/BOO-418
fxCop might have some other ideas for things boo could check.