Difference between revisions of "Code Cleanup"

From BRL-CAD
(add a section on code reduction and using simian)
(swap the order so lays out better)
Line 4: Line 4:
  
  
=Coverity Scan=
+
=The HACKING File=  
  
[[Image:CoverityExample3.png|right|256px|... showing pretty awesome detection of a potentially uninitialized variable use]]
+
Our tried and true [http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/HACKING?revision=HEAD developer guidelines HACKING file] identifies numerous stylistic concerns and source code conventions that the entire BRL-CAD source code should conform to.  When in doubt, consult the dev guidelines.
 
 
Since 2006, BRL-CAD has been a participant in the [http://scan.coverity.com/ Coverity Scan Initiative], an effort funded by the U.S. Department of Homeland Security to improve the quality, safety and [http://en.wikipedia.org/wiki/Open_source_software_security security] of open source software.  Coverity performs a static source code analysis (one of the best) and generates a detailed report of issues detected.
 
 
 
The BRL-CAD scan was previously "stuck" but we're now back online and operational!  For an interesting preview of some of the kinds of things reported, here are some screenshots:
 
 
 
[[Image:CoverityExample1.png|left|256px|... showing a potential (albeit unlikely) NULL dereference]]
 
 
 
[[Image:CoverityExample2.png|none|256px|... showing secure coding practice suggestions]]
 
 
 
 
 
Those and many other issues are all managed through a private website that is only accessible if you have an account.  If you're going to help, fantasticGet in touch with a developer to have your account created.
 
 
 
'''''PLEASE don't bother inquiring if you're only interested in looking at results or poking around.'''''
 
 
 
We'll probably have you fix an issue or two first to make sure you're serious.
 
  
  
Line 47: Line 32:
  
  
=The HACKING File=
+
=Coverity Scan=
 +
 
 +
[[Image:CoverityExample3.png|right|256px|... showing pretty awesome detection of a potentially uninitialized variable use]]
 +
 
 +
Since 2006, BRL-CAD has been a participant in the [http://scan.coverity.com/ Coverity Scan Initiative], an effort funded by the U.S. Department of Homeland Security to improve the quality, safety and [http://en.wikipedia.org/wiki/Open_source_software_security security] of open source software.  Coverity performs a static source code analysis (one of the best) and generates a detailed report of issues detected.
 +
 
 +
The BRL-CAD scan was previously "stuck" but we're now back online and operational!  For an interesting preview of some of the kinds of things reported, here are some screenshots:
 +
 
 +
[[Image:CoverityExample1.png|left|256px|... showing a potential (albeit unlikely) NULL dereference]]
 +
 
 +
[[Image:CoverityExample2.png|none|256px|... showing secure coding practice suggestions]]
 +
 
 +
 
 +
Those and many other issues are all managed through a private website that is only accessible if you have an account.  If you're going to help, fantastic.  Get in touch with a developer to have your account created.
 +
 
 +
'''''PLEASE don't bother inquiring if you're only interested in looking at results or poking around.'''''
  
Our tried and true [http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/HACKING?revision=HEAD developer guidelines HACKING file] identifies numerous stylistic concerns and source code conventions that the entire BRL-CAD source code should conform to.  When in doubt, consult the dev guidelines.
+
We'll probably have you fix an issue or two first to make sure you're serious.

Revision as of 13:29, 11 April 2011

The BRL-CAD source code is large with a lot of history. In order to survive decades of development, considerable time and attention is put forth towards improving code maintainability and code quality. One of the best ways to get involved in BRL-CAD open source development is to help clean up source code.

Cleaning up the source code helps you become familiarized with BRL-CAD and improves maintainability. There are a variety of ways you can clean up source code, but some of our specific efforts in place to help refactor BRL-CAD are:


The HACKING File

Our tried and true developer guidelines HACKING file identifies numerous stylistic concerns and source code conventions that the entire BRL-CAD source code should conform to. When in doubt, consult the dev guidelines.


Duplication Reduction

As BRL-CAD's source code is large, another way to clean up code is to reduce the inevitable duplication that results after years of development. There has been considerable success in the past using the Simian similarity analyser. This shell script snippet should provide a reasonable analysis of BRL-CAD's core source code:

#!/bin/sh
export files=`find . \( -name \*.h
                        -o -name \*.c
                        -o -name \*.cxx
                        -o -name \*.cpp
                        -o -name \*.tcl
                        -o -name \*.itcl
                        -o -name \*.itk
                        -o -name \*.tk \)
                     -not -regex '.*src/other.*'
                     -not -regex '.*misc.*'
                     -not -regex '.*libfft.*'
                     -not -regex '.*src/mged/points/.*'
                     -not -regex '.*src/tab/.*'`
java -Xms200m -Xmx2000m -jar simian-2.2.24.jar -threshold=25 $files

You'll of course probably need to change the version number from 2.2.24 to whatever version you downloaded. Once you get the output report, focus attention on refactoring the largest or most frequently duplicated code into reusable functions. Submit patches or commit changes accordingly.


Coverity Scan

... showing pretty awesome detection of a potentially uninitialized variable use

Since 2006, BRL-CAD has been a participant in the Coverity Scan Initiative, an effort funded by the U.S. Department of Homeland Security to improve the quality, safety and security of open source software. Coverity performs a static source code analysis (one of the best) and generates a detailed report of issues detected.

The BRL-CAD scan was previously "stuck" but we're now back online and operational! For an interesting preview of some of the kinds of things reported, here are some screenshots:

... showing a potential (albeit unlikely) NULL dereference
... showing secure coding practice suggestions


Those and many other issues are all managed through a private website that is only accessible if you have an account. If you're going to help, fantastic. Get in touch with a developer to have your account created.

PLEASE don't bother inquiring if you're only interested in looking at results or poking around.

We'll probably have you fix an issue or two first to make sure you're serious.