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

Option to ignore warnings from dependencies in foundry.toml #1200

Closed
pmdaly opened this issue Apr 5, 2022 · 12 comments
Closed

Option to ignore warnings from dependencies in foundry.toml #1200

pmdaly opened this issue Apr 5, 2022 · 12 comments
Assignees
Labels
C-forge Command: forge Cmd-forge-build Command: forge build D-average Difficulty: average first issue A good way to start contributing T-feature Type: feature

Comments

@pmdaly
Copy link

pmdaly commented Apr 5, 2022

Component

Forge

Describe the feature you would like

Some of my projects have dependencies I can't change. Due to implementations of some of the abstract contracts, there are unused imports that cause warnings. These warnings spam my stdout and aren't relevant to my projects. I'd like the ability to silence warnings from dependencies.

Additional context

No response

@pmdaly pmdaly added the T-feature Type: feature label Apr 5, 2022
@pmdaly pmdaly changed the title Option to ignore dependencies in foundry.toml Option to ignore warnings from dependencies in foundry.toml Apr 5, 2022
@onbjerg onbjerg added this to Foundry Apr 17, 2022
@onbjerg onbjerg moved this to Todo in Foundry Apr 17, 2022
@onbjerg onbjerg added C-forge Command: forge Cmd-forge-build Command: forge build labels Apr 18, 2022
@mattsse mattsse added first issue A good way to start contributing D-average Difficulty: average labels May 20, 2022
@Alef-gabriel
Copy link

I can take this?

@mattsse
Copy link
Member

mattsse commented Jun 16, 2023

sure!
I think this would require parsing the error message and check where they originated from

lmk if you need some pointers, happy to take a look where we can get that info

@Alef-gabriel
Copy link

@mattsse of course, thanks

@Alef-gabriel
Copy link

Hello guys I tried to replicate your issue but I couldn't. Could you share exactly what I do?

@guidanoli
Copy link

guidanoli commented Sep 14, 2023

@Alef-gabriel To replicate this problem, try this project. It should raise several warnings:

Warning (2519): This declaration shadows an existing declaration.
  --> ../node_modules/@ensdomains/ens-contracts/contracts/registry/ENSRegistry.sol:20:9:
   |
20 |         address owner = records[node].owner;
   |         ^^^^^^^^^^^^^
Note: The shadowed declaration is here:
   --> ../node_modules/@ensdomains/ens-contracts/contracts/registry/ENSRegistry.sol:143:5:
    |
143 |     function owner(
    |     ^ (Relevant source part starts here and spans across multiple lines).

[...]

@wottpal
Copy link

wottpal commented Feb 3, 2024

@guidanoli Did you find any solution to this?

@mattsse
Copy link
Member

mattsse commented Feb 3, 2024

@loocapro perhaps you want to take this?

I believe this can be solved with:

The current workflow wrt to ignored errors is:
configure ignored error types in foundry.toml, which is then configured in the foundry_compilers::Project:

.ignore_error_codes(self.ignored_error_codes.iter().copied().map(Into::into))

I think we want to enhance that setting to also make it possible to ignore paths

@mattsse
Copy link
Member

mattsse commented Feb 3, 2024

but for this specific error @wottpal you can silence this via:

ignored_error_codes = ["shadowing"], though this apply to all files atm

@wottpal
Copy link

wottpal commented Feb 3, 2024

but for this specific error @wottpal you can silence this via:

ignored_error_codes = ["shadowing"], though this apply to all files atm

Great, that already removes a lot of warnings when having ens contracts as a dependency in node_modules. Thanks!

But some are still persisting:

Compiler run successful with warnings:
Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> node_modules/@ensdomains/ens-contracts/contracts/ethregistrar/IBaseRegistrar.sol

Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> node_modules/@ensdomains/ens-contracts/contracts/ethregistrar/StringUtils.sol

Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> node_modules/@ensdomains/ens-contracts/contracts/registry/ENS.sol

Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> node_modules/@ensdomains/ens-contracts/contracts/registry/ENSRegistry.sol

Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> node_modules/@ensdomains/ens-contracts/contracts/reverseRegistrar/IReverseRegistrar.sol

Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> node_modules/@ensdomains/ens-contracts/contracts/root/Controllable.sol

Warning (3420): Source file does not specify required compiler version! Consider adding "pragma solidity ^0.8.22;"
--> node_modules/@ensdomains/ens-contracts/contracts/ethregistrar/IBaseRegistrar.sol

Warning (2462): Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
  --> node_modules/@ensdomains/ens-contracts/contracts/registry/ENSRegistry.sol:28:5:
   |
28 |     constructor() public {
   |     ^ (Relevant source part starts here and spans across multiple lines).

And ofc I could just ignore the specific error code, but actually I would like to get those for all files under src/, just not node_modules/ :)

@mattsse
Copy link
Member

mattsse commented Feb 3, 2024

here's a list of supported aliases:

"unreachable" => SolidityErrorCode::Unreachable,
"unused-return" => SolidityErrorCode::UnnamedReturnVariable,
"unused-param" => SolidityErrorCode::UnusedFunctionParameter,
"unused-var" => SolidityErrorCode::UnusedLocalVariable,
"code-size" => SolidityErrorCode::ContractExceeds24576Bytes,
"init-code-size" => SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes,
"shadowing" => SolidityErrorCode::ShadowsExistingDeclaration,
"func-mutability" => SolidityErrorCode::FunctionStateMutabilityCanBeRestricted,
"license" => SolidityErrorCode::SpdxLicenseNotProvided,
"pragma-solidity" => SolidityErrorCode::PragmaSolidity,
"virtual-interfaces" => SolidityErrorCode::InterfacesExplicitlyVirtual,
"missing-receive-ether" => SolidityErrorCode::PayableNoReceiveEther,
"same-varname" => SolidityErrorCode::DeclarationSameNameAsAnother,

but the error code works as well

@loocapro
Copy link
Contributor

loocapro commented Feb 3, 2024

@loocapro perhaps you want to take this?

Sure, I can take it!

@mattsse mattsse assigned loocapro and unassigned Alef-gabriel Feb 5, 2024
mattsse added a commit to foundry-rs/compilers that referenced this issue Feb 9, 2024
[Related to #1200](foundry-rs/foundry#1200)

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
@mattsse mattsse closed this as completed Feb 9, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Feb 9, 2024
@mattsse
Copy link
Member

mattsse commented Feb 9, 2024

this is now supported via new config setting ignored_warnings_from = [path],

will add to book

@jenpaff jenpaff moved this from Done to Completed in Foundry Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-build Command: forge build D-average Difficulty: average first issue A good way to start contributing T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

7 participants