Repository: ericsson/codechecker
Issue: error: unknown argument: '-analyzer-config-help'

**Describe the bug**
CodeChecker throws `error: unknown argument: '-analyzer-config-help'`.

**CodeChecker version**
```
$ CodeChecker version
CodeChecker analyzer version:
---------------------------------------
Kind                 | Version         
---------------------------------------
Base package version | 6.15.2          
Package build date   | 2021-04-09T12:56
Git commit ID (hash) |                 
Git tag information  |                 
---------------------------------------

CodeChecker web version:
------------------------------------------------
Kind                          | Version         
------------------------------------------------
Base package version          | 6.15.2          
Package build date            | 2021-04-09T12:56
Git commit ID (hash)          |                 
Git tag information           |                 
Server supported API (Thrift) | 6.39            
Client API (Thrift)           | 6.39            
------------------------------------------------
```

**To Reproduce**
Steps to reproduce the behaviour:

* Run command `CodeChecker --help`:
```
$ CodeChecker --help
error: unknown argument: '-analyzer-config-help'
error: unknown argument: '-analyzer-config-help'
usage: CodeChecker [-h]
                   {analyze,analyzer-version,analyzers,check,checkers,cmd,fixit,log,parse,server,store,version,web-version}
                   ...

...
```
* or `CodeChecker analyzers --analyzer-config clangsa`:
```
$ CodeChecker analyzers --analyzer-config clangsa
error: unknown argument: '-analyzer-config-help'

```

**Expected behaviour**
No `error:`.

**Desktop (please complete the following information)**
 - OS: Ubuntu 18.04

**Additional context**
I believe this can be reproduced with both Snap package and CodeChecker installed from source.

Changed files:
analyzer/codechecker_analyzer/cmd/checkers.py, analyzer/codechecker_analyzer/cmd/analyzers.py, analyzer/codechecker_analyzer/analyzers/clangsa/analyzer.py

diff --git a/analyzer/codechecker_analyzer/analyzers/clangsa/analyzer.py b/analyzer/codechecker_analyzer/analyzers/clangsa/analyzer.py
index 370e813e..8aaafe7d 100644
--- a/analyzer/codechecker_analyzer/analyzers/clangsa/analyzer.py
+++ b/analyzer/codechecker_analyzer/analyzers/clangsa/analyzer.py
@@ -15,6 +15,8 @@ import re
 import shlex
 import subprocess
 
+from typing import Dict, List
+
 from codechecker_common.logger import get_logger
 
 from codechecker_analyzer import env
@@ -33,7 +35,11 @@ from .result_handler import ResultHandlerClangSA
 LOG = get_logger('analyzer')
 
 
-def parse_clang_help_page(command, start_label, environ):
+def parse_clang_help_page(
+    command: List[str],
+    start_label: str,
+    environ: Dict[str, str]
+) -> List[str]:
     """
     Parse the clang help page starting from a specific label.
     Returns a list of (flag, description) tuples.
@@ -41,11 +47,13 @@ def parse_clang_help_page(command, start_label, environ):
     try:
         help_page = subprocess.check_output(
             command,
+            stderr=subprocess.STDOUT,
             env=environ,
             universal_newlines=True,
             encoding="utf-8",
             errors="ignore")
     except (subprocess.CalledProcessError, OSError):
+        LOG.debug("Failed to run '%s' command!", command)
         return []
 
     help_page = help_page[help_page.index(start_label) + len(start_label):]
@@ -131,7 +139,11 @@ class ClangSA(analyzer_base.SourceAnalyzer):
         self.__checker_configs.append(checker_cfg)
 
     @classmethod
-    def get_analyzer_checkers(cls, cfg_handler, environ):
+    def get_analyzer_checkers(
+        cls,
+        cfg_handler: config_handler.ClangSAConfigHandler,
+        environ: Dict[str, str]
+    ) -> List[str]:
         """Return the list of the supported checkers."""
         checker_list_args = clang_options.get_analyzer_checkers_cmd(
             cfg_handler,
@@ -139,7 +151,11 @@ class ClangSA(analyzer_base.SourceAnalyzer):
         return parse_clang_help_page(checker_list_args, 'CHECKERS:', environ)
 
     @classmethod
-    def get_checker_config(cls, cfg_handler, environ):
+    def get_checker_config(
+        cls,
+        cfg_handler: config_handler.ClangSAConfigHandler,
+        environ: Dict[str, str]
+    ) -> List[str]:
         """Return the list of checker config options."""
         checker_config_args = clang_options.get_checker_config_cmd(
             cfg_handler,
@@ -147,7 +163,11 @@ class ClangSA(analyzer_base.SourceAnalyzer):
         return parse_clang_help_page(checker_config_args, 'OPTIONS:', environ)
 
     @classmethod
-    def get_analyzer_config(cls, cfg_handler, environ):
+    def get_analyzer_config(
+        cls,
+        cfg_handler: config_handler.ClangSAConfigHandler,
+        environ: Dict[str, str]
+    ) -> List[str]:
         """Return the list of analyzer config options."""
         analyzer_config_args = clang_options.get_analyzer_config_cmd(
             cfg_handler)
diff --git a/analyzer/codechecker_analyzer/cmd/analyzers.py b/analyzer/codechecker_analyzer/cmd/analyzers.py
index f20137a2..d878617b 100644
--- a/analyzer/codechecker_analyzer/cmd/analyzers.py
+++ b/analyzer/codechecker_analyzer/cmd/analyzers.py
@@ -13,6 +13,7 @@ analyzers available in CodeChecker.
 
 import argparse
 import subprocess
+import sys
 
 from codechecker_analyzer import analyzer_context
 from codechecker_analyzer import env
@@ -173,6 +174,12 @@ def main(args):
 
         configs = analyzer_class.get_analyzer_config(config_handler,
                                                      analyzer_environment)
+        if not configs:
+            LOG.error("Failed to get analyzer configuration options for '%s' "
+                      "analyzer! Please try to upgrade your analyzer version "
+                      "to use this feature.", analyzer)
+            sys.exit(1)
+
         rows = [(':'.join((analyzer, c[0])), c[1]) if 'details' in args
                 else (':'.join((analyzer, c[0])),) for c in configs]
 
diff --git a/analyzer/codechecker_analyzer/cmd/checkers.py b/analyzer/codechecker_analyzer/cmd/checkers.py
index ae205880..de925279 100644
--- a/analyzer/codechecker_analyzer/cmd/checkers.py
+++ b/analyzer/codechecker_analyzer/cmd/checkers.py
@@ -282,16 +282,30 @@ def main(args):
             header = list(map(uglify, header))
 
         rows = []
+        analyzer_failures = []
         for analyzer in working_analyzers:
             config_handler = analyzer_config_map.get(analyzer)
             analyzer_class = analyzer_types.supported_analyzers[analyzer]
 
             configs = analyzer_class.get_checker_config(config_handler,
                                                         analyzer_environment)
+            if not configs:
+                analyzer_failures.append(analyzer)
+                continue
+
             rows.extend((':'.join((analyzer, c[0])), c[1]) if 'details' in args
                         else (':'.join((analyzer, c[0])),) for c in configs)
 
-        print(twodim.to_str(args.output_format, header, rows))
+        if rows:
+            print(twodim.to_str(args.output_format, header, rows))
+
+        if analyzer_failures:
+            LOG.error("Failed to get checker configuration options for '%s' "
+                      "analyzer(s)! Please try to upgrade your analyzer "
+                      "version to use this feature.",
+                      ', '.join(analyzer_failures))
+            sys.exit(1)
+
         return
 
     if args.guideline is not None and len(args.guideline) == 0: