# 代码扫描分析错误疑难解答

识别并解决在代码分析期间发生的错误，包括生成失败、不完整扫描、资源限制和意外结果。

## Links

* [在生成的代码中找到的警报](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/alerts-in-generated-code)

  使用 code scanning 分析代码时，你可能希望仅生成要分析的代码。

* [编译的语言的自动生成失败](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/automatic-build-failed)

  如果自动生成失败，可以将 code scanning 配置为使用编译的语言的特定生成步骤。

* [C# 编译器意外失败](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/c-sharp-compiler-unexpectedly-failing)

  如果 MSBuild C# 编译意外失败，则可能需要修改应用程序项目文件。

* [无法在专用存储库中启用 CodeQL](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/cannot-enable-codeql-in-a-private-repository)

  要在专用存储库中使用 code scanning，需要启用 GitHub Code Security。

* [代码扫描分析耗时过长](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/analysis-takes-too-long)

  可以微调 code scanning 配置，以最大程度地减少分析时间。

* [CodeQL 扫描的行数少于预期](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/fewer-lines-scanned-than-expected)

  如果 CodeQL 分析的代码少于预期，则可能需要使用自定义生成命令。

* [启用默认设置耗时过长](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/enabling-default-setup-takes-too-long)

  如果认为启用默认设置耗时过长，可以重启该过程。

* [错误：“GitHub Code Security or GitHub Advanced Security must be enabled for this repository to use code scanning”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/advanced-security-must-be-enabled)

  如果看到此错误，请确保 GitHub Code Security 已启用。

* [“磁盘不足”和“内存不足”错误](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/out-of-disk-or-memory)

  如果系统针对 GitHub Actions 显示其中某一错误，你可以尝试使用替代运行器。

* [错误：403“无法通过集成访问资源”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/resource-not-accessible)

  此错误可能在 Dependabot 创建的拉取请求上出现，可以通过几种不同的方式解决。

* [错误：“不是 .ql 文件、.qls 文件、目录或查询包规范”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/not-recognized)

  CodeQL 未能找到为分析指定的查询或查询集之一。

* [错误：“生成期间未看到任何源代码”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/no-source-code-seen-during-build)

  当 CodeQL 找不到任何源代码时，需要解决此问题以取消阻止 code scanning 分析。

* [错误：“服务器错误”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/server-error)

  如果看到此错误，可能是暂时性的。 检查当前 GitHub Actions 服务状态，然后再次尝试运行工作流。

* [数据库中的提取错误](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/extraction-errors-in-the-database)

  可以检查提取错误是否会影响所创建的 CodeQL 数据库的运行状况。

* [日志不够详细](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/logs-not-detailed-enough)

  增加日志详细程度，并在日志缺少诊断详细信息时生成调试项目。

* [结果与预期不同](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/results-different-than-expected)

  如果 code scanning 结果与预期不同，可以检查哪些配置处于活动状态。

* [某些语言未使用 CodeQL 高级设置进行分析](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/some-languages-not-analyzed)

  如果某些语言未分析，则可以修改 code scanning 工作流，以添加指定要分析的语言的矩阵。

* [两个 CodeQL 工作流](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/two-codeql-workflows)

  如果看到两个名为“CodeQL”的工作流，那么其中一个工作流可能是预先存在的 CodeQL 工作流文件（在默认设置下被禁用）。

* [不确定是什么触发了工作流运行](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/unclear-what-triggered-a-workflow)

  如果不知道是什么触发了分析，则调查 工具状态页 或查看上次扫描的日志。

* [警告：“此工作流检测到 1 个问题：不再需要 git checkout HEAD^2”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/unnecessary-step-found)

  如果看到此警告，应更新工作流以遵循当前的最佳做法。

* [警告：检测到项目中有 X 个 Kotlin 文件，需经过构建才能进行处理。](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/kotlin-detected-in-no-build)

  虽然可在不生成代码的情况下为 Java 创建 CodeQL 数据库，但会排除 Kotlin 文件，除非生成代码。