The Gabelou is now available in the DWScript SVN, this is a set of classes and rules that aims to watch over coding styles.
Currently only a handful of naming rules are declared, with more coming.
You can run the Gabelou by adding the dwsGabelou unit to your uses, then create an instance, add custom rules or use built-in ones (f.i. those in dwsGabelouStdRules), compile a script program as usual, then invoke Gabelou on the compiled program:
gabelou.Evaluate( someIdwsProgram );
The rules will then be evaluated, and corresponding hints or style error will be added to the standard error messages list of the program. You can optionally restrict the rules check to a particular source file (f.i. the one currently edited in your IDE).
For instance the following snippet
type myClass = class private field : Integer; procedure doh; begin end; end;
will result in the following messages
Hint: Private field "field" declared but never used [line: 4, column: 10] Hint: Private method "doh" declared but never used [line: 6, column: 20] Gabelou: "myClass", Type names should follow PascalCase and start with an upper-case character [line: 2, column: 4] Gabelou: "field", Private or protected fields should start with "F" followed by PascalCase.[line: 4, column: 10] Gabelou: "doh", Function names should follow PascalCase and start with an upper-case character [line: 6, column: 20]
Rules can be added as IdwsGabelouRule interfaces, or via the RegisterRuleClass class methods.
You can find a few ready-to-use rules in dwsGabelouStdRules which match those used in the DWScript source code, and are a mix of classic Pascal conventions and more modern ones borrowed from the Java world. Feel free to derive your own sets!
And what is a Gabelou? It’s an old french slang for a customs officer, it’s here to help you make sure you don’t ship out what you shouldn’t 😉
Way cool!!!
This kind of configurable system would be must for the Delphi/FreePascal – Lazarus also…
And PascalCasedWords could be spell checked also, it is very embarrassing to see some elementary spelling errors code that has been on repository for ages 🙂
I actually gave it a try, but the dictionary I was using (OpenOffice’s hunspell) was woefully lacking when it came to technical terminologies.
I guess the first need would be to write or compile a developer’s dictionary!