# Buggy code
def __populate_analyzers(self):
    """Set analyzer binaries for each registered analyzers."""
    analyzer_env = None
    analyzer_from_path = env.is_analyzer_from_path()
    if not analyzer_from_path:
        analyzer_env = env.extend(self.path_env_extra, self.ld_lib_path_extra)

    compiler_binaries = self.pckg_layout.get("analyzers")
    for name, value in compiler_binaries.items():
        if analyzer_from_path:
            value = os.path.basename(value)

        if os.path.dirname(value):
            # Check if it is a package relative path.
            self.__analyzers[name] = os.path.join(self._package_root, value)
        else:
            env_path = analyzer_env["PATH"] if analyzer_env else None
            compiler_binary = find_executable(value, env_path)
            if not compiler_binary:
                LOG.warning("'%s' binary can not be found in your PATH!", value)
                continue

            self.__analyzers[name] = os.path.realpath(compiler_binary)

            # If the compiler binary is a simlink to ccache, use the
            # original compiler binary.
            if self.__analyzers[name].endswith("/ccache"):
                self.__analyzers[name] = compiler_binary


# Traceback (TypeError)
╰─ which clang
clang not found

╰─ which clang-tidy
~/LLVM/Build/bin/clang-tidy

╰─ ~/CodeChecker/build/CodeChecker/bin/CodeChecker check -l compile_commands.json --analyzers clang-tidy
'clang' binary can not be found in your PATH!
'clang' binary can not be found in your PATH!
[WARNING 2021-01-13 17:56] - 'clang' binary can not be found in your PATH!
[ERROR 2021-01-13 17:56] - Running check failed.
Traceback (most recent call last):
File "~/CodeChecker/build/CodeChecker/cc_bin/../lib/python3/codechecker_analyzer/cmd/check.py", line 819, in main
analysis_exit_status = analyze_module.main(analyze_args)
File "~/CodeChecker/build/CodeChecker/lib/python3/codechecker_analyzer/cmd/analyze.py", line 937, in main
analyzer_env)
File "~/CodeChecker/build/CodeChecker/lib/python3/codechecker_analyzer/analyzers/clangsa/version.py", line 73, in get
errors="ignore")
File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
**kwargs).stdout
File "/usr/lib/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1278, in _execute_child
executable = os.fsencode(executable)
File "/usr/lib/python3.6/os.py", line 800, in fsencode
filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType
Traceback (most recent call last):
File "~/CodeChecker/build/CodeChecker/cc_bin/../lib/python3/codechecker_analyzer/cmd/check.py", line 819, in main
analysis_exit_status = analyze_module.main(analyze_args)
File "~/CodeChecker/build/CodeChecker/lib/python3/codechecker_analyzer/cmd/analyze.py", line 937, in main
analyzer_env)
File "~/CodeChecker/build/CodeChecker/lib/python3/codechecker_analyzer/analyzers/clangsa/version.py", line 73, in get
errors="ignore")
File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
**kwargs).stdout
File "/usr/lib/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1278, in _execute_child
executable = os.fsencode(executable)
File "/usr/lib/python3.6/os.py", line 800, in fsencode
filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType
Traceback (most recent call last):
File "~/CodeChecker/build/CodeChecker/cc_bin/CodeChecker.py", line 141, in main
sys.exit(args.func(args))
File "~/CodeChecker/build/CodeChecker/cc_bin/../lib/python3/codechecker_analyzer/cmd/check.py", line 850, in main
return analysis_exit_status
UnboundLocalError: local variable 'analysis_exit_status' referenced before assignment

# Fixed code
def __populate_analyzers(self):
    """Set analyzer binaries for each registered analyzers."""
    analyzer_env = None
    analyzer_from_path = env.is_analyzer_from_path()
    if not analyzer_from_path:
        analyzer_env = env.extend(self.path_env_extra, self.ld_lib_path_extra)

    compiler_binaries = self.pckg_layout.get("analyzers")
    for name, value in compiler_binaries.items():
        if analyzer_from_path:
            value = os.path.basename(value)

        if os.path.dirname(value):
            # Check if it is a package relative path.
            self.__analyzers[name] = os.path.join(self._package_root, value)
        else:
            env_path = analyzer_env["PATH"] if analyzer_env else None
            compiler_binary = find_executable(value, env_path)
            if not compiler_binary:
                LOG.debug("'%s' binary can not be found in your PATH!", value)
                continue

            self.__analyzers[name] = os.path.realpath(compiler_binary)

            # If the compiler binary is a simlink to ccache, use the
            # original compiler binary.
            if self.__analyzers[name].endswith("/ccache"):
                self.__analyzers[name] = compiler_binary