企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] 将 Podspec 提交到 [Trunk](https://guides.cocoapods.org/making/making/getting-setup-with-trunk.html) 后,文档服务 CocoaDocs 将为 Pod 创建一组度量标准。您可以在 [metrics.cocoapods.org/api/v1/pods/[Pod]](http://metrics.cocoapods.org/api/v1/pods/ORStackView) 上查看任何 Pod 的这些指标。这些指标用于生成各种质量修饰符,最终形成一个称为质量指标的单一数字。 该文档是 [CocoaDocs-API](https://github.com/CocoaPods/cocoadocs-api/blob/master/quality_modifiers.rb) 中的一种[字面量编程](https://en.wikipedia.org/wiki/Literate_programming#cite_note-19)。因此,它包含为了生成单个分数而实际运行的 Ruby 代码。另外,Swift 看起来像 Ruby ,所以你可以读它。 质量指数的目标是突出正面指标,淡化负面因素。非常有可能有一个没有实际应用修饰符的 Pod。这意味着指数停留在默认的50位。这是一个非常合理的分数。 我们对修饰符的一个很好的例子就是在 Swift 中想到一个带有大部分代码的 Pod。它得到了提升,而 Objective-C 不会被修改。这不是为了减少 Objective-C 的分数,而是强调目前 Swift 库代表了具有前瞻性的最佳实践。 最后,在我们开始之前。这些指标并非一成不变,它们自推出以来一直在发展,并将在未来继续这样做。反馈是被欣赏的,最好是在[问题模块](https://github.com/CocoaPods/cocoapods.org/issues/new)中——这样他们就可以被讨论了。 # 1. 人气指标 这是一个非常安全的赌注,一个非常受欢迎的库将得到很好的照顾,并维持库。 我们根据单个指标的价值多少来衡量不同的指标,而不是仅仅使用星标作为核心指标。 ~~~ Modifier.new("Very Popular", "The popularity of a project is a useful way of discovering if it is useful, and well maintained.", 30, { |...| value = stats[:contributors].to_i * 90 + stats[:subscribers].to_i * 20 + stats[:forks].to_i * 10 + stats[:stargazers].to_i value > 9000 }), ~~~ 然而,并不是每个想法都需要足够大才能保证如此高的指标。 大量的参与对本身是有用的。 ~~~ Modifier.new("Popular", "A popular library means there can be a community to help improve and maintain a project.", 10, { |...| value = stats[:contributors].to_i * 90 + stats[:subscribers].to_i * 20 + stats[:forks].to_i * 10 + stats[:stargazers].to_i value > 1500 }), ~~~ # 2. Swift Package Manager 我们希望鼓励对 Apple 的 Swift Package Manager 的支持,这对社区是统一的。 欲了解更多信息,请参阅我们的 [FAQ](https://guides.cocoapods.org/using/faq.html) 。目前,它正在检查 Package.swift 的存在,一旦 SPM 开发速度放慢,我们可能会转向测试它是否支持最新版本。 ~~~ Modifier.new("Supports Swift Package Manager", "Supports Apple's official package manager for Swift.", 15, { |...| cd_stats[:spm_support] }), ~~~ # 3. README 评分 README 评分基于一种算法,该算法查看的 README 的多样性。你可以对[clayallsopp.github.io/readme-score](http://clayallsopp.github.io/readme-score) 上的任何URL运行算法。README 是您的库的首页,它可以提供 API 的概览或显示库的功能。 听起来很奇怪,如果你提供了一个二进制 CocoaPod,值得将你的 README.md 嵌入到 zip 中。 这意味着 CocoaPods 可以使用它来生成 Pod 页面。 我们在您的项目根目录中的两个目录查找 README 或 README.md 或 README.markdown 。 注意:由于我们想要考虑 Podspec 的 documentation_url,所以这些修饰符仍然存在一些问题。 ~~~ Modifier.new("Great README", "A well written README gives a lot of context for the library, providing enough information to get started. ", 5, { |...| cd_stats[:readme_complexity].to_i > 75 }), Modifier.new("Minimal README", "The README is an overview for a library's API. Providing a minimal README means that it can be hard to understand what the library does.", -5, { |...| cd_stats[:readme_complexity].to_i < 40 }), Modifier.new("Empty README", "The README is the front page of a library. To have this applied you may have a very empty README.", -8, { |...| cd_stats[:readme_complexity].to_i < 25 && spec.documentation_url == nil }), ~~~ # 4. 修改日志 拥有 CHANGELOG 意味着人们更容易比较旧版本,作为质量指标,这通常表明维护人员需要小心以显示更改的更成熟的库。 我们在您的项目根目录中的两个目录寻找CHANGELOG 或 CHANGELOG.md 或 CHANGELOG.markdown。 ~~~ Modifier.new("Has a CHANGELOG", "CHANGELOGs make it easy to see the differences between versions of your library.", 8, { |...| cd_stats[:rendered_changelog_url] != nil }), ~~~ # 5. 语言选择 Swift 正在发生。 我们想积极地区分在 Swift 中编写库的人员。 ~~~ Modifier.new("Built in Swift", "Swift is where things are heading.", 5, { |...| cd_stats[:dominant_language] == "Swift" }), ~~~ Objective-C ++库很难与 Swift 集成,并且可能需要与大多数项目所用的编程不同的范例。 ~~~ Modifier.new("Built in Objective-C++", "Usage of Objective-C++ makes it difficult for others to contribute.", -5, { |...| cd_stats[:dominant_language] == "Objective-C++" }), ~~~ # 6. 许可问题 GPL 是用于您的代码的合法许可。 但它与 App Store 上的应用程序[不兼容](http://www.fsf.org/blogs/licensing/more-about-the-app-store-gpl-enforcement)。 为了防止这种情况,我们从 GPL 库中减去了一些分数。 ~~~ Modifier.new("Uses GPL", "There are legal issues around distributing GPL'd code in App Store environments.", -20, { |...| cd_stats[:license_short_name] =~ /GPL/i || false }), ~~~ 也有相当多的库使用 WTFPL,这是一个旨在不成为许可证的许可证。 它被 [OSI](http://opensource.org/)(一个开放源代码许可机构)拒绝,因为它与不包括许没有不同。 如果您想这样做,请使用公共领域的许可证。 ~~~ Modifier.new("Uses WTFPL", "WTFPL was denied as an OSI approved license. Thus it is not classed as code license.", -5, { |...| cd_stats[:license_short_name] == "WTFPL" }), ~~~ # 7. 代码调用 测试一个库是很重要的。 当你有一个人们依赖的库时,能够验证你所期望的工作是否会提高质量。 ~~~ Modifier.new("Has Tests", "Testing a library shows that the developers care about long term quality on a project as internalized logic is made explicit via testing.", 4, { |...| cd_stats[:total_test_expectations].to_i > 10 }), Modifier.new("Test Expectations / Line of Code", "Having more code covered by tests is great.", 10, { |...| lines = cd_stats[:total_lines_of_code].to_f expectations = cd_stats[:total_test_expectations].to_f if lines != 0 0.045 < (expectations / lines) else false end }), ~~~ CocoaPods 可以很容易地创建一个包含多个文件的库,我们希望鼓励采用更小的可组合库。 ~~~ Modifier.new("Lines of Code / File", "Smaller, more composeable classes tend to be easier to understand.", -8, { |...| files = cd_stats[:total_files].to_i if files != 0 (cd_stats[:total_lines_of_code].to_f / cd_stats[:total_files].to_f) > 250 else false end }), ~~~ # 8. 所有权 CocoaPods Specs Repo 并没有被管理,对于较大的 SDKs,人们将创建非官方的 pod 。我们需要一种方法来说明这个Pod是为图书馆的作者而来的,所以,我们已经验证了帐户。这些对公司的规模非常有用;谷歌,Facebook,亚马逊和 Dropbox。我们非常谨慎地运用这一点,并一直在与各公司进行单独接触。 ~~~ Modifier.new("Verified Owner", "When a pod comes from a large company with an official account.", 20, { |...| owners.find { |owner| owner.owner.is_verified } != nil }), ~~~ # 9. 维护 我们希望鼓励人们使用他们的库来发布语义版本。如果在没有社会契约的情况下,从一个尚未达到 1.0.0 的库中,我们很难知道会发生什么。这是因为在 v1.0.0之前,一个库作者没有对向后兼容做出承诺。 ~~~ Modifier.new("Post-1.0.0", "Has a Semantic Version that is above 1.0.0", 5, { |...| Pod::Version.new("1.0.0") <= Pod::Version.new(spec.version) }), ~~~ 当需要废弃库时,我们应该在搜索结果中反映这一点。 ~~~ Modifier.new("Is Deprecated", "Latest Podspec is declared to be deprecated", -20, { |...| spec.deprecated || spec.deprecated_in_favor_of || false }), ~~~ # 10. 杂项 - GitHub 特定 这是一项研究项目是否被放弃的实验。问题可能会被用作待办事项列表,但是50+ un-open会让人感觉有点不舒服,更有可能是这个项目已经被放弃。 ~~~ Modifier.new("Lots of open issues", "A project with a lot of open issues is generally abandoned. If it is a popular library, then it is usually offset by the popularity modifiers.", -8, { |...| stats[:open_issues].to_i > 50 }) ~~~