Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enforce Delphi Coding Standards

I want to enforce coding standards for our Delphi codebase.

A few colleagues have suggested Code Healer and Pascal Analyzer. I've had a look at these tools and they aren't suitable.

I was hoping to be able to do the same thing that CheckStyle for Java or StyleCop for C# can do

like image 250
Ben Clews Avatar asked Jun 29 '10 05:06

Ben Clews


People also ask

What programming language is used in Delphi?

Delphi uses the Pascal-based programming language Object Pascal created by Anders Hejlsberg for Borland (now IDERA) as the successor to Turbo Pascal. It supports native cross-compilation to many platforms including Windows, Linux, iOS and Android.

Is Delphi a high level language?

Delphi is a high level language supporting object-oriented design. It is a rapid application development used to develop applications ranging from database solutions to mobile applications and is used on Windows as well as Linux.

Is Delphi a scripting language?

In a nutshell, DelphiScript is an OLE scripting language, like VBScript or JScript, but derived from Standard Pascal (not Object Pascal).

What can Delphi be used for?

The Delphi language and software development kit is most widely used for the development of Windows applications. However, it is also used to develop web applications, machine learning applications, desktop applications, windows applications, and mobile applications for OS X, iOS, and Android operating systems.


3 Answers

Some newer editions of Delphi offer Audits and Metrics in the Model view, which can also be configured to set allowed limits. They do not run from command line for build integration afaik so I found them not very helpful.

I know the highly customizable Java (and .Net tools) like PMD, FindBugs and CheckStyle which generate XML or HTML statistic reports, and also integrate very well with build tools (Ant, Maven, Hudosn) - but for Delphi nothing comparable has crossed my road so far.

like image 119
mjn Avatar answered Oct 22 '22 13:10

mjn


It seems those 2 are the most used. You can also try:

http://jedicodeformat.sourceforge.net/

like image 3
RBA Avatar answered Oct 22 '22 12:10

RBA


The best one is Pascal Analyzer (PAL) by Peganza, which you said you tried and found unsuitable, but did not say why. I will say a bit in its favor: It's Commercial, inexpensive, and so worth it. They recently released version 5, and if version 5 doesn't do what you want, you should tell them what you want, because they have always answered my requests whenever I have mentioned a feature I wish the product would add.

We use it instead of the high-end SKUs of Delphi's metrics because it costs less and does more than the built-in $3000 stuff. I think it costs about $160 us.

I am a happy customer. Here is a sample of some of the metric areas that I like:
convention compliance - class names that don't start with T, exception types don't start with E, class fields not in private, identifiers with goofy names, class visibility confusion or bad order, local identifier/unit outer scope identifier clashes. Inconsistent case, Many many many more!

alt text

The weakness is that the output is plain text in a "TMemo" control. Of course, I have found a lot of ways to take that output and write my own small sort/filter utilities to mine even more useful stuff from the reports. A powerful tool that you won't be able to live without once you try it.

I realize you said in your answer that you tried that already, but if it's not what you want, it's already the best LINT like tool for Pascal that currently exists.

like image 3
Warren P Avatar answered Oct 22 '22 14:10

Warren P