Repository: ericsson/codechecker
Issue: CodeChecker analyze does not show analysis errors when it only re-analysis files

Even if there was error in the analysis, it is not shown properly if the report directory was existing when
analyze is called.
We expect the following output
~~~~~~~~~~
Total compilation commands: 12
[19:37] - Successfully analyzed
[19:37] -   clangsa: 5
[19:37] -   clang-tidy: 6
[19:37] - Failed to analyze
[19:37] -   clangsa: 1
~~~~~~~~~~

however we got
~~~~~~~~~~
19:29] - Total compilation commands: 12
[19:29] - Reanalyzed compilation commands: 12
~~~~~~~~~~

~~~~~~~~~~
~/work/codechecker$ CodeChecker analyze ./TinyXML/build.json -o tmp-reports -j12
[19:28] - Starting static analysis ...
[19:28] - [1/12] clang-tidy analyzed tinystr.cpp successfully.
[19:28] - [2/12] clang-tidy analyzed tinyxmlerror.cpp successfully.
[19:28] - [3/12] clang-tidy analyzed tinyxmlparser.cpp successfully.
[19:28] - [4/12] clang-tidy analyzed tinyxml.cpp successfully.
[19:28] - [5/12] clang-tidy analyzed xmltest.cpp successfully.
[19:28] - [6/12] clang-tidy analyzed tinyxml.cpp successfully.
[ERROR] [19:28] - Analyzing 'tinystr.cpp' with clangsa failed.
[ERROR] [19:28] - /home/ednikru/work/codechecker/TinyXML/tinystr.cpp:23:1: error: unknown type name 'dfdf'
dfdf
^
In file included from /home/ednikru/work/codechecker/TinyXML/tinystr.cpp:27:
In file included from /home/ednikru/work/codechecker/TinyXML/tinystr.h:30:
/usr/include/assert.h:66:1: error: expected unqualified-id
__BEGIN_DECLS
^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:98:24: note: expanded from macro '__BEGIN_DECLS'
# define __BEGIN_DECLS  extern "C" {
                        ^
In file included from /home/ednikru/work/codechecker/TinyXML/tinystr.cpp:27:
/home/ednikru/work/codechecker/TinyXML/tinystr.h:149:3: error: use of undeclared identifier '__assert_fail'
                assert( index < length() );
                ^
/usr/include/assert.h:91:6: note: expanded from macro 'assert'
   : __assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
     ^
In file included from /home/ednikru/work/codechecker/TinyXML/tinystr.cpp:27:
/home/ednikru/work/codechecker/TinyXML/tinystr.h:156:3: error: use of undeclared identifier '__assert_fail'
                assert( index < length() );
                ^
/usr/include/assert.h:91:6: note: expanded from macro 'assert'
   : __assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
     ^
4 errors generated.

[19:28] - [8/12] clangsa analyzed tinyxmlerror.cpp successfully.
[19:28] - [9/12] clangsa analyzed xmltest.cpp successfully.
[19:29] - [10/12] clangsa analyzed tinyxmlparser.cpp successfully.
[19:29] - [11/12] clangsa analyzed tinyxml.cpp successfully.
[19:29] - [12/12] clangsa analyzed tinyxml.cpp successfully.
[19:29] - ----==== Summary ====----
[19:29] - Total compilation commands: 12
**[19:29] - Reanalyzed compilation commands: 12**
[19:29] - ----=================----
[19:29] - Analysis length: 99.6122159958 sec.
[19:29] - Analysis finished.
[19:29] - To view results in the terminal use the "CodeChecker parse" command.
[19:29] - To store results use the "CodeChecker store" command.
[19:29] - See --help and the user guide for further options about parsing and storing the reports.
[19:29] - ----=================----
~~~~~~~~~~


Changed files:
libcodechecker/analyze/analysis_manager.py

diff --git a/libcodechecker/analyze/analysis_manager.py b/libcodechecker/analyze/analysis_manager.py
index 78dec21f..5bd7e4d9 100644
--- a/libcodechecker/analyze/analysis_manager.py
+++ b/libcodechecker/analyze/analysis_manager.py
@@ -40,9 +40,10 @@ def worker_result_handler(results, metadata, output_path):
     for res, skipped, reanalyzed, analyzer_type, _ in results:
         if skipped:
             skipped_num += 1
-        elif reanalyzed:
-            reanalyzed_num += 1
         else:
+            if reanalyzed:
+                reanalyzed_num += 1
+
             if res == 0:
                 successful_analysis[analyzer_type] += 1
             else: