Add new comment

Introducing Project QA

Ever wish there was a better way to keep an eye on a project you’re working on? After being inspired by a presentation at Drupalcon Portland called “Development, By the Numbers” I decided to create a Drupal module to help automate the code evaluation process: Project QA.

This is part 1 of a 3 part series overviewing the Project QA Drupal module:

  1. Introducing Project QA
  2. Project QA: Writing a submodule
  3. Project QA: With great power

Don’t want to read? Skip ahead, there’s a video introduction and demo.

Overview

At its heart, Project QA is a Drupal module that scans git repos and offers hooks for processing them. By itself, Project QA does not evaluate your code at all.

When you tell Project QA to scan a repo, it checks the repo out locally (or updates it if it already has a copy from a previous run), and then begins stepping backwards through the git history one commit at a time. A record of the commit is saved, including the commit hash, the timestamp of the commit, and the author of the commit. After each commit is checked out, a hook is fired to allow submodules to act on the repo in its current state. After all commits have been processed, Project QA evaluates the existing tags in the repo and matches them up with the imported commits.

It is pretty generic, except for one major condition: every action or piece of data is always linked back to a specific git commit. The code being evaluated doesn’t need to be Drupal code, or even PHP code; as long as it exists in a git repo you can access.

Submodules

The real fun begins when you consider submodules. With this initial release I’ve included one submodule based on the PHPLOC tool. PHPLOC “is a tool for quickly measuring the size and analyzing the structure of a PHP project.” One of its great strengths is measuring cyclomatic complexity alongside a host of stats about the number of files, methods, lines of code, comments, etc.

The PHPLOC submodule uses the Project QA hook to run on every commit in a repository’s history. All data is saved into custom entities, as well as delta information between git commits for faster and easier reporting. All of this information is exposed to views so writing custom reports is easy.

Some report ideas include:

  • Who is introducing the most complexity (for good or bad)?
  • Is code being checked in regularly during a project?
  • How does a particular module stack up against others?
  • Are your developers commenting their code enough?
  • Were there any major changes or spikes in the history of the code, indicating things such as a bad merge, extra modules or files, or maybe an onslaught of sloppy or duplicate code?

Plans

I have plans for implementing submodules to run other PHP tools like the copy-paste detector, mess detector, and perhaps even code sniffer. Beyond that I’d love to see JavaScript evaluations taking place in submodules as well. I’ve also wanted to make this as easy as possible for writing your own reports but know that including some default common reports to get you started is beneficial as well. In that vein, if you have suggestions let me know!

You can check out the project page on Drupal.org or even see a live demo over at projectqa.nateofnine.com.

Demo

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Filtered HTML

  • Use [acphone_sales], [acphone_sales_text], [acphone_support], [acphone_international], [acphone_devcloud], [acphone_extra1] and [acphone_extra2] as placeholders for Acquia phone numbers. Add class "acquia-phones-link" to wrapper element to make number a link.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <h4> <h5> <h2> <img>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.