-
Notifications
You must be signed in to change notification settings - Fork 120
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
Add ink! linting MVP stage #431
Conversation
Maybe better to require the user to always implement If the contract implements Example of the idea in the playground. impl Contract {
#[ink(constrcutor)]
fn new(mut self/* we will require `self` here*/, total_supply: u32) -> Self {
self.total_supply = total_supply;
self
}
} |
f4c6e04
to
e76bce7
Compare
de13be5
to
899d3a7
Compare
@xgreenx Thanks for your comment! So the thing is that we don't want to change the ink! constructor function signature, we would really like to stay as close to Rust syntax as possible. Putting the Our thinking right now is that we will likely find a better way going forward and by requiring the |
ad3962b
to
27451a6
Compare
c1a772a
to
228aa04
Compare
228aa04
to
82a8d4c
Compare
Thanks for the response. I see you are right. I forgot about off-chain unit tests that the problem still exists for them.
Yesterday I tried to implement your idea regarding the new structure of the contract. Here is results. Maybe you can check it in your free time=) |
Co-authored-by: Sergejs Kostjucenko <85877331+sergejparity@users.noreply.github.com>
This reverts commit b599831.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
); | ||
zip_dir(&template_dir, &template_dst_file, CompressionMethod::Stored).map(|_| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of map
ping into an io side effect, but now I am just nitpicking
I am wondering: We are writing our custom link but don't even run the stock clippy lints. Can we do that at the same time as we are running dylint so we don't have multiple passes? |
So dylint doesn't support the stock clippy lints out of the box, it would be an additional invocation of |
Is that possible to use |
Closes #281.
This is an MVP, there are a couple shortcomings for which I want to create follow-up issues:
As it is now, we unfortunately have to require users to install
dylint
anddylint-driver
manually. We should look into making those cargo dependencies instead. However, this is not straight forward. Especially for thedylint-driver
(which is used as a linker) I'm not sure if this is even possible.I haven't yet managed to get rid of some driver build overhead, this happens every time the linting is applied:
We should render and publish a proper website displaying info about the linting rules. Similar to https://rust-lang.github.io/rust-clippy/master/.
We should recognize if the call to
ink_lang::utils::initialize_contract
is nested within the constructor. So if it's not called directly in the constructor, but instead in a sub-function.How it works:
ink_linting/
contains the ink! linting driver (i.e. the linting rules).build.rs
builds these rules into a*.so
/*.dll
, this file is included viainclude_bytes!
into thecargo-contract
executable.Try it out: