codechecker icon indicating copy to clipboard operation
codechecker copied to clipboard

Missing key 'extended_message' in Clang SA plist report (Sonar)

Open aallrd opened this issue 3 years ago • 2 comments

Hello,

This is going to be a weird issue, because everything works wonderfully well, thank you for CodeChecker 👍

I am using CodeChecker 6.18.0 on my codeline to run the Clang SA, and I am successfully able to analyze/parse/store the generated report on our CodeChecker server. Some people in my organization are running a SonarQube instance and wanted to experiment if we could push the CodeChecker reports to the Sonar server. Since the CodeChecker analyze output is in the plist format, it seemed like a straightforward task but we got this error when processing the files with Sonar:

The 'Clang Static Analyzer' report is invalid, report='test.cpp_clangsa_688478000a3dff762587d71f676dfe9f.plist'
cause='IllegalArgumentException: Missing mandatory entry 'extended_message'', skipping

I could find examples of plist with this key extended_message in the codechecker codeline on Github, but it is not really clear to me if this is a mandatory entry in the report structure (and there is a bug), or it's not mandatory (or deprecated) and Sonar is wrong expecting this key.

Do you have a clue maybe?

aallrd avatar Feb 21 '22 13:02 aallrd

I compared the plist reports from the Clang SA from CodeChecker and scan-build on the same source file. The reports show the same diagnostic but the CodeChecker one is missing the extended_message key:

  • CodeChecker generated plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>diagnostics</key>
	<array>
		<dict>
			<key>category</key>
			<string>Unused code</string>
			<key>check_name</key>
			<string>deadcode.DeadStores</string>
			<key>description</key>
			<string>Value stored to 'pc' is never read</string>
			<key>issue_hash_content_of_line_in_context</key>
			<string>7158da36ad0e68ee70a4dcadca396eed</string>
			<key>location</key>
			<dict>
				<key>col</key>
				<integer>7</integer>
				<key>file</key>
				<integer>0</integer>
				<key>line</key>
				<integer>130</integer>
			</dict>
			<key>path</key>
			<array>
				<dict>
					<key>depth</key>
					<integer>0</integer>
					<key>kind</key>
					<string>event</string>
					<key>location</key>
					<dict>
						<key>col</key>
						<integer>7</integer>
						<key>file</key>
						<integer>0</integer>
						<key>line</key>
						<integer>130</integer>
					</dict>
					<key>message</key>
					<string>Value stored to 'pc' is never read</string>
					<key>range</key>
					<array>
						<dict>
							<key>col</key>
							<integer>13</integer>
							<key>file</key>
							<integer>0</integer>
							<key>line</key>
							<integer>130</integer>
						</dict>
						<dict>
							<key>col</key>
							<integer>13</integer>
							<key>file</key>
							<integer>0</integer>
							<key>line</key>
							<integer>130</integer>
						</dict>
					</array>
				</dict>
			</array>
		</dict>
	</array>
	<key>files</key>
	<array>
		<string>/source.c</string>
	</array>
	<key>metadata</key>
	<dict>
		<key>analyzer</key>
		<dict>
			<key>name</key>
			<string>clangsa</string>
		</dict>
		<key>generated_by</key>
		<dict>
			<key>name</key>
			<string>CodeChecker</string>
			<key>version</key>
			<string>6.18.0</string>
		</dict>
	</dict>
</dict>
</plist>
  • scan-build generated plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>clang_version</key>
<string>clang version 13.0.0</string>
 <key>diagnostics</key>
 <array>
  <dict>
   <key>path</key>
   <array>
    <dict>
     <key>kind</key><string>event</string>
     <key>location</key>
     <dict>
      <key>line</key><integer>130</integer>
      <key>col</key><integer>7</integer>
      <key>file</key><integer>0</integer>
     </dict>
     <key>ranges</key>
     <array>
       <array>
        <dict>
         <key>line</key><integer>130</integer>
         <key>col</key><integer>13</integer>
         <key>file</key><integer>0</integer>
        </dict>
        <dict>
         <key>line</key><integer>130</integer>
         <key>col</key><integer>13</integer>
         <key>file</key><integer>0</integer>
        </dict>
       </array>
     </array>
     <key>depth</key><integer>0</integer>
     <key>extended_message</key>
     <string>Value stored to pc is never read</string>
     <key>message</key>
     <string>Value stored to pc is never read</string>
    </dict>
   </array>
   <key>description</key><string>Value stored to pc is never read</string>
   <key>category</key><string>Unused code</string>
   <key>type</key><string>Dead increment</string>
   <key>check_name</key><string>deadcode.DeadStores</string>
   <!-- This hash is experimental and going to change! -->
   <key>issue_hash_content_of_line_in_context</key><string>7158da36ad0e68ee70a4dcadca396eed</string>
  <key>issue_context_kind</key><string>function</string>
  <key>issue_context</key><string>Sys_ImpMDATE</string>
  <key>issue_hash_function_offset</key><string>29</string>
  <key>location</key>
  <dict>
   <key>line</key><integer>130</integer>
   <key>col</key><integer>7</integer>
   <key>file</key><integer>0</integer>
  </dict>
  <key>ExecutedLines</key>
  <dict>
   <key>0</key>
   <array>
    <integer>130</integer>
   </array>
  </dict>
  </dict>
 </array>
 <key>files</key>
 <array>
  <string>/source.c</string>
 </array>
</dict>
</plist>

It seems that the CodeChecker plist contains less keys than the scan-build one. Are they filtered somehow?

aallrd avatar Feb 23 '22 15:02 aallrd

Could you please share the reproducer c++ file? Also the clang --version would help a lot.

I tried to reconstruct a dead store example according to your first plist, but I still end up having the extended_message field in the report: https://godbolt.org/z/GTKKajcvY

steakhal avatar Apr 28 '22 15:04 steakhal