Jdeveloper Auditing Framework
Jdeveloper Auditing Framework
About Us
Richard Olrichs MN www.olrichs.nl @richardolrichs Wilfred van der Deijl The Future Group www.redheap.com @wilfreddeijl
Agenda Audit Profiles and Preferences Audit JDeveloper Extension Project Creating Custom Rules Creating Custom Fixes SuppressWarnings Automated QA
Applies default Fix Run analysis with single (or few) rules Example: Generate unique JSF component ID
Custom Rules
Custom Rules Setting up JDeveloper Extension Project Implementing Custom Rule Implementing Custom Fix
AuditContext Provides Traversal State report() for Violations, Metrics, Suppressions Holds State for Analyzer
Setting Attributes for Child Constructs Setting Attributes for Parent Construct (Sharing Attributes between Analyzers)
AuditContext creates Analyzer State Keys enter() on root-node (Workspaces) invoked once, so can initialize keys
Transform subclass
apply(context, construct)
applies fix by changing source TransformContext argument contains editor location, violation, etc Construct is the object with the violation (eg. a JavaMethod or XMLElement)
Violation Overload
Violation Overload
Even ADF Sample Application from OTN has 157 issues Too many violations cause developers to ignore all of them
Violation Overload
@SuppressWarnings annotation introduced in Java 1.5 and tells Java Compiler to suppress warnings
JDeveloper 12c now also listens to annotation and suppresses warnings itself (not only javac)
SuppressWarnings
JDeveloper 12c natively supports @SuppressWarning in Java JDev extension adds <!-- SuppressWarning --> Extension available today JDeveloper 12c only as Suppression Schemes is new 12c feature
Automated QA
OJAudit
Command line auditing JDEV_HOME/jdev/bin/ojaudit -help Output in XML/text/HTML or custom xsl
Automated QA
Simple solution: Run ojaudit from CI server and publish output Benefit: Same rules during development and CI QA @SuppressWarnings and <!--SuppressWarning--> keep list of violations short and actionable
Automated QA
SonarQube
SonarQube
Tool to manage Code Quality Rules, Violations, Metrics, Test Coverage, etc Free Open Source Initially Java, but now 20+ languages Historical data, thus trends Highly extensible through plugins
www.sonarqube.com for base product Watch ADF EMG for availability of plugin Not specific to ADF, but for any JDev project Tested with JDeveloper 12c, but should work with any version
Further Reading
www.olrichs.nl www.redheap.com ADF Enterprise Methodology Group
Google Groups
Summary Audit Profiles and Preferences Creating Custom Rules Creating Custom Fixes SuppressWarnings JDev Extension ADF Code Guidelines JDev Extension SonarQube ojaudit plugin