0xFable / cw-lint

POC State - Code quality and static analysis for CosmWasm based projects
MIT License
11 stars 0 forks source link

Cosmwasm Linter

PRs Welcome first-timers-only Twitter handle

Dylint is a tool for running Rust lints from dynamic libraries. This repository is a "cosmwasm-focused" Dylint library you can use locally for one or all Cosmwasm contracts in your workspace!

Usage

First install dylint, then add the following to your workspace's cargo.toml:

[workspace.metadata.dylint]
libraries = [
    { git = "https://github.com/0xFable/cw-lint" },
]

Now running cargo dylint cw_lint --workspace will download the linter and check your crates. Currently the following lints are used:

More lints will be added in the future. If you can think of some pls submit a PR :D

Using cw-lint in Github Actions

Yes! You can automate the usage of cw-lint for when contributors submit new versions like so (assuming a github workflow yaml file):

# Install deps
- name: Install cargo-dylint
run: cargo install cargo-dylint

- name: Install dylint-link
run: cargo install dylint-link
# Run linter
- name: Run cosmwasm linter
run: cargo dylint cw_lint --workspace

Experimental

Choose a Clippy lint and run the following two commands:

./start_from_clippy_lint.sh CLIPPY_LINT_NAME NEW_LINT_NAME
cargo build

If the first command fails: sorry. Perhaps try another Clippy lint.

If the first command succeeds, but the second fails: you are probably halfway to having a functional Dylint library.

If both commands succeed: hooray! You might then try the following:

DYLINT_LIBRARY_PATH=$PWD/target/debug cargo dylint NEW_LINT_NAME -- --manifest-path=PATH_TO_OTHER_PACKAGES_MANIFEST