smithy-rs/tools/cargo-check-external-types
John DiSanti 31c5a91a25
Upgrade min versions of tokio, tracing-subscriber, and criterion (#1662)
* Upgrade minimum Tokio version to 1.8.4

This addresses RUSTSEC-2021-0072 and RUSTSEC-2021-0124.
The SDK, runtime crates, and server are set to the minimum secure
version of Tokio to allow a larger range of versions to be used by
consumers of those libraries. The tools and the Python server are
both set to the latest Tokio version since they are not intended
to be consumed as a libraries.

* Upgrade `tracing-subscriber` to 0.3.15

* Upgrade `criterion` to 0.3.6

This addresses RUSTSEC-2021-0093 by upgrading `criterion`, which
upgrades `rayon`, which upgrades `crossbeam-deque`.
2022-08-31 21:19:04 +00:00
..
src Fix crash for certain re-exports in `cargo-check-external-types` (#1654) 2022-08-23 17:04:31 +00:00
test-workspace Fix crash for certain re-exports in `cargo-check-external-types` (#1654) 2022-08-23 17:04:31 +00:00
tests Fix crash for certain re-exports in `cargo-check-external-types` (#1654) 2022-08-23 17:04:31 +00:00
Cargo.lock Fix crash for certain re-exports in `cargo-check-external-types` (#1654) 2022-08-23 17:04:31 +00:00
Cargo.toml Upgrade min versions of tokio, tracing-subscriber, and criterion (#1662) 2022-08-31 21:19:04 +00:00
LICENSE Improve `cargo-check-external-types` README (#1630) 2022-08-11 20:11:04 +00:00
README.md Improve `cargo-check-external-types` README (#1630) 2022-08-11 20:11:04 +00:00
additional-ci Check external types for runtime and SDK crates in CI (#1625) 2022-08-10 18:33:43 -07:00

README.md

cargo-check-external-types

Static analysis tool that detects external types used in a Rust library's public API. Configuration can be provided to allow certain external types so that this tool can be used in continuous integration so that types don't unintentionally make it into the library's API. It can also output a Markdown table of the external types it found.

Example Output

The test suite has a Rust library that relies on some external types. When the tool is run against this library without any configuration, it emits errors for each occurrence of an external type in the public API.

When a config file is provided, the allowed external types no longer show up in the output.

When the output format is set to markdown-table, then a table of external types is output.

How to Use

Important: This tool requires a nightly build of Rust to be installed since it relies on rustdoc JSON output. It was last tested against nightly-2022-07-25.

To install, run the following from this README path:

cargo install --locked cargo-check-external-types

Then, in your library crate path, run:

cargo +nightly check-external-types

This will produce errors if any external types are used in a public API at all. That's not terribly useful on its own, so the tool can be given a config file to allow certain types. For example, we can allow any type in bytes with:

allowed_external_types = [
    "bytes::*",
]

Save that file somewhere in your project (in this example, we choose the name external-types.toml), and then run the command with:

cargo +nightly check-external-types --config external-types.toml

License

This tool is distributed under the terms of Apache License Version 2.0. See the LICENSE file for more information.