XML Run Output Schema Reference

This example shows how to create a XML-formatted output file when using the --output-file flag of the code-analyzer run command.

1sf code-analyzer run --output-file results.xml

Sample XML Run Output 

This sample output shows 3 violations with different severities from different engines.

1<?xml version="1.0" encoding="UTF-8"?>
2<results>
3  <runDir>/Users/lisa.simpson/sfdx/coral-cloud-afdx/</runDir>
4  <violationCounts>
5    <total>3</total>
6    <sev1>0</sev1>
7    <sev2>1</sev2>
8    <sev3>1</sev3>
9    <sev4>1</sev4>
10    <sev5>0</sev5>
11  </violationCounts>
12  <versions>
13    <code-analyzer>0.25.1</code-analyzer>
14    <eslint>0.20.1</eslint>
15    <retire-js>0.18.1</retire-js>
16    <regex>0.18.1</regex>
17    <flow>0.18.1</flow>
18    <pmd>0.21.0</pmd>
19  </versions>
20  <violations>
21    <violation>
22      <rule>@lwc/lwc/no-inner-html</rule>
23      <engine>eslint</engine>
24      <severity>2</severity>
25      <tags>
26        <tag>Recommended</tag>
27        <tag>LWC</tag>
28        <tag>Security</tag>
29        <tag>Javascript</tag>
30      </tags>
31      <primaryLocationIndex>0</primaryLocationIndex>
32      <locations>
33        <location>
34          <file>force-app/main/default/staticresources/highlight/highlight/prism.js</file>
35          <startLine>571</startLine>
36          <startColumn>17</startColumn>
37          <endLine>571</endLine>
38          <endColumn>26</endColumn>
39        </location>
40      </locations>
41      <message>Using 'innerHTML/outputHTML/insertAdjacentHTML' is not allowed</message>
42      <resources>
43        <resource>https://github.com/salesforce/eslint-plugin-lwc/blob/v2.1.0/docs/rules/no-inner-html.md</resource>
44      </resources>
45    </violation>
46    <violation>
47      <rule>PreventPassingUserDataIntoElementWithSharing</rule>
48      <engine>flow</engine>
49      <severity>4</severity>
50      <tags>
51        <tag>Recommended</tag>
52        <tag>Security</tag>
53        <tag>Xml</tag>
54      </tags>
55      <primaryLocationIndex>1</primaryLocationIndex>
56      <locations>
57        <location>
58          <file>force-app/main/default/flows/Get_Customer_Details.flow-meta.xml</file>
59          <startLine>90</startLine>
60          <startColumn>1</startColumn>
61          <comment>email.email: Initialization</comment>
62        </location>
63        <location>
64          <file>force-app/main/default/flows/Get_Customer_Details.flow-meta.xml</file>
65          <startLine>41</startLine>
66          <startColumn>1</startColumn>
67          <comment>email.email influences Get_Contact_by_Email_and_Member_Number.Email: flow into recordLookups via influence over Email in run mode SystemModeWithSharing</comment>
68        </location>
69      </locations>
70      <message>User controlled data flows into recordLookups element selector in run mode: SystemModeWithSharing</message>
71      <resources></resources>
72    </violation>
73    <violation>
74      <rule>ApexSharingViolations</rule>
75      <engine>pmd</engine>
76      <severity>3</severity>
77      <tags>
78        <tag>Recommended</tag>
79        <tag>Security</tag>
80        <tag>Apex</tag>
81      </tags>
82      <primaryLocationIndex>0</primaryLocationIndex>
83      <locations>
84        <location>
85          <file>force-app/main/default/classes/ExperienceBookingHelper.cls</file>
86          <startLine>1</startLine>
87          <startColumn>1</startColumn>
88          <endLine>1</endLine>
89          <endColumn>7</endColumn>
90        </location>
91      </locations>
92      <message>Apex classes should declare a sharing model if DML or SOQL/SOSL is used</message>
93      <resources>
94        <resource>https://docs.pmd-code.org/pmd-doc-7.11.0/pmd_rules_apex_security.html#apexsharingviolations</resource>
95      </resources>
96    </violation>
97  </violations>
98</results>

Elements in the Top-Level <results> Element 

ElementData TypeDescription
<runDir>stringThe directory from which the Code Analyzer analysis ran.
<violationCounts>complexTypeContains elements that show the total number of violations and the aggregate counts for each severity level. See <violationCounts> Element for details.
<versions>complexTypeContains elements that show the versions of the core Code Analyzer module and each engine module that ran in the analysis. See <versions> Element for details.
<violations>complexType[]An array of <violation> elements, where each element corresponds to a violation that was detected in the analysis. See <violation> Element for details.

<violationCounts> Element 

ElementData TypeDescription
<total>numberTotal number of violations found in the analysis.
<sev1>numberNumber of severity 1 (Critical) violations found.
<sev2>numberNumber of severity 2 (High) violations found.
<sev3>numberNumber of severity 3 (Moderate) violations found.
<sev4>numberNumber of severity 4 (Low) violations found.
<sev5>numberNumber of severity 5 (Info) violations found.

<versions> Element 

ElementData TypeDescription
<code-analyzer>stringVersion of the core Code Analyzer module.
<cpd>stringVersion of the CPD module.
<eslint>stringVersion of the ESLint module.
<flow>stringVersion of the Flow Scanner module.
<pmd>stringVersion of the PMD module.
<retire-js>stringVersion of the RetireJS module.
<regex>stringVersion of the Regex module.
<sfge>stringVersion of the Salesforce Graph module.

<violation> Element 

ElementData TypeDescription
<rule>stringThe name of the rule that’s associated with the violation.
<engine>stringThe engine that’s associated with the violation.
<severity>numberThe severity level of the violation: 1 (Critical), 2 (High), 3 (Moderate), 4 (Low), 5 (Info)
<tags>string[]An array of elements that contain the tags that are associated with the rule that’s associated with the violation.
<primaryLocationIndex>numberThe index of the primary code location within the code locations array.
<locations>complexType[]An array of <location> elements, where each element corresponds to a location in your code that’s associated with the violation. See location Object Properties for details.
<message>stringThe violation message.
<resources>string[]An array of elements that contain URLs for additional resources and information about the violation.

<location> Element 

Some rules, such as those that have a PathBased tag, can produce multiple code locations. These code locations make up the code path associated with the violation.

Property NameData TypeDescription
<file>stringThe pathname of the file in which the violation occurred, relative to the runDir directory.
<startLine>numberThe line where the violating code starts.
<startColumn>numberThe column in the startLine where the violating code starts.
<endLine>numberThe line where the violating code ends.
<endColumn>numberThe column in the endLine where the violating code ends.
<comment>stringComment that provides additional context associated with this line or block of code.