Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JDeveloper Auditing Framework (UKOUG Tech2013)

4,402 views

Published on

Presentation on Quality Assurance with the JDeveloper Auditing Framework, covering:
- how to use default auditing framework
- creating custom rules and fixes to implement company and project standards
- SuppressWarnings JDeveloper extension to suppresswarnings in XML files
- ADF Code Guidelines JDeveloper extension
- SonarQube plugin for JDeveloper (ojaudit)

Published in: Technology
  • Be the first to comment

JDeveloper Auditing Framework (UKOUG Tech2013)

  1. 1. Quality Assurance JDeveloper Auditing Framework
  2. 2. About Us Richard Olrichs MN www.olrichs.nl @richardolrichs Wilfred van der Deijl The Future Group www.redheap.com @wilfreddeijl
  3. 3. Agenda ● ● ● ● ● ● Audit Profiles and Preferences Audit JDeveloper Extension Project Creating Custom Rules Creating Custom Fixes SuppressWarnings Automated QA
  4. 4. Aborts Compile On Error
  5. 5. ● Applies default Fix ● Run analysis with single (or few) rules ● Example: Generate unique JSF component ID
  6. 6. Custom Rules
  7. 7. Custom Rules ● Setting up JDeveloper Extension Project ● Implementing Custom Rule ● Implementing Custom Fix
  8. 8. Setting up JDev Project
  9. 9. Setting up JDev Extension Project ● Install Extension SDK (Help>CheckForUpdates) ● File > New > Applications > Extension Application ● extension.xml and MANIFEST.MF ● Bundled as .ZIP ● Can be distributed through custom JDeveloper Update Center (aka network drive or URL)
  10. 10. Creating Custom Rules
  11. 11. Analyzing Java Code
  12. 12. Analyzing XML Files
  13. 13. Disables Analyzer for current construct and all children
  14. 14. 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)
  15. 15. ● AuditContext creates Analyzer State Keys ● enter() on root-node (Workspaces) invoked once, so can initialize keys
  16. 16. Creating Custom Fix
  17. 17. 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) ● isQueryRequired(context, construct) and query(context, construct) ○ queries the user for additional info when applying fix
  18. 18. Violation Overload
  19. 19. Violation Overload ● Even ADF Sample Application from OTN has 157 issues ● Too many violations cause developers to ignore all of them
  20. 20. Violation Overload
  21. 21. SuppressWarnings Java Annotation @SuppressWarnings annotation introduced in Java 1.5 and tells Java Compiler to suppress warnings
  22. 22. SuppressWarnings Java Annotation JDeveloper 12c now also “listens” to annotation and suppresses warnings itself (not only javac)
  23. 23. JDeveloper 12c Suppression Schemes
  24. 24. JDeveloper 12c Suppression Scheme Why not create our own for non-Java (aka XML)?
  25. 25. Suppress Warnings in XML
  26. 26. Suppress Warnings in XML
  27. 27. 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
  28. 28. Analyzer - Suppressing violations
  29. 29. Transform - Creating XML Comment
  30. 30. Audit Extension Project
  31. 31. Audit Extension Project ● Project standards ● Company standards ● Community standards
  32. 32. Audit Extension Project
  33. 33. ADF EMG Extension Project
  34. 34. ADF Code Guidelines Extension ● JDeveloper extension available today ● ADF Code Guidelines auditing during development ● Community project at java.net: adfemgauditrules ● Contribute and discuss at ADF EMG ● JDeveloper 12c only ○ at least for now. No reason why this can’t be backported to JDeveloper 11g
  35. 35. Automated QA
  36. 36. OJAudit ● Command line auditing ● JDEV_HOME/jdev/bin/ojaudit -help ● Output in XML/text/HTML or custom xsl
  37. 37. 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
  38. 38. Automated QA SonarQube
  39. 39. 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
  40. 40. ADF EMG SonarQube plugin ● SonarQube plugin ○ runs ojaudit ○ converts ojaudit output to SonarQube violations ● ● ● ● 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
  41. 41. Further Reading ● www.olrichs.nl ● www.redheap.com ● ADF Enterprise Methodology Group ○ Google Groups ● http://docs.oracle.com JDeveloper Doc (not ADF documentation) ○ Developing Extensions for JDeveloper ○ Java API Reference for Extension SDK
  42. 42. Summary ● ● ● ● ● ● Audit Profiles and Preferences Creating Custom Rules Creating Custom Fixes SuppressWarnings JDev Extension ADF Code Guidelines JDev Extension SonarQube ojaudit plugin

×