{"meta":{"title":"代码扫描分析错误疑难解答","intro":"识别并解决在代码分析期间发生的错误，包括生成失败、不完整扫描、资源限制和意外结果。","product":"安全性和代码质量","breadcrumbs":[{"href":"/zh/code-security","title":"安全性和代码质量"},{"href":"/zh/code-security/reference","title":"Reference"},{"href":"/zh/code-security/reference/code-scanning","title":"代码扫描"},{"href":"/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors","title":"排查与解决分析错误"}],"documentType":"subcategory"},"body":"# 代码扫描分析错误疑难解答\n\n识别并解决在代码分析期间发生的错误，包括生成失败、不完整扫描、资源限制和意外结果。\n\n## Links\n\n* [在生成的代码中找到的警报](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/alerts-in-generated-code)\n\n  使用 code scanning 分析代码时，你可能希望仅生成要分析的代码。\n\n* [编译的语言的自动生成失败](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/automatic-build-failed)\n\n  如果自动生成失败，可以将 code scanning 配置为使用编译的语言的特定生成步骤。\n\n* [C# 编译器意外失败](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/c-sharp-compiler-unexpectedly-failing)\n\n  如果 MSBuild C# 编译意外失败，则可能需要修改应用程序项目文件。\n\n* [无法在专用存储库中启用 CodeQL](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/cannot-enable-codeql-in-a-private-repository)\n\n  要在专用存储库中使用 code scanning，需要启用 GitHub Code Security。\n\n* [代码扫描分析耗时过长](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/analysis-takes-too-long)\n\n  可以微调 code scanning 配置，以最大程度地减少分析时间。\n\n* [CodeQL 扫描的行数少于预期](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/fewer-lines-scanned-than-expected)\n\n  如果 CodeQL 分析的代码少于预期，则可能需要使用自定义生成命令。\n\n* [启用默认设置耗时过长](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/enabling-default-setup-takes-too-long)\n\n  如果认为启用默认设置耗时过长，可以重启该过程。\n\n* [错误：“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)\n\n  如果看到此错误，请确保 GitHub Code Security 已启用。\n\n* [“磁盘不足”和“内存不足”错误](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/out-of-disk-or-memory)\n\n  如果系统针对 GitHub Actions 显示其中某一错误，你可以尝试使用替代运行器。\n\n* [错误：403“无法通过集成访问资源”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/resource-not-accessible)\n\n  此错误可能在 Dependabot 创建的拉取请求上出现，可以通过几种不同的方式解决。\n\n* [错误：“不是 .ql 文件、.qls 文件、目录或查询包规范”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/not-recognized)\n\n  CodeQL 未能找到为分析指定的查询或查询集之一。\n\n* [错误：“生成期间未看到任何源代码”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/no-source-code-seen-during-build)\n\n  当 CodeQL 找不到任何源代码时，需要解决此问题以取消阻止 code scanning 分析。\n\n* [错误：“服务器错误”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/server-error)\n\n  如果看到此错误，可能是暂时性的。 检查当前 GitHub Actions 服务状态，然后再次尝试运行工作流。\n\n* [数据库中的提取错误](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/extraction-errors-in-the-database)\n\n  可以检查提取错误是否会影响所创建的 CodeQL 数据库的运行状况。\n\n* [日志不够详细](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/logs-not-detailed-enough)\n\n  增加日志详细程度，并在日志缺少诊断详细信息时生成调试项目。\n\n* [结果与预期不同](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/results-different-than-expected)\n\n  如果 code scanning 结果与预期不同，可以检查哪些配置处于活动状态。\n\n* [某些语言未使用 CodeQL 高级设置进行分析](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/some-languages-not-analyzed)\n\n  如果某些语言未分析，则可以修改 code scanning 工作流，以添加指定要分析的语言的矩阵。\n\n* [两个 CodeQL 工作流](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/two-codeql-workflows)\n\n  如果看到两个名为“CodeQL”的工作流，那么其中一个工作流可能是预先存在的 CodeQL 工作流文件（在默认设置下被禁用）。\n\n* [不确定是什么触发了工作流运行](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/unclear-what-triggered-a-workflow)\n\n  如果不知道是什么触发了分析，则调查 工具状态页 或查看上次扫描的日志。\n\n* [警告：“此工作流检测到 1 个问题：不再需要 git checkout HEAD^2”](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/unnecessary-step-found)\n\n  如果看到此警告，应更新工作流以遵循当前的最佳做法。\n\n* [警告：检测到项目中有 X 个 Kotlin 文件，需经过构建才能进行处理。](/zh/code-security/reference/code-scanning/troubleshoot-analysis-errors/kotlin-detected-in-no-build)\n\n  虽然可在不生成代码的情况下为 Java 创建 CodeQL 数据库，但会排除 Kotlin 文件，除非生成代码。"}