Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
74fab99
feat(cast): added custom polling interval args
dipanshuhappy Oct 30, 2025
3b03b3d
feat(cast): added a custom alias for poll interval
dipanshuhappy Oct 30, 2025
6992ffb
feat(cast): updated with clippy suggestion
dipanshuhappy Oct 30, 2025
8f41f4c
feat(cast): added multi fields to cast block
dipanshuhappy Nov 2, 2025
f5863b9
Merge branch 'master' of https://github.com/foundry-rs/foundry
dipanshuhappy Nov 3, 2025
d00864c
feat(cast): num of args needed for fields in block set to 0
dipanshuhappy Nov 3, 2025
ccc98a9
chore: updated with formatting
dipanshuhappy Nov 3, 2025
b34c60f
feat(cast): added long field to cast block
dipanshuhappy Nov 3, 2025
de99dcd
doc(cast): updated docs to match change in fields
dipanshuhappy Nov 3, 2025
e41c2f2
test(cast): Remove trailing whitespace from block output
dipanshuhappy Nov 11, 2025
90dfd30
Merge branch 'master' into master
dipanshuhappy Nov 11, 2025
2d92457
Merge branch 'master' into master
dipanshuhappy Nov 13, 2025
4c21736
feat(forge): set default serverity to low in forge lint
dipanshuhappy Nov 29, 2025
e44d1fe
Merge branch 'master' of https://github.com/foundry-rs/foundry into f…
dipanshuhappy Dec 4, 2025
d209fe6
feat(forge): supress serverity gas if serverity is none
dipanshuhappy Dec 4, 2025
d1cdf9a
chore(forge): updated test cases
dipanshuhappy Dec 4, 2025
642b5a3
Merge branch 'master' into feat/forge-lint-verbosity
dipanshuhappy Dec 5, 2025
79391cd
Merge branch 'master' into feat/forge-lint-verbosity
dipanshuhappy Dec 9, 2025
b616a51
Merge branch 'master' into feat/forge-lint-verbosity
dipanshuhappy Dec 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/lint/src/sol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ impl<'a> SolidityLinter<'a> {
}

fn include_lint(&self, lint: SolLint) -> bool {
self.severity.as_ref().is_none_or(|sev| sev.contains(&lint.severity()))
let excluded_severity: Vec<Severity> = vec![Severity::Gas];
let severity_check = match &self.severity {
None => !excluded_severity.contains(&lint.severity()),
Some(sev) => sev.contains(&lint.severity()),
};
severity_check
&& self.lints_included.as_ref().is_none_or(|incl| incl.contains(&lint))
&& !self.lints_excluded.as_ref().is_some_and(|excl| excl.contains(&lint))
}
Expand Down
56 changes: 39 additions & 17 deletions crates/lint/testdata/Keccak256.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.18;

contract AsmKeccak256 {

// constants are optimized by the compiler
bytes32 constant HASH = keccak256("hello");
bytes32 constant OTHER_HASH = keccak256(hex"1234");
Expand All @@ -15,7 +14,7 @@ contract AsmKeccak256 {

// lints fire before the disabled block
address c = address(1);
bytes32 hash = keccak256(abi.encodePacked(a, b, bytes32(bytes20(c)))); //~NOTE: inefficient hashing mechanism
bytes32 hash = keccak256(abi.encodePacked(a, b, bytes32(bytes20(c))));
uint256 MixedCase_Variable = 1; //~NOTE: mutable variables should use mixedCase

// forge-lint: disable-start(asm-keccak256) -------------------------------------
Expand All @@ -31,25 +30,33 @@ contract AsmKeccak256 {
// forge-lint: disable-end(asm-keccak256) ---------------------------------------

// lints still fire after the disabled block
bytes32 afterDisabledBlock = keccak256(abi.encode(a, b, c)); //~NOTE: inefficient hashing mechanism
bytes32 afterDisabledBlock = keccak256(abi.encode(a, b, c));
uint256 YetAnother_MixedCase = 3; //~NOTE: mutable variables should use mixedCase
}

// forge-lint: disable-next-item(asm-keccak256)
function solidityHashDisabled(uint256 a, uint256 b) public view returns (bytes32) {
function solidityHashDisabled(
uint256 a,
uint256 b
) public view returns (bytes32) {
bytes32 hash = keccak256(abi.encodePacked(a));
return keccak256(abi.encodePacked(a, b));
}

function solidityHash(bytes calldata z, uint256 a, uint256 b, address c) public view returns (bytes32) {
bytes32 loadsFromCalldata = keccak256(z); //~NOTE: inefficient hashing mechanism
function solidityHash(
bytes calldata z,
uint256 a,
uint256 b,
address c
) public view returns (bytes32) {
bytes32 loadsFromCalldata = keccak256(z);
bytes memory y = z;
bytes32 loadsFromMemory = keccak256(y); //~NOTE: inefficient hashing mechanism
bytes32 lintWithoutFix = keccak256(abi.encodePacked(a, b, c)); //~NOTE: inefficient hashing mechanism
return keccak256(abi.encode(a, b, c)); //~NOTE: inefficient hashing mechanism
bytes32 loadsFromMemory = keccak256(y);
bytes32 lintWithoutFix = keccak256(abi.encodePacked(a, b, c));
return keccak256(abi.encode(a, b, c));
}

function assemblyHash(uint256 a, uint256 b) public view returns (bytes32){
function assemblyHash(uint256 a, uint256 b) public view returns (bytes32) {
//optimized
assembly {
mstore(0x00, a)
Expand All @@ -63,24 +70,39 @@ contract AsmKeccak256 {
contract OtherAsmKeccak256 {
uint256 Enabled_MixedCase_Variable; //~NOTE: mutable variables should use mixedCase

function contratDisabledHash(uint256 a, uint256 b) public view returns (bytes32) {
function contratDisabledHash(
uint256 a,
uint256 b
) public view returns (bytes32) {
return keccak256(abi.encode(a, b));
}

function contratDisabledHash2(uint256 a, uint256 b) public view returns (bytes32) {
function contratDisabledHash2(
uint256 a,
uint256 b
) public view returns (bytes32) {
return keccak256(abi.encodePacked(a, b));
}
}

contract YetAnotherAsmKeccak256 {
function nonDisabledHash(uint256 x, uint256 y) public view returns (bytes32) {
bytes32 doesNotUseScratchSpace = keccak256(abi.encode(x, y, x, y, x, y)); //~NOTE: inefficient hashing mechanism
bytes32 doesUseScratchSpace = keccak256(abi.encode(x)); //~NOTE: inefficient hashing mechanism
return keccak256(abi.encode(doesUseScratchSpace, doesNotUseScratchSpace)); //~NOTE: inefficient hashing mechanism
function nonDisabledHash(
uint256 x,
uint256 y
) public view returns (bytes32) {
bytes32 doesNotUseScratchSpace = keccak256(
abi.encode(x, y, x, y, x, y)
);
bytes32 doesUseScratchSpace = keccak256(abi.encode(x));
return
keccak256(abi.encode(doesUseScratchSpace, doesNotUseScratchSpace));
}

// forge-lint: disable-next-item(asm-keccak256)
function functionDisabledHash(uint256 a, uint256 b) public view returns (bytes32) {
function functionDisabledHash(
uint256 a,
uint256 b
) public view returns (bytes32) {
uint256 Enabled_MixedCase_Variable = 1; //~NOTE: mutable variables should use mixedCase
return keccak256(abi.encodePacked(a, b));
}
Expand Down
72 changes: 0 additions & 72 deletions crates/lint/testdata/Keccak256.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,75 +38,3 @@ LL | uint256 Enabled_MixedCase_Variable = 1;
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#mixed-case-variable

note[asm-keccak256]: use of inefficient hashing mechanism; consider using inline assembly
--> ROOT/testdata/Keccak256.sol:LL:CC
|
LL | bytes32 hash = keccak256(abi.encodePacked(a, b, bytes32(bytes20(c))));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256

note[asm-keccak256]: use of inefficient hashing mechanism; consider using inline assembly
--> ROOT/testdata/Keccak256.sol:LL:CC
|
LL | bytes32 afterDisabledBlock = keccak256(abi.encode(a, b, c));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256

note[asm-keccak256]: use of inefficient hashing mechanism; consider using inline assembly
--> ROOT/testdata/Keccak256.sol:LL:CC
|
LL | bytes32 loadsFromCalldata = keccak256(z);
| ^^^^^^^^^^^^
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256

note[asm-keccak256]: use of inefficient hashing mechanism; consider using inline assembly
--> ROOT/testdata/Keccak256.sol:LL:CC
|
LL | bytes32 loadsFromMemory = keccak256(y);
| ^^^^^^^^^^^^
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256

note[asm-keccak256]: use of inefficient hashing mechanism; consider using inline assembly
--> ROOT/testdata/Keccak256.sol:LL:CC
|
LL | bytes32 lintWithoutFix = keccak256(abi.encodePacked(a, b, c));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256

note[asm-keccak256]: use of inefficient hashing mechanism; consider using inline assembly
--> ROOT/testdata/Keccak256.sol:LL:CC
|
LL | return keccak256(abi.encode(a, b, c));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256

note[asm-keccak256]: use of inefficient hashing mechanism; consider using inline assembly
--> ROOT/testdata/Keccak256.sol:LL:CC
|
LL | bytes32 doesNotUseScratchSpace = keccak256(abi.encode(x, y, x, y, x, y));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256

note[asm-keccak256]: use of inefficient hashing mechanism; consider using inline assembly
--> ROOT/testdata/Keccak256.sol:LL:CC
|
LL | bytes32 doesUseScratchSpace = keccak256(abi.encode(x));
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256

note[asm-keccak256]: use of inefficient hashing mechanism; consider using inline assembly
--> ROOT/testdata/Keccak256.sol:LL:CC
|
LL | return keccak256(abi.encode(doesUseScratchSpace, doesNotUseScratchSpace));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256

Loading