varScoper Ant Target example
If you haven't heard of the vaScoper tool created and maintained by Mike Schierberl, it is definately worth checking out. It has the stamp of approval of Raymond Camden and Sean Corfield.
Here is a varScoper ant target recently added to the MXUnit build ant. Download both tools and give them a test drive.
<target name="varScopeCheck" depends="init">
<!— MUST HAVE VARSCOPER IN WEBROOT —>
<echo>Check for unscoped variables</echo>
<!— load the varScoper task —>
<taskdef name="conGet" classname="com.varscoper.ant.task.ConditionalGet" classpathref="project.classpath" />
<property file="${antrunner.file}" />
<property name="filePathToUse" value="${webroot}"/>
<property name="recursiveDirectory" value="true" />
<conGet dest="varScoper.csv" url="http://${server}:${port}/varscoper/varScoper.cfm" >
<parameter name ="filePath" value="${filePathToUse}" />
<parameter name="displayFormat" value ="csv" />
<parameter name="recursiveDirectory" value = "${recursiveDirectory}" />
<!—
<FailIfNotFound pattern="<results></results>" />
<FailIfFound pattern=".cfc" message="var scope violation is found." />
<FailIfFound pattern=".cfm" message="var scope violation is found." />
—>
</conGet>
<!— check csv file for any violations —>
<loadfile srcfile="varScoper.csv" property="varScoper.cvs">
<filterchain>
<headfilter skip="1"/>
<trim/>
</filterchain>
</loadfile>
<!— will be set if violations found else variable will be unset —>
<echo>${varScoper.cvs}</echo>
<fail message="var scope violation is found.">
<condition>
<isset property="varScoper.cvs"/>
</condition>
</fail>
<echo>Successful check for unscoped variables</echo>
</target>
So do I need MXUnit to make use of this? Added to the wiki!