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

Conversation

chungquantin
Copy link
Contributor

@chungquantin chungquantin commented Apr 21, 2025

Summary

Closes #1989

  • y/n | Does it introduce breaking changes?
  • y/n | Is it dependent on the specific version of ink or pallet-contracts?

Description

  • Move the linting logic from build/lib.rs to a separate lint.rs file.
  • Remove skip_clippy_and_linting flag from the cargo contract build command. Adjust the lint flag to requires the --generate=check-only if the flag is provided.
  • Add a new lint command to only run linting the contract.
  • Add lint_code_only test.
➜ 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

      --lint
          Performs extra linting checks for ink! specific issues during the build process.

          Basic clippy lints are deemed important and run anyway.

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

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have added an entry to CHANGELOG.md
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@chungquantin chungquantin changed the title feat: add lint command feat: remove skip_clippy_and_linting flag from build command + add lint command Apr 21, 2025
Copy link
Contributor

@al3mart al3mart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick review at it and it looks good :)

Have left a couple of comments. One regarding the change of the name for the option --lint within the lint command so it reads less repetitive and the name a bit more meaningful given this new context.

The other comment is a nit about a potential refactor of module linting which I am not sure might be worth the effort, haven't either look for usages of that module across the codebase.

///
/// Basic clippy lints are deemed important and run anyway.
#[clap(long)]
lint: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this is only used to run extra lints via dylint aside from clippy lints. Might be worth changing the name of the option to extra-lints or dylint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I have renamed it to dylint and updated the comment above

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chungquantin @al3mart dylint is an implementation detail, so extra-lints is a better user-facing name if we're renaming this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidsemakula I see, that makes sense and more user friendly. I reverted back to extra-lints.

@chungquantin chungquantin requested a review from al3mart April 22, 2025 03:58
Copy link
Contributor

@al3mart al3mart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

One consideration would be adding in some deprecation messages for the options we are removing. But I think we should be mostly OK if we decide not doing so.

@davidsemakula davidsemakula requested review from davidsemakula and removed request for ascjones and cmichi April 24, 2025 06:47
Copy link
Collaborator

@davidsemakula davidsemakula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Except for one high-level comment 🙂

Copy link
Collaborator

@davidsemakula davidsemakula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chungquantin

@davidsemakula davidsemakula merged commit 7abd306 into use-ink:master Apr 24, 2025
13 checks passed
davidsemakula added a commit to use-ink/ink that referenced this pull request Apr 24, 2025
* feat:  if not mapped yet

* chore: fix method name and add CHANGELOG

* fix: clippy warnings

* original_account_entry

* chore: minor fixes

* chore: add new error type

* chore: Remove `skip_clippy_and_linting` from contract_build args

See use-ink/cargo-contract#2015

---------

Co-authored-by: davidsemakula <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change linting behavior of cargo contract build
3 participants