Automatic consistency checking

This post is very old. Please bear in mind that information here might be incorrect or obsolete, and links can be broken. If something seems wrong, please feel free to comment or contact me and I'll update the post.

Yesterday evening I slapped together a small tool for consistency checking of large codebases. It’s written in a similar spirit as Boost’s inspect tool, just slightly more sophisticated. Written in C#, it allows you to plug in your own checks easily. At the moment, I have a generic RegEx checker (just looks if a regular expression matches) and a line ending checker in my core tests and a bunch of niven specific ones (license, interfaces with struct and not with class, file header, @file comment in header matches file name, include guards are not reused, missing @author, outdated mail addresses).

Some example output:

Loading checker from 'Checks'
         .. 'CrLfCheck'
 .. 1 checker loaded
Loading checker from 'nivenChecks'
         .. 'CheckFileHeader'
         .. 'OutdatedMailAnteru'
         .. 'AuthorCheck'
         .. 'IncludeGuards'
         .. 'StructInterfaces'
         .. 'FilenameInHeader'
 .. 6 checker loaded

Extensions:
        'cpp'
        'h'

Running checks for 'archive.h'
 ++ OK  ... 0 failures

...

Running checks for 'core.h'
    Include guards      : Include guard already used
        >> Line: 9: The include guard 'NIV_CORE_H' has been already used
    Interfaces          : Interface defined with 'class'
        >> Line: 17: Interface 'IFileSystem' uses 'class' instead of 'struct'
 -- FAILED  ... 2 failures

...

39 failures (101 files total)

It was written against the .NET Framework 2.0, but it should work with Mono as well. On startup, it loads up your assembly and pulls the checks out of it, so it’s really easy to extend. I’m running it now along with the build to see which files need some attention.

By the way, anonymous comments are enabled, so you can tell me what features would you like to see from such a litte helper?

Related posts:

  1. C++ tricks, #1: Compile time checks
  2. Code quality notes
  3. C++ tricks, #6: Explicit template instantiation

This entry was posted in Programming and tagged , , . Bookmark the permalink.

4 Responses to Automatic consistency checking

  1. hehejo says:

    Ah, das mal ein nettes Tool.

    Den Check auf “line ending” verstehe ich jetzt zwar nicht – aber ein automatisiertes Newline anhängen würde manchen Gurkenjünger bestimmt glücklich machen.

  2. Anteru says:

    Na obs CR, LF oder CR&LF ist – bei niven check ich ob alles schön mit CR&LF endet.

  3. hehejo says:

    Und es lüppt (mit Mono 1.2.3.1)

  4. Philipp says:

    Ha, klingt ja wirklich lustig… Vor Allem cool, wie du geschrieben hast, dass du das mal schnell geschrieben hast *g*
    Vielleicht sollte man das der bekannten Frau mal zeigen, dann müssten wir in der Vorlesung nicht so aufpassen ;-)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>