Jan 2, 2019 3:48:45 PM by Dan Hotka
I recently did one of my Lunch N Learn webinars (Mondays at 12:15…see my website to get on the list for these…and to see the replay) on this Toad Code Review. Goes without saying that I just love this feature.
IF I were regularly programming, I’d definitely attach one of these reports (see below) to my completed work. This will show that my code is clean and complies with the rules setup in this area of Toad (the rules are easily visible and adjustable).
This report shows 4 main areas across the top of the interface I would like as a manager:
A manager can use this simple scale when assigning resources to the project and to quickly see the status of a current project or an overall rating of a completed project.
Programmers can use this same information to make a baseline of the status of code they are about to start on to be compared with the same report items once the project is complete. This information can be used to help programmers make sure they don’t miss any bad or invalid code.
People evaluating software packages based in Oracle code can use this as another metric to compare the code among the solutions being considered.
To use: Database > Diagnose > Code Review.
Open the code from the file system or from the database. The green button to the left of the open buttons runs the analysis on the selected items. To the right of the open buttons are the rule buttons…shows the rules being used and allowing the rules to be edited. The output report can be saved.
My recommendation is for programmers to submit this final report with their completed project.
The main interface allows you to open and analyze individual program units or packages. You can open a variety of program units but the Report (on the Report tab, lower left panel) will be more general.
When these reports are run against single program units or single packages, the report contains a considerable more amount of detail.
The report identifies program modules that contain SQL and what that SQL does: ‘CRUD’…create/retrieve/update/delete from the database.
The Toad Code Rating is a scale of 1 to 4 where 1 is good and 4 is the worst. Just a simple rating with the following analysis giving far more detail.
The Halstead Volume is calculation/code function complexity. Items considered are any calculation, length of the calculation, flow logic, depth of flow logic, etc. The Report tab shows all the detail being considered.
0 – 1000 - an average programmer should be able to comprehend and maintain
1001 – 3000 - code is more challenging and would take more skills to comprehend and change content
> 3000 – too complex. Redesign this module.
McCabe’s Cyclomatic Complexity is a different and simpler metric for identifying program unit complexity
1 – 10 – Simple program
11 – 20 – More complex program
21 – 50 - complex program
>50 – untestable program
My personal favorite: The maintainability Index (MI). How maintainable is the code. This metric considers the output of both the Halstead and McCabes complexity scales.
0 – 64 - difficult to maintain
65 – 84 – moderate maintainability
>85 – easy to maintain
You can call upon Toad Help (Code Analysis) for assistance in running these reports. I would load this up and run the reports one at a time against each code module (procedure, function, or package) in an application or a programming assignment. The various results can easily be sorted by clicking on the heading of each report.
I find these reports useful. I hope you do as well.
Tags: Toad for Oracle
Written by Dan Hotka
Dan Hotka is an Author/Instructor/Expert/Oracle ACE Director Alumni who uses TOAD regularly in his web-based and on-line courses. He is well published with many books still available on Amazon or www.DanHotka.com. Dan is available for user groups and company educational events. He regularly speaks at user groups around the world. Check his website for course listings, references, and discount codes for his online courses based in Safari.
Dan's most recent book is Toad for Oracle Unleashed