Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for static and dynamic analyzer tools.
https://codechecker.readthedocs.io
Apache License 2.0
2.27k stars 383 forks source link

Get analyzer statistics from CodeChecker storage using cli #1796

Closed polskikh closed 6 years ago

polskikh commented 6 years ago

I need to get information about analyzer statistics (successful, failed). At the moment I can get this information only from metadata.json file, right?

But what if I want to get this information from storage using CLI? Because this information is stored and I can see it in UI.

Because I have cases when I need to get this information and pass it to another service (for example for dashboards). And I don't have CodeChecker artifacts (metadata.json)

What do you think about it?

whisperity commented 6 years ago

(By all means, DO NOT RELY ON metadata.json, IT'S FORMAT OR CONTENTS! That is an internal artifact that is only used to carry CodeChecker-specific information (that is not the actual bug reports) between the "facades" of CodeChecker (log -> analyze -> parse/store).)

I've been out of the loop regarding CodeChecker, but if the web GUI really shows the number of failed files (it didn't back when I was around :slightly_smiling_face: ) then you could try obtaining a machine-readable JSON run information via CodeChecker cmd runs -o json --url [...].

polskikh commented 6 years ago

@whisperity CodeChecker cmd runs -o json --url will return just this information:

{
    "REPORT_NAME": {
      "detectionStatusCount": {
      },
      "runDate": "2018-11-01 15:10:57.108259",
      "name": "REPORT_NAME",
      "versionTag": "TAG",
      "runCmd": "CodeChecker.py check -b make -o output_folder -j 10 --ctu",
      "runId": 49,
      "duration": 1521,
      "resultCount": 2089
    },
}

Ok, If I shouldn't read metadata.json, how can I get clangsa and clang-tidy stats? Search in stdout?

We use codechecker 6.7.1 as CLI and 6.8 as server

whisperity commented 6 years ago

Analyzer statistics as a feature (https://github.com/Ericsson/codechecker/commit/b5b815b2a767dabb405e2ce4b195bb2166f66896) was introduced in release 6.8. Please update your CLI.


The getRunData function returns a RunDataList, in which each element contains an analyzer statistics data field:

https://github.com/Ericsson/codechecker/blob/94ef62f36f2f1ebc9832e5d35669db741f2d69a8/api/v6/report_server.thrift#L128-L139

https://github.com/Ericsson/codechecker/blob/94ef62f36f2f1ebc9832e5d35669db741f2d69a8/api/v6/report_server.thrift#L119-L126

The JSON output should show these fields.

If you don't request the JSON output, you also should see this value:

https://github.com/Ericsson/codechecker/blob/94ef62f36f2f1ebc9832e5d35669db741f2d69a8/libcodechecker/cmd/cmd_line_client.py#L237-L252

polskikh commented 6 years ago

Hi @whisperity , it's awesome!

I think we can close this issue

Thanks for the help and your time! 🙂