Repository: ericsson/codechecker
Issue: Incremental analysis failures on the same file results in stupid failure ZIP

**Describe the bug**
If sequential analyses which fail happen to the same `reports` directory, the failure zip might end up collecting the data files multiple times.

**CodeChecker version**
Has been happening with 6.10, 6.11...

```
---------------------------------------------------------------
Kind                 | Version
---------------------------------------------------------------
Base package version | 6.11.0
Package build date   | 2019-10-16T22:02
Git commit ID (hash) | 93d5cb005ae3efc08fcdf50695d82daaa59d2d03
Git tag information  | 6.11
---------------------------------------------------------------
```

**To Reproduce**
~~~~{.sh}
# need a valid bjson first.
echo "int main(){}" > a.cpp
CodeChecker log -b "g++ a.cpp -o/dev/null" -o build.json

# using only 1 analyzer so the failed zip's name is unique
CodeChecker analyze --analyzers clangsa build.json -o reports

# now mess up the file (or the analyzer binary)
echo "crap" >> a.cpp

# incremental analysis
CodeChecker analyze --analyzers clangsa build.json -o reports

unzip -l reports/failed/a.cpp*
~~~~

Output:

```
Length      Date    Time    Name
---------  ---------- -----   ----
     2363  2018-04-16 22:14   sources-root/usr/include/stdc-predef.h
       27  2019-10-18 13:56   sources-root/home/whisperity/one-shitty-project/a.cpp
        0  2019-10-18 14:11   stdout
      124  2019-10-18 14:11   stderr
       37  2019-10-18 14:11   build-action
    12735  2019-10-18 14:11   analyzer-command
        1  2019-10-18 14:11   return-code
---------                     -------
    15287                     7 files
```

Now analyze again:
~~~~{.sh}
CodeChecker analyze --analyzers clangsa build.json -o reports

unzip -l reports/failed/a.cpp*
~~~~

See:

```
  Length      Date    Time    Name
---------  ---------- -----   ----
     2363  2018-04-16 22:14   sources-root/usr/include/stdc-predef.h
       27  2019-10-18 13:56   sources-root/home/whisperity/one-shitty-project/a.cpp
        0  2019-10-18 14:11   stdout
      124  2019-10-18 14:11   stderr
       37  2019-10-18 14:11   build-action
    12735  2019-10-18 14:11   analyzer-command
        1  2019-10-18 14:11   return-code
        0  2019-10-18 14:11   stdout
      124  2019-10-18 14:11   stderr
       37  2019-10-18 14:11   build-action
    12735  2019-10-18 14:11   analyzer-command
        1  2019-10-18 14:11   return-code
---------                     -------
    28184                     12 files
```

While it is not strictly undefined behaviour to have name conflicts in a ZIP file, most likely 99% of the tools used to handle ZIPs don't consider this a possibility. Although in this example they should contain the same thing (as no configuration or file had been modified), over the course of a longer-living project with many incremental analysis steps, the failed ZIPs could get out of sync and the info inside them about the built analyzer command useless for reproduction.

For `unzip`, calling extract, a prompt happens:

    replace stdout? [y]es, [n]o, [A]ll, [N]one, [r]ename:

In a graphical ZIP viewer, such as *Ark*, there is no indication of multiple entries until someone double-click opens a multiplied file, in which case similar "overwrite?" prompt will happen.

There is no immediate indication about the order of the multiplication (reasonable assumption: the sequence of failed analyses), or how many of such conflicts will be.

This only affects the text files CodeChecker creates by itself, files copied from the host machine into the ZIP doesn't duplicate, but overwrite.
However, due to this behaviour, if it includes change, includes from a previous failure will still be present in the failed-zip.

**Expected behavior**
Clear the files inside the ZIP, or delete the ZIP when a new failure ZIP is created for the same analysis (same fail zip filename).


Changed files:
analyzer/codechecker_analyzer/analysis_manager.py

diff --git a/analyzer/codechecker_analyzer/analysis_manager.py b/analyzer/codechecker_analyzer/analysis_manager.py
index 4a0dce44..1d9f167a 100644
--- a/analyzer/codechecker_analyzer/analysis_manager.py
+++ b/analyzer/codechecker_analyzer/analysis_manager.py
@@ -315,7 +315,7 @@ def handle_failure(source_analyzer, rh, zip_file, result_base, actions_map):
         zip_file,
         map(lambda path: os.path.join(action.directory, path), other_files))
 
-    with zipfile.ZipFile(zip_file, 'a') as archive:
+    with zipfile.ZipFile(zip_file, 'w') as archive:
         LOG.debug("[ZIP] Writing analyzer STDOUT to /stdout")
         archive.writestr("stdout", rh.analyzer_stdout)
 
@@ -553,7 +553,6 @@ def check(check_data):
         source_file_name = os.path.basename(action.source)
 
         if rh.analyzer_returncode == 0:
-
             # Remove the previously generated error file.
             if os.path.exists(zip_file):
                 os.remove(zip_file)