使用rust clippy改进rust项目质量

RustClippy是一个包含600多条规则的工具,用于提升Rust代码质量。它提供不同分类的检查,如错误逻辑、代码风格、性能等,并能在自动构建中整合。部分规则可自定义配置,用户可通过GUI配置助手简化设置。链接saas提供了预编译版本和源代码访问。
摘要由CSDN通过智能技术生成

Rust Clippy集合了一系列规则用于改进Rust代码的质量,这个规则集包含了600条以上的规则。这些规则被分成了几个大类,可以在允许Clippy的时候指定分类。

目前有如下几个分类:

  • clippy::all 执行所有检查规则
  • clippy::correctness 检查错误逻辑和代码
  • clippy::suspicious 检查可疑逻辑和代码
  • clippy::style 代码风格相关的检查规则
  • clippy::complexity 复杂性相关的检查规则
  • clippy::perf 性能相关的检查规则
  • clippy::pedantic 严格会引起误报的规则
  • clippy::restriction 阻止使用语言或库功能的规则
  • clippy::nursery 人在开发中的规则
  • clippy::cargo cargo相关的规则

你可以把Clippy整合到工作流程中,比如自动构建中。

Rust Clippy中的大多数规则没有额外配置,约有50条规则有自定义配置。

使用gui配置工具

使用gui配置工具,可以让配置rust clippy参数更简单。

在凌鲨(linksaas)的微应用里面可以找到clippy配置助手,快速配置自定义规则。

凌鲨(linksaas)是以开源方式运作的,您可以从linksaas · 极狐GitLab 访问源代码。也可以从 凌鲨 软件研发团队信息枢纽 下载预编译的版本。

附录

自定义配置

  • arithmetic-side-effects-allowed
  • arithmetic-side-effects-allowed-binary
  • arithmetic-side-effects-allowed-unary
  • avoid-breaking-exported-api
  • msrv
  • cognitive-complexity-threshold
  • disallowed-names
  • doc-valid-idents
  • too-many-arguments-threshold
  • type-complexity-threshold
  • single-char-binding-names-threshold
  • too-large-for-stack
  • enum-variant-name-threshold
  • enum-variant-size-threshold
  • verbose-bit-mask-threshold
  • literal-representation-threshold
  • trivial-copy-size-limit
  • pass-by-value-size-limit
  • too-many-lines-threshold
  • array-size-threshold
  • vec-box-size-threshold
  • max-trait-bounds
  • max-struct-bools
  • max-fn-params-bools
  • warn-on-all-wildcard-imports
  • disallowed-macros
  • disallowed-methods
  • disallowed-types
  • unreadable-literal-lint-fractions
  • upper-case-acronyms-aggressive
  • matches-for-let-else
  • cargo-ignore-publish
  • standard-macro-braces
  • enforced-import-renames
  • allowed-scripts
  • enable-raw-pointer-heuristic-for-send
  • max-suggested-slice-pattern-length
  • await-holding-invalid-types
  • max-include-file-size
  • allow-expect-in-tests
  • allow-unwrap-in-tests
  • allow-dbg-in-tests
  • allow-print-in-tests
  • large-error-threshold
  • ignore-interior-mutability
  • allow-mixed-uninlined-format-args
  • suppress-restriction-lint-in-const
  • missing-docs-in-crate-items
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凌鲨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值