Skip to content
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

Feature: Implement automatic fix for roots with different contract name #60

Open
alexfertel opened this issue Mar 2, 2024 · 3 comments
Labels
Feat New feature or request Uphill Needs research before being implemented

Comments

@alexfertel
Copy link
Owner

ContractName::func1
└── It should have a name mismatch in the contracts.

MismatchedContractName::func2
└── It should have a name mismatch in the contracts.

For the above tree, we get the following message when running bulloak check:

$ cargo run -- check tests/check/contract_names_mismatch_multiple_roots.tree
warn: an error occurred while parsing the tree: contract name mismatch: expected 'ContractName', found 'MismatchedContractName'
   --> tests/check/contract_names_mismatch_multiple_roots.tree

warn: 1 check failed

We should make the violation fixable and implement the auto fix.

@alexfertel alexfertel added Feat New feature or request Good First Issue Good for newcomers labels Mar 2, 2024
@alexfertel
Copy link
Owner Author

Adding a bit more of color on the work needed here:

Violations can be fixable, meaning there may be a sequence of steps to fix them by bulloak itself. For example, if a tree root is MyContract and the contract in the solidity file is named MyBeautifulContract, it's very easy to fix it by just renaming the contract.

In that specific issue, two roots in the same .tree have different contract names. However, they describe functions in the same generated contract, so the roots should be the same. This is fixable by, for example, replacing every root that is not correct with whatever the contract name is in the first root.

Two changes are needed to implement this: first, making the violations fixable because they aren't by default, and then implementing the actual fix so that when we run bulloak check —-fix, it takes violations away.

@simon-something
Copy link
Contributor

simon-something commented Jul 3, 2024

Violations can be fixable, meaning there may be a sequence of steps to fix them by bulloak itself. For example, if a tree root is MyContract and the contract in the solidity file is named MyBeautifulContract, it's very easy to fix it by just renaming the contract.

I'm currently in a campaign to implement systematic use of Bulloak within my org, and one thing we now do to have an "easy" CI/nice dev ex is to use the suffix _Unit in our roots (and then run all the unit test with --mc Unit).

"Enforcing" tree root == name of the tested contract would break this then (I know, we could then match the glob path instead, but it's less straightforward/dev friendly imo). Anecdotical report tho, I don't know if others are doing something similar.

@alexfertel
Copy link
Owner Author

alexfertel commented Jul 3, 2024

I'm currently in a campaign to implement systematic use of Bulloak within my org

Let's goooo 🚀 Please share all the feedback you have, happy to help with this.

"Enforcing" tree root == name of the tested contract would break this then

Hehe, use case for a bulloak.toml with

[lints]
matching_contract_names = "allow"

Thanks for bringing this up.

@alexfertel alexfertel added Uphill Needs research before being implemented and removed Good First Issue Good for newcomers labels Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feat New feature or request Uphill Needs research before being implemented
Projects
None yet
Development

No branches or pull requests

2 participants