Skip to content

feat: remove skip_clippy_and_linting flag from build command + add lint command #2015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ jobs:
cargo run -- contract --version &&
cargo run -- contract new --target-dir ${{ runner.temp }} foobar &&
# Build with linting
cargo run -- contract build --lint --manifest-path=${{ runner.temp }}/foobar/Cargo.toml &&
cargo run -- contract lint --manifest-path=${{ runner.temp }}/foobar/Cargo.toml &&
cargo run -- contract check --manifest-path=${{ runner.temp }}/foobar/Cargo.toml &&
cargo run -- contract build --manifest-path=${{ runner.temp }}/foobar/Cargo.toml --release &&
# Run tests
Expand Down
42 changes: 32 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,41 @@ of bugs in PolkaVM that prohibit us from using e.g. LTO. The contract sizes will
get much smaller again, once those bugs are fixed.

### Linting
Linting of a contract can be executed if set like this:
Linting of a contract can be executed by running the `lint` command:

```bash
➜ cargo contract lint --help
Lint a contract

Usage: cargo contract lint [OPTIONS]

Options:
--manifest-path <MANIFEST_PATH>
Path to the `Cargo.toml` of the contract to build

--quiet
No output printed to stdout

--verbose
Use verbose output

--extra-lints
Performs extra linting checks during the build process. Basic clippy lints are deemed important and run anyway.

-h, --help
Print help (see a summary with '-h')
```

Or can be executed programmatically:

```rust
let args = ExecuteArgs {
skip_clippy_and_linting: true
...
};
let res = contract_build::execute(args);
let crate_metadata = CrateMetadata::collect(manifest_path)?;
let verbosity = TryFrom::<&VerbosityFlags>::try_from(&self.verbosity)?;

contract_build::lint(extra_lint, &crate_metadata, &verbosity);
```

The linting can be quite slow, thus decreasing the feedback cycle if actively developing
a contract. Right now it's still the default to lint when `cargo contract build` is
invoked. We're actively thinking about not linting byt default, right now it's still
on by default.
Please see [#2013](https://github.com/use-ink/cargo-contract/pull/2013) for more information.

### Ability to generate Solidity metadata for a contract
ink! v6 will have the ability to speak Solidity, you'll be able to integrate
Expand All @@ -154,6 +175,7 @@ Please see [#1930](https://github.com/use-ink/cargo-contract/pull/1930) for more
### Added
- Add option to generate Solidity compatible metadata (via `cargo contract build ---metadata <ink|solidity>`) - [#1930](https://github.com/use-ink/cargo-contract/pull/1930)
- Deny overflowing (and lossy) integer type cast operations - [#1895](https://github.com/use-ink/cargo-contract/pull/1895)
- Remove linting by default and `--skip-linting` flag in `cargo contract build`, rename `--lint` flag to `--extra-lints` and add a new command `lint` - [#2013](https://github.com/use-ink/cargo-contract/pull/2013)

## [5.0.1]

Expand Down
6 changes: 3 additions & 3 deletions build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ RUN set -eux \
&& chmod +x rustup-init \
&& ./rustup-init -y --no-modify-path --profile minimal --component rust-src,rustfmt,clippy --default-toolchain $RUST_VERSION \
&& rm rustup-init \
# Install nightly toolchain required by `cargo contract build --verifiable --lint` command
# Install nightly toolchain required by `cargo contract build --verifiable --extra-lints` command
&& rustup install ${RUST_LINTER_VERSION} --profile minimal \
&& rustup component add rust-src --toolchain ${RUST_LINTER_VERSION} \
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
Expand Down Expand Up @@ -100,13 +100,13 @@ RUN apt-get -y update && apt-get -y install gcc=${GCC_VERSION} g++=${G_VERSION}
fi \
&& echo "Executing ${COMMAND}" \
&& eval "${COMMAND}" \
# Install cargo-dylint, dylint-link required by `cargo contract build --verifiable --lint` command
# Install cargo-dylint, dylint-link required by `cargo contract build --verifiable --extra-lints` command
&& cargo +${RUST_LINTER_VERSION} install cargo-dylint dylint-link \
# Check if build with linting works
&& mkdir -p $DYLINT_DRIVER_PATH \
&& cargo contract new test \
# Generate /usr/local/dylint_drivers/nightly-2024-02-20-x86_64-unknown-linux-gnu/dylint-driver bin
&& cd test && cargo contract build --lint --verbose --release && cd .. \
&& cd test && cargo contract build --extra-lints --verbose --release && cd .. \
&& rm -rf test \
# apt clean up
&& apt-get remove -y gnupg libssl-dev pkg-config \
Expand Down
1 change: 0 additions & 1 deletion crates/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ let args = contract_build::ExecuteArgs {
keep_debug_symbols: false,
extra_lints: false,
output_type: OutputType::Json,
skip_clippy_and_linting: false,
image: ImageVariant::Default,
metadata_spec: MetadataSpec::Ink,
};
Expand Down
Loading
Loading