Code standards review with RegEx

On our project we use Macroview to visualise and edit data. The script that drives the proces is subject to our definition of done code standards. A review of the script is a time consuming activity that is leading to frustration in our team. Time to get some tooling support.

First we looked at StyleCop and other static code analysis tools. Since the script language isn’t widely used no of-the-shelve solution was found. We did stumble upon a tool that seemed to use regular expressions. This was an idea worth exploring.

We have a full license to EditPad Pro. This rich text editor has the ability to search with regular expressions. When a match is found, the text is highlighted. In an hour or two we developed some expressions that can be divided in three groups:

  1. Highlight blocks, used to view comment blocks

    regex-codereview-highlight-blocks-comments

    Comment blocks to inspect

  2. Highlight correct, correct used and spelled keywords are highlighted, this was abnormalities are found easy (not highlighted)

    regex-codereview-hightlight-correct-keywords

    Correct cased keywords

  3. Find defects, negative search used for explicit rules, highlighted items are wrong

    regex-codereview-highlight-wrong-naming

    Wrong prefix in name

Using the list of regular expressions sped up the code review and made it more reliable. The code quality has gone up and new code is quickly reviewed. One up for regular expressions. 1up

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development, Tooling and tagged , , . Bookmark the permalink.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.