5 Work with the Output of Audits
You can customize the Oracle JAF configuration to tailor the output for your needs.
About Audit Output
Apart from specifying the scope of the audit by using Oracle JAF configuration properties such as files, excludes, severity, groups, ruleNames, ruleMods, you can also customize the format of the output.
Oracle JAF provides these ways to customize the output of the audit report:
-
The format of reported issues can be customized by using the proseFormat configuration property. You can also add a custom report title by using the title configuration property.
- You can specify that the output format be JSON by using the format and outPath configuration properties, and then you can process this JSON to create any desired output. For example, HTML could be generated for web use, or perhaps other information could be injected into the output and the resulting file distributed in email.
Display Details About a Rule
You can use the rule name or rule message ID from the audit results to obtain a description of the rule.
[71, 41] <oj-list-view> attribute 'selection' is deprecated!
Use selected attribute instead. [JET-0080 : oj-html-ojattr-deprecated]
ojaf --help
. ojaf --help oj-html-ojattr-deprecated
Rule: oj-html-ojattr-deprecated Severity: major
JET component deprecated attributes should not be used.
Alternatively, if you know the message ID, you can obtain the rule name and rule description:
ojaf --help JET-0080
Rule: oj-html-ojattr-deprecated Severity: major
JET component deprecated attributes should not be used.
Note:
To get rule help, you must run ojaf --help
from the directory that contains your application's oraclejafconfig.json
file. By default this is the root of the application.
For more information about enabling rule names to display in audit results, see Display Rule Names with Audit Messages.
Toggle the Default Format of Audit Messages
Use the optional Oracle JAF configuration file property format to specify the default display format for audit messages.
You can set the JAF configuration file format property to prose or to line to toggle the default presentation of audit messages between these two styles. The prose format displays audit messages in a report style, while the line format flattens out audit messages into single lines.
You can also customize the presentation for audit messages in either style by applying custom templates that you create, as describe in Customize the Presentation of the Audit Messages.
Display Rule Names with Audit Messages
You can enable Oracle JAF to append the corresponding rule name to reported audit messages and you can use the rule name to return a description of the rule.
[71, 41] <oj-list-view> attribute 'selection' is deprecated!
Use selected attribute instead. [JET-0080 : oj-html-ojattr-deprecated]
ojaf --help
. ojaf --help oj-html-ojattr-deprecated
Rule: oj-html-ojattr-deprecated Severity: major
JET component deprecated attributes should not be used.
Alternatively, if you know the message ID, you can view the rule name with the rule description:
ojaf --help JET-0080
Rule: oj-html-ojattr-deprecated Severity: major
JET component deprecated attributes should not be used.
Note:
To get rule help, you must run ojaf --help
from the directory that contains your application's oraclejafconfig.json
file. By default this is the root of the application.
Customize the Presentation of the Audit Messages
Use the optional Oracle JAF configuration file properties proseFormat and lineFormat to define templates to redefine the presentation of reported audit issues.
If the JAF configuration file format property is set to prose or to line, you can use the respective properties proseFormat and lineFormat to define a custom presentation template to format the displayed audit issues.
A prose-formatted
audit message begins with the text Audit for
.

Description of the illustration audit_lineformat.png
Here is a line-formatted audit message with different template.

Description of the illustration audit_proseformat.png
If you omit proseFormat, Oracle JAF uses the default template,
"%pos1 %s : %m"
, which displays as follows:
Specify the template for the properties as a string, containing any of the following tokens in any order. JAF replaces the tokens in the audit message output at runtime.
Audit Message Tokens | Replacement Value |
---|---|
%l | The line number only. |
%c | The column number only. |
%pos1 | The comma-separated line and column number with
square brackets. For example: [46, 25] |
%pos2 | The comma-separated line and column number with
parens. For example: (46, 25) |
%s | The severity level of the processed rule. |
%m | The entire audit issue message. |
%mid | The full audit message ID. For example,
JET-1234 |
%p | The prefix of the rule set. For example,
JET for the built-in JET rule set.
|
%n | The audit message number only. For example,
1234 |
%r | The rule name. |
%f | The file path. |
Format a Title for the Audit Report
You can use the optional Oracle JAF configuration title property create a title for audit reports.
If the JAF configuration file format property is set to prose (the default), you can use the title property to format a title header to display with the audit output. The title definition may include tokens to insert values, such as the Oracle JET version into the title.
Audit Title Tokens | Replacement Values |
---|---|
$jafdate | The current date, like "Friday Feb 14, 2020". |
$jaftime | The current time, like "8:05am EDT". |
$jetver | The Oracle JET version, like "8.1.0". |
%jafver | The Oracle JAF version, like "2.4.0". |
%jafconfig | The file path for the Oracle JAF configuration file used in the audit, like "D:\myproject\oraclejafconfig.json". |
Output Audit Messages in JSON Format
Use the optional Oracle JAF configuration file property format to specify that the output format of the audit to be a JSON document. You can then process the JSON to create any desired output.
If the JAF configuration file property format is set to json, you can generate the output of the audit in JSON format. You can direct JAF to output the JSON document to the desired directory by defining the JAF configuration property outPath.
The output of the JSON is structured as follows.
JSON Section | Description |
---|---|
reported | An array object for each audited file containing an array of reported issue objects. |
summary | An object containing summary data such as the number of issues found or the number of files processed, for example. |
run | An object containing run data such as run date/time and JET version number. |
descriptions | An optional object containing rule descriptions for the issues in the reported section. Must be configured by using the JAF configuration property ruleDescriptions, as described below. |
fileset | An optional object containing the file set processed by the audit. Must be configured by using the JAF configuration property addFileList, as described below. |
This is an abbreviated sample of typical JSON output for reported issue.
{
"reported": [
{
"file": "/tests/rules/oj-html-binding-attr/binding-foreach_FAIL_2.html",
"issues": [
{
"severity": "minor",
"msg": "Use of attribute 'id' is meaningless for binding element <oj-bind-for-each>",
"msgId": "JET-0015",
"position": {
"row": 14,
"col": 12,
"start": 467,
"end": 482
},
"rule": "oj-html-binding-attr"
}
]
},
. . .
],
"summary": {
"severities": {
"blocker": 0,
"severity": 0,
"major": 0,
"minor": 0,
"info": 1
},
"issues": 1,
"issueFiles": 1,
"errorFiles": 0,
"parseErrors": 0,
"errors": 0,
"warnings": 1,
"asserts": 0,
"files": 1,
"urls": 0,
"rulesActive": 64,
"rulesFired": 41,
"hooksFired": 15
},
"run": {
"date": "Tues, 14 April 2020 15:52:39 GMT",
"jetversion": "8.1.0",
"title" : "Testing",
"config": "d:\\runAudit\\testing_config.json"
}
}