52
Quality Assurance Enforcing Code Guidelines by Extending JDeveloper’s Auditing Framework

Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Embed Size (px)

DESCRIPTION

Quality Assurance doesn’t always get the attention it needs during a project. Maintaining and enforcing organization defined quality rules can be seen as a chore. Having code quality audited while coding is much more efficient than manually peer reviewing afterwards. We will not only demonstrate the powerful Oracle JDeveloper built-in auditing tools, but will also show how to extend it with your own auditing rules, create your own automated code fixes, and how to integrate automated auditing with your build automation. This session shows JDeveloper’s Auditing features and other free tools to enable you and your team to consistently deliver high quality code whether it is ADF, SOA, BPM or any other technology supported by JDeveloper.

Citation preview

Page 1: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Quality Assurance Enforcing Code Guidelines by Extending JDeveloper’s Auditing Framework

Page 2: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

About Us

Richard Olrichs

MN

www.olrichs.nl

@richardolrichs

Wilfred van der Deijl

The Future Group

www.redheap.com

@wilfreddeijl

Page 3: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Agenda

● Audit Profiles and Preferences

● Audit JDeveloper Extension Project

● Creating Custom Rules

● SuppressWarnings

● ADF EMG Audit Rules

● Automated QA

Page 4: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 5: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Aborts Compile On Error

Page 6: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 7: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 8: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 9: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 10: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 11: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 12: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 13: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Custom Rules

Page 14: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Custom Rules

● Setting up JDeveloper Extension

Project

● Implementing Custom Rule

● Implementing Custom Fix

Page 15: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

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)

Page 16: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 17: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 18: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 19: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 20: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 21: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Violation Overload

Page 22: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 23: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Violation Overload

● Even ADF Sample Application from OTN

has 157 issues

● Too many violations cause developers to

ignore all of them

Page 24: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Violation Overload

Page 25: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

SuppressWarnings Java Annotation

@SuppressWarnings annotation introduced in

Java 1.5 and tells Java Compiler to suppress

warnings

Page 26: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

SuppressWarnings Java Annotation

JDeveloper 12c now also “listens” to annotation

and suppresses warnings itself (not only javac)

Page 27: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

JDeveloper 12c Suppression Scheme

Why not create our own for non-Java (aka XML)?

Page 28: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Suppress Warnings in XML

Page 29: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Suppress Warnings in XML

Page 30: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 31: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 32: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

ADF EMG Audit Rules

Page 33: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 34: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 35: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 36: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 37: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

ADF Code Guidelines Extension

● JDeveloper extension available today

● ADF Code Guidelines auditing during

development

● Community project at java.net: adfemg-

auditrules

● Contribute and discuss at ADF EMG

● JDeveloper 12c & JDeveloper 11g

Page 38: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Automated QA

Page 39: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

OJAudit

● Command line auditing ● JDEV_HOME/jdev/bin/ojaudit -help

● Output in XML/text/HTML or custom xsl

Page 40: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 41: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

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

Page 42: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Automated QA

SonarQube

Page 43: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 44: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

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

Page 45: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 46: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 47: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 48: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs
Page 49: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

ADF EMG SonarQube plugin

● SonarQube plugin o runs ojaudit

o 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

Page 50: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs

Summary

● Audit Profiles and Preferences

● Creating Custom Rules

● SuppressWarnings JDev Extension

● ADF EMG Audit Rules Extension

● SonarQube ojaudit plugin

Page 52: Enforcing code guidelines by extending j developer’s auditing framework - Oracle OpenWorld Preview AMIS - Richard Olrichs