Colobot Forum - International Colobot Community

Full Version: Introducing colobot-lint
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For the last two weeks, I've been working on a static analysis tool based on Clang's libtooling that would help us in refactoring Colobot code. The project, which I named colobot-lint, is now pretty much complete in how I envisioned it, and stable enough, so the time has come to officially introduce it.

Colobot-lint uses Clang's extensive API to perform a range of checks on C++ code, compiled to AST (abstract syntax tree). Based on information contained in AST and associated contextual data, it can detect things such as:
 - uninitialized local variables
 - uninitialized fields in structs/classes
 - uses of new/delete operators
 - functions written in legacy C style (variable declarations only at the beginning of function)
 - occurences of TODO comments
 - style checks (variable/function/class naming, etc.)

Project repository is here: https://github.com/piotrdz/colobot-lint
Full list of checks performed is documented here: https://github.com/piotrdz/colobot-lint/...r/RULES.md

For the time being, I have set up my own Jenkins CI server at http://piotrdz.pl:9000/ with jobs running colobot-lint on current Colobot code (dev branch). Later, we can move these jobs to our main Jenkins server.

There are two jobs listed in Main page:
 - colobot-lint-build builds colobot-lint tool itself
 - colobot-lint-run runs colobot-lint on latest dev branch of Colobot

The results are visualized using cppcheck plugin in a form of graph (http://piotrdz.pl:9000/job/colobot-lint-run/) and list of issues (http://piotrdz.pl:9000/job/colobot-lint-...eckResult/). You can click on link in "Line" column to see source code location, for example: http://piotrdz.pl:9000/job/colobot-lint-...e.1030/#48

As you can see, there is currently quite a lot of detected issues, but the point is not to fix them all at once. Instead, as in every refactoring effort, we should try to lower the number of issues step by step, and not introduce new issues. Each issue is also marked with category like error, warning or style, based on what I felt are most important issues.

Some improvements are still needed, for example better way to display results, as the Jenkins cppcheck plugin is quite limited. I've listed some ideas for improvement as issues here: https://github.com/piotrdz/colobot-lint/issues. You are welcome to report any bugs or your propositions for improvements.

Update:
Now I think the tool can be safely described as finished, at least unless we find more rules to add to it.

For some time now, the tool has been running on our main Jenkins server: http://compiled.colobot.info/jenkins/job...-lint-run/. My old server now serves as slave to run the colobot-lint jobs.

I also moved the repository on github from my account to our organization: https://github.com/colobot/colobot-lint, as I think it should be included there along with other tools that we have developed.