foundry icon indicating copy to clipboard operation
foundry copied to clipboard

chore: fix compilation warnings in Foundry's Solidity test suite

Open knelsondev opened this issue 6 months ago • 4 comments

Motivation

This PR aims to close #10577

Solution

PR Checklist

  • [ ] Added Tests
  • [ ] Added Documentation
  • [ ] Breaking changes

knelsondev avatar Jun 10 '25 07:06 knelsondev

@zerosnacks Please look into this PR and let me know if it resolves #10577

knelsondev avatar Jun 10 '25 07:06 knelsondev

Hi @knelsondev unfortunately these changes do not resolve the compilation warnings; please see the instructions in the ticket on how to iteratively fix them

zerosnacks avatar Jun 10 '25 07:06 zerosnacks

@zerosnacks @grandizzy I need a bit of your help. In the master branch, when I cd testdata and then temporarily comment out solc = "0.8.18 in foundry.toml and run forge build --ignored-error-codes=2018

I get a list of warnings that look like this, and not like the one mentioned in the original issue:

Warning: This is a nightly build of Foundry. It is recommended to use the latest stable version. To mute this warning set `FOUNDRY_DISABLE_NIGHTLY_WARNING` in your environment. 

note[screaming-snake-case-const]: constants should use SCREAMING_SNAKE_CASE
 --> /home/acesif/application/foundry/testdata/default/repros/Issue10586.t.sol:8:17
  |
8 |     Vm constant vm = Vm(HEVM_ADDRESS);
  |                 --
  |
  = help: https://book.getfoundry.sh/reference/forge/forge-lint#screaming-snake-case-const

note[screaming-snake-case-const]: constants should use SCREAMING_SNAKE_CASE
 --> /home/acesif/application/foundry/testdata/default/cheats/Prevrandao.t.sol:8:17
  |
8 |     Vm constant vm = Vm(HEVM_ADDRESS);
  |                 --
  |
  = help: https://book.getfoundry.sh/reference/forge/forge-lint#screaming-snake-case-const

note[mixed-case-variable]: mutable variables should use mixedCase
  --> /home/acesif/application/foundry/testdata/lib/ds-test/src/test.sol:38:17
   |
38 |     bool public IS_TEST = true;
   |                 -------
   |
   = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable

note[screaming-snake-case-const]: constants should use SCREAMING_SNAKE_CASE
  --> /home/acesif/application/foundry/testdata/default/cheats/GetCode.t.sol:12:17
   |
12 |     Vm constant vm = Vm(HEVM_ADDRESS);
   |                 --
   |
   = help: https://book.getfoundry.sh/reference/forge/forge-lint#screaming-snake-case-const

note[screaming-snake-case-const]: constants should use SCREAMING_SNAKE_CASE
  --> /home/acesif/application/foundry/testdata/default/cheats/Wallet.t.sol:10:17
   |
10 |     Vm constant vm = Vm(HEVM_ADDRESS);
   |                 --
   |
   = help: https://book.getfoundry.sh/reference/forge/forge-lint#screaming-snake-case-const

note[screaming-snake-case-const]: constants should use SCREAMING_SNAKE_CASE
 --> /home/acesif/application/foundry/testdata/default/cheats/getBlockNumber.t.sol:8:17
  |
8 |     Vm constant vm = Vm(HEVM_ADDRESS);
  |                 --
  |
  = help: https://book.getfoundry.sh/reference/forge/forge-lint#screaming-snake-case-const

note[mixed-case-function]: function names should use mixedCase
  --> /home/acesif/application/foundry/testdata/lib/ds-test/src/test.sol:81:14
   |
81 |     function hasHEVMContext() internal view returns (bool) {
   |              --------------
   |
   = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-function

note[mixed-case-function]: function names should use mixedCase
  --> /home/acesif/application/foundry/testdata/lib/ds-test/src/test.sol:89:14
   |
89 |     modifier logs_gas() {
   |              --------
   |
   = help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-function

note[screaming-snake-case-const]: constants should use SCREAMING_SNAKE_CASE
 --> /home/acesif/application/foundry/testdata/default/cheats/Blobhashes.t.sol:8:17
  |
8 |     Vm constant vm = Vm(HEVM_ADDRESS);
  |                 --
  |
  = help: https://book.getfoundry.sh/reference/forge/forge-lint#screaming-snake-case-const

note[screaming-snake-case-const]: constants should use SCREAMING_SNAKE_CASE
  --> /home/acesif/application/foundry/testdata/default/cheats/Mapping.t.sol:22:17
   |
22 |     Vm constant vm = Vm(HEVM_ADDRESS);
   |                 --
   |
   = help: https://book.getfoundry.sh/reference/forge/forge-lint#screaming-snake-case-const

knelsondev avatar Jun 13 '25 03:06 knelsondev

Hi @knelsondev, ah yes - in the latest nightly we have enabled the running of forge lint by default.

You can disable this by setting:

[lint]
lint_on_build = false

in the foundry.toml

You can ignore these warnings raised by the linting; this PR relates to warnings raised by the Solidity compiler.

zerosnacks avatar Jun 13 '25 07:06 zerosnacks

bump @knelsondev :saluting_face:

onbjerg avatar Sep 15 '25 13:09 onbjerg

Hi @knelsondev, since this PR is inactive, I'm going to close it. I appreciate the time you put into this, and I do appreciate that this going stale is on us given the slow turn around time. Sorry about that. Feel free to open up a similar PR again if you find the bandwidth :)

onbjerg avatar Sep 18 '25 14:09 onbjerg