用于集成到 CI 管道中的 Android Studio 代码检查 shell 脚本

标签 android shell android-studio code-inspection dead-code

我正在尝试为我的 Android 应用程序集成死代码分析,以提高代码质量。我发现 android studio 提供了开箱即用的代码检查选项,它为我提供了未使用代码和建议改进的详细报告。

我使用了分析 -> 检查代码选项

enter image description here

我在工作室中得到的结果如下:

enter image description here

这非常有用,但我想将此代码分析集成到我的 CI 管道中,以便我可以跟踪报告的警告并对其进行趋势分析。

我发现了一个blog这就是说我可以使用 Android Studio 包附带的 inpsect.sh 文件来达到相同的目的。该命令的语法如下:

sh inspect.sh <project> <inspection-profile> <output> [<options>]

我尝试通过传递下面给出的适当参数来运行此命令:

sh inspect.sh Users/user1/Documents/androidProject /Users/user1/Documents/androidProject/app/src/InspectionProfile.xml /Users/user1/Documents/inspectionResults -v2 -d /Users/user1/Documents/androidProject/app/src

但每当我尝试使用所需参数运行此 shell 脚本时,我都会收到以下错误:

inspect.sh: line 9: exec: /Applications/Android Studio.app/Contents/bin/inspect.sh/../MacOS/studio: cannot execute: Not a directory

花了很多时间但没有运气。我在这里缺少什么?

最佳答案

这是因为您没有为-d选项指定参数。

-d <Specify the full path to the subdirectory if you don't want to inspect the whole project.>

应该是这样的:

inspect.sh 'Users/user1/Documents/androidProject' '/Users/user1/Documents/androidProject/app/src/InspectionProfile.xml' '/Users/user1/Documents/inspectionResults' -v2 -d '/Users/user1/Documents/androidProject/app/src'

关于用于集成到 CI 管道中的 Android Studio 代码检查 shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69656562/

相关文章:

android - 为速度较慢的手机优化粒子效果

android - 无法在 VS Android 模拟器 (Marshmallow 6.0) 上安装 Google play 服务

android - 混淆的 Android 库上的 java.lang.VerifyError

javascript - 我的 Android 平板电脑 4.4 版本无法自动播放视频

linux - IF语句多个and or条件

c - execvp 的错误地址错误

android - 未找到名称为 'default' 的配置 - HoloGraphLibrary

linux - 多字命令的大括号扩展?

android - 更新了 Android Studio,收到 DuplicateFileException

android-studio - 当我使用 Android Studio 4.0 时,我仍然可以使用 JKS keystore 将应用程序发布到 Google Play 吗?