Code Review at compile time

3

I need to do an automatic Code Review on my codes. We use Jenkins which triggers compilation with some other validations every day, but at non-commercial times.

As the project is very extensive and undergoes constant changes during the day, it is unfeasible to fire Job from Jenkins to commit .

So I wonder if it's possible to develop a code parsing component that validates code while compiling the project in Delphi .

I gave one a lookup on how to do this at compile time. One of the options I found would be to extend the Delphi compiler. I found this guy but saw that he's been standing for 1 year.

I do not know if this is the only option, so I wonder if it's possible to do it in other ways.

PS: What I need to do are some validations similar to CodeSmells of Sonar in code during compilation.

Eg prevent constructors from being declared without inherited.

    
asked by anonymous 18.07.2016 / 20:07

2 answers

2

You can use a static code analysis tool, such as Pascal Expert / Pascal Analyzer or the FixInsight for example, to review your code before committing.

These tools can also be integrated via the command line, in a job in Jenkins or in a build event in Delphi project settings, to review the code after each commit or each build respectively.

    
23.07.2016 / 17:04
3

I will post as a response because it did not fit in the comment.

Usually in java use Jenkins + Sonarqube (known as Sonar) for general code evaluation.

A quick google search on jenkins + delphi gives you to find 2 or 3 different plugins, all seemingly stuck in their respective repositories ...

link

link

We also have a noncontinued plugin that is mentioned in an old sonar documentation:

link

If you have your preferred code evaluation tool, you could create a pre build or post build task in jenkins and call this your tool by command line. After the evaluation, make an assertion of a certain metric to your respective taste (eg look at a text file generated by the tool by some variable).

Alternatively, would you be writing a sonar plugin .

    
24.07.2016 / 22:37