Finding resource issues
Static code scanning comes into its own when you are able to look beyond simple pattern matching to being able to deeply parse and understand the code.
There are many types of bugs or issues that are easy for developers to find and easy to fix. Such as methods being correctly named, or variables being correctly named or keywords in the right case.
These bugs are often easy and repetitive to fix, but it is very do-able.
When looking through a method, it takes a bit more effort, but developers can still find issues such as unused variables. It just takes more time and the developer needs to be more vigilant.
Even more complicated or difficult to find issues, such as unused methods (or an unused message map), where you would need to need to scan the whole file, and then every other file in your source code repository can be found with a bit of time and a good text editor.
Where static code analysis comes into it's own is when it can find things that developers can't find with their own eyes. Or can't find with a text search.
Static code analysis can work through different paths in the code, and it can dig deeper into the code then any developer can. It can start from one procedure or function and find all the others that are called.
In the case of our latest new rule, we scan through each message flow file and see which ones have compute nodes. For each of those compute nodes we find what code is being called. For each of the procedures it finds, we then check what procedures it calls.
In the end we can start from a compute node, navigate through all the ESQL and determine whether a database connection is used. If we cannot find the database being used, then we can flag an issue against the code - R370 - The compute node has a datasource set but it does not access the database (WMB). By preventing this redundant database usage, the developer can prevent the creation on needless database connections, which is slow and inefficient.
If you are interested in finding out more this rule, our product or were interested in a demonstration, please drop me an email to:
Richard@bettercodingtools.com
Or contact me via the contact page on our website.
Regards
Richard
Richard@bettercodingtools.com
www.bettercodingtools.com