Audit Application Code

Use the Audits pane to check and verify your application's code as you develop it.

When you open application artifacts, Visual Builder automatically scans its code and displays errors and warnings (if any) in the Audits pane. You can view details of each issue and take action to resolve it. In addition to JET component errors, the Audits pane displays syntax errors, translation issues, and warnings for missing dependencies.

If an artifact contains errors, it is also badged in the Navigator to indicate that action must be taken to resolve the issue. For example, page errors are indicated by a red dot on the Web Applications icon in the Navigator toolbar as well as against the particular artifact in the Web Apps pane. The badge persists until the error is fixed or until the session ends.

Here's how you can audit your application's code:

  1. Click Audits at the bottom of your browser.

    If the Audits pane displays a message that no artifacts are open, you'll need to open the artifacts you want audited, for example, one or more pages or a .JS file. Here's a quick walkthrough of the results displayed in the Audits pane when artifacts are open (with the active artifact always highlighted):
    Description of audit-results-vb.png follows
    Description of the illustration audit-results-vb.png

    Label Description
    A Options to filter audit results either by text or by severity:
    • Enter text to filter the results based on your search string. For example, you might enter main in the filter text box to search for all issues in the main flow.
    • Use Error, Warning, Info, and ToDo to filter the results by severity. For example, when your application contains errors, you can clear the Warning, Info, and ToDo check boxes to focus on errors.
    B Scope of the audit. By default, only artifacts that are open are audited, for example, the main-create-department-page and main-create-employee-page. To audit the application as a whole, change Audited in from Opened Artifacts to All Artifacts. Any scope change you make is retained for the application, and will persist even if the Audits pane is closed and reopened.
    C Menu with options to edit audit settings or revalidate the entire application.
    D Option to close the Audits pane.
    E Path to the artifact that contains issues, for example, the main-create-department-page under webApps/hrwebapp/flows/main/pages/.
    F Number and type of issues in the artifact, for example, 7 warnings.
    G Message about the issue in the artifact, for example, String not externalized for translation.
    H Line and column number of the issue, for example, (8, 89) indicates that the String not externalized for translation issue exists in line 8, column 89 of the main-create-department-page artifact in Code view.
  2. Decide how you want to resolve the issue. You can choose to resolve an issue directly from its right-click menu or by opening it in the source editor.

    For example, to resolve a translation issue, right-click the issue and select Add to translation bundle:
    Description of audit-rightclickmenu.png follows
    Description of the illustration audit-rightclickmenu.png

    To work with an issue in its source editor, simply click the issue, or select Open in Source Editor in the issue's right-click menu. You can then use code actions suggested in the editor to resolve the issue. For example, for the String not externalized for translation issue, you'll see the same quick fixes suggested in the right-click menu available in the source editor as well:
    Description of audits-resolve-source-editor.png follows
    Description of the illustration audits-resolve-source-editor.png

    Whether you use the right-click fixes or the source editor is entirely up to you, but will mostly depend on the issue you're working with.
    • Resolve the issue, if possible, by selecting the appropriate option in the right-click menu. For example, for the String not externalized for translation issue, select Add to translation bundle.
    • If a resolution isn't available for your issue, select Open in Source Editor to view the issue in the source editor. Hover over the highlighted issue to view problem details and see how you can fix it.

      Note:

      When you're working with code editors (such as Code view in the Page Designer or the JavaScript editor), audit markers show in the file even after you make changes to resolve issues. They disappear only after the file is revalidated and audit results are regenerated, if the issue has been fixed.
    • Optionally, select Do not report this type of defect again to ignore similar defects in future.
    Once you make a choice, your application is rescanned and the audits results updated.

    Tip:

    If you want to copy an issue to your clipboard for further processing, right-click the issue and select Copy to Clipboard. To copy all issues in a particular artifact, use the right-click menu at the artifact level.

Edit Audit Rules

The Audits feature in the Designer includes built-in rules from the Oracle JET Audit Framework (JAF) by referencing the rule pack and the JAF utility (ojaf) hosted on the Content Delivery Network (CDN) at https://static.oracle.com/cdn/jet/.

Every JET release includes the JAF utility and JAF metadata, plus the JAF metadata for previous releases of JET. You can configure the built-in JAF rules to include disabled rules. Custom JAF configurations that deal with the file system, custom rule plug-ins, and so on will not be evaluated because JAF does not execute on the Visual Builder backend; it runs on the client.

Here's how to enable a built-in rule that is disabled by default:
  1. In the Audits pane, click Menu (Menu icon) and select Edit Settings.
  2. Edit the audit.json file in the Source editor, for example, here's the syntax to reference JAF from the CDN and enable a disabled built-in rule:
    {
        "paths": {
            "exclude": [
                "build/**",
                "docs/**",
                "scripts/**",
                "tests/**",
                "**/private",
                "+(web|mobile)Apps/**/resources/components/**/lib/*"
            ]
        },
        "rules": {},
        "auditors": {
            "jaf": {
                "cdnPath": "https://static.oracle.com/cdn/jet/",
                "version": "9.0.0",
                 "jafOptions": {
                    "ruleMods": {
                        "JET": {
                            "oj-css-style-override": {
                                "enabled": true
                            }
                        }
                    }
                }
            }
        }
    }
    

To revert the built-in rules to their default settings, click Reset Settings in the Menu (Menu icon).

For more information about JAF, including the built-in rules that it includes, see About Auditing Oracle JET Applications in Using and Extending the Oracle JET Audit Framework.