Wednesday, April 26, 2017

Cleaning up your code in JDeveloper

Environment / assumptions for this post:
  • JDeveloper 12c
  • jdk7 / 8
I really like to see a little green box in the top of my fragments and source code.
The green All is Clear / No Issues Found indicator
This may be unnecessary and a lot of trouble to achieve, but there are things to be said for it:

  • it forces you to acknowledge and fix potential issues - some examples:
    • ui: deprecated components, such as af:commandButton when going from 11g to 12c
    • ui: 'escape' attribute on af:outputText
    • ui: typos, especially in method names for things like listeners and validators
    • java: unchecked cast and conversions
    • java: convention violations
    • etc 
  • you end up cleaning up as you go - unused variables and methods, unnecessary imports, etc.
  • satisfies one's obsessive-compulsive urge to have clean code with no outstanding little things you have to constantly ignore. :)
There are a few ways to get to the Green Nirvana:
  1. Fixing the actual problem!
  2. Suppressing the warning.
  3. Making JDev not check for the warning

Method 1 - Fix the problem

Nothing to say for this, except don't be lazy! 

Method 2 - Suppress the warning

Suppressing the warning is usually easy, since JDev's code assist will do it for you. 
Suppress a warning with JDev's Code Assist

Method 3 - change JDev's Auditing

Change JDev's auditing. This can be dangerous, but proceed if you are comfortable. In JDev Properties, find Audit, then Manage Profiles. Browse around and deslect what you don't want checked for, then save-as a new profile. Make sure the new profile is selected.
Managing JDev's Audit Profile


No comments:

Post a Comment