diff --git a/aderyn_core/src/detect/low/state_variable_could_be_constant.rs b/aderyn_core/src/detect/low/state_variable_could_be_constant.rs index 426c5569..daa5450e 100644 --- a/aderyn_core/src/detect/low/state_variable_could_be_constant.rs +++ b/aderyn_core/src/detect/low/state_variable_could_be_constant.rs @@ -51,7 +51,15 @@ impl IssueDetector for StateVariableCouldBeConstantDetector { let collection_b_ids: HashSet<_> = collection_b.into_iter().map(|v| v.id).collect(); // RESULT = collection A - collection B - for variable in collection_a { + for variable in collection_a.into_iter().filter(|s| { + // Do not report it if it's a struct / mapping / contract type + s.type_descriptions + .type_string + .as_ref() + .is_some_and(|type_string| { + !type_string.starts_with("mapping") && !type_string.starts_with("struct") + }) + }) { if !collection_b_ids.contains(&variable.id) { capture!(self, context, variable); } diff --git a/reports/adhoc-sol-files-report.md b/reports/adhoc-sol-files-report.md index 5be6438b..1f8589af 100644 --- a/reports/adhoc-sol-files-report.md +++ b/reports/adhoc-sol-files-report.md @@ -749,7 +749,7 @@ State variable appears to be unused. No analysis has been performed to see if an State variables that are not updated following deployment should be declared constant to save gas. Add the `constant` attribute to state variables that never change. -
14 Found Instances +
13 Found Instances - Found in InconsistentUints.sol [Line: 7](../tests/adhoc-sol-files/InconsistentUints.sol#L7) @@ -770,12 +770,6 @@ State variables that are not updated following deployment should be declared con uint[] public uintArray; // 4 ``` -- Found in InconsistentUints.sol [Line: 16](../tests/adhoc-sol-files/InconsistentUints.sol#L16) - - ```solidity - mapping(uint256 => uint other) u2uMapping; // 5 3 - ``` - - Found in StateVariables.sol [Line: 8](../tests/adhoc-sol-files/StateVariables.sol#L8) ```solidity diff --git a/reports/ccip-functions-report.md b/reports/ccip-functions-report.md index 18346f80..5038969c 100644 --- a/reports/ccip-functions-report.md +++ b/reports/ccip-functions-report.md @@ -2455,7 +2455,7 @@ Avoid `require` / `revert` statements in a loop because a single bad item can ca State variables that are not updated following deployment should be declared constant to save gas. Add the `constant` attribute to state variables that never change. -
27 Found Instances +
22 Found Instances - Found in src/v0.8/functions/dev/v1_X/FunctionsBilling.sol [Line: 66](../tests/ccip-contracts/contracts/src/v0.8/functions/dev/v1_X/FunctionsBilling.sol#L66) @@ -2488,18 +2488,6 @@ State variables that are not updated following deployment should be declared con IOwnableFunctionsRouter private immutable i_functionsRouter; ``` -- Found in src/v0.8/functions/dev/v1_X/accessControl/TermsOfServiceAllowList.sol [Line: 21](../tests/ccip-contracts/contracts/src/v0.8/functions/dev/v1_X/accessControl/TermsOfServiceAllowList.sol#L21) - - ```solidity - EnumerableSet.AddressSet private s_allowedSenders; - ``` - -- Found in src/v0.8/functions/dev/v1_X/accessControl/TermsOfServiceAllowList.sol [Line: 22](../tests/ccip-contracts/contracts/src/v0.8/functions/dev/v1_X/accessControl/TermsOfServiceAllowList.sol#L22) - - ```solidity - EnumerableSet.AddressSet private s_blockedSenders; - ``` - - Found in src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol [Line: 15](../tests/ccip-contracts/contracts/src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol#L15) ```solidity @@ -2548,12 +2536,6 @@ State variables that are not updated following deployment should be declared con IOwnableFunctionsRouter private immutable i_router; ``` -- Found in src/v0.8/functions/v1_0_0/accessControl/TermsOfServiceAllowList.sol [Line: 21](../tests/ccip-contracts/contracts/src/v0.8/functions/v1_0_0/accessControl/TermsOfServiceAllowList.sol#L21) - - ```solidity - EnumerableSet.AddressSet private s_allowedSenders; - ``` - - Found in src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol [Line: 15](../tests/ccip-contracts/contracts/src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol#L15) ```solidity @@ -2608,18 +2590,6 @@ State variables that are not updated following deployment should be declared con IFunctionsRouter internal immutable i_functionsRouter; ``` -- Found in src/v0.8/functions/v1_3_0/accessControl/TermsOfServiceAllowList.sol [Line: 22](../tests/ccip-contracts/contracts/src/v0.8/functions/v1_3_0/accessControl/TermsOfServiceAllowList.sol#L22) - - ```solidity - EnumerableSet.AddressSet private s_allowedSenders; - ``` - -- Found in src/v0.8/functions/v1_3_0/accessControl/TermsOfServiceAllowList.sol [Line: 23](../tests/ccip-contracts/contracts/src/v0.8/functions/v1_3_0/accessControl/TermsOfServiceAllowList.sol#L23) - - ```solidity - EnumerableSet.AddressSet private s_blockedSenders; - ``` -
diff --git a/reports/report.json b/reports/report.json index d69c8e44..c432769a 100644 --- a/reports/report.json +++ b/reports/report.json @@ -5088,30 +5088,6 @@ "src": "337:7", "src_char": "337:7" }, - { - "contract_path": "src/DeletionNestedMappingStructureContract.sol", - "line_no": 12, - "src": "236:6", - "src_char": "236:6" - }, - { - "contract_path": "src/EnumerableSetIteration.sol", - "line_no": 11, - "src": "392:10", - "src_char": "392:10" - }, - { - "contract_path": "src/EnumerableSetIteration.sol", - "line_no": 12, - "src": "441:10", - "src_char": "441:10" - }, - { - "contract_path": "src/EnumerableSetIteration.sol", - "line_no": 13, - "src": "487:7", - "src_char": "487:7" - }, { "contract_path": "src/FunctionInitializingState.sol", "line_no": 6, @@ -5172,12 +5148,6 @@ "src": "383:9", "src_char": "383:9" }, - { - "contract_path": "src/InconsistentUints.sol", - "line_no": 16, - "src": "434:10", - "src_char": "434:10" - }, { "contract_path": "src/IncorrectCaretOperator.sol", "line_no": 10, @@ -5274,12 +5244,6 @@ "src": "130:26", "src_char": "130:26" }, - { - "contract_path": "src/PublicVariableReadInExternalContext.sol", - "line_no": 7, - "src": "162:39", - "src_char": "162:39" - }, { "contract_path": "src/ReturnBomb.sol", "line_no": 61, @@ -5400,42 +5364,12 @@ "src": "2298:5", "src_char": "2298:5" }, - { - "contract_path": "src/StateVariablesManipulation.sol", - "line_no": 114, - "src": "3271:15", - "src_char": "3271:15" - }, - { - "contract_path": "src/StateVariablesManipulation.sol", - "line_no": 117, - "src": "3338:5", - "src_char": "3338:5" - }, - { - "contract_path": "src/StateVariablesManipulation.sol", - "line_no": 223, - "src": "6102:6", - "src_char": "6102:6" - }, - { - "contract_path": "src/StateVariablesManipulation.sol", - "line_no": 224, - "src": "6128:7", - "src_char": "6128:7" - }, { "contract_path": "src/StateVariablesManipulation.sol", "line_no": 225, "src": "6162:7", "src_char": "6162:7" }, - { - "contract_path": "src/StateVariablesManipulation.sol", - "line_no": 227, - "src": "6190:5", - "src_char": "6190:5" - }, { "contract_path": "src/StateVariablesManipulation.sol", "line_no": 278, @@ -5454,12 +5388,6 @@ "src": "109:12", "src_char": "109:12" }, - { - "contract_path": "src/TautologyOrContradiction.sol", - "line_no": 5, - "src": "97:30", - "src_char": "97:30" - }, { "contract_path": "src/TautologyOrContradiction.sol", "line_no": 6, @@ -5490,12 +5418,6 @@ "src": "448:3", "src_char": "448:3" }, - { - "contract_path": "src/UninitializedStateVariable.sol", - "line_no": 13, - "src": "503:3", - "src_char": "503:3" - }, { "contract_path": "src/UninitializedStateVariable.sol", "line_no": 15, @@ -5603,12 +5525,6 @@ "line_no": 29, "src": "486:3", "src_char": "486:3" - }, - { - "contract_path": "src/nested_mappings/LaterVersion.sol", - "line_no": 17, - "src": "416:20", - "src_char": "416:20" } ] } diff --git a/reports/report.md b/reports/report.md index 3365d599..fdcf439b 100644 --- a/reports/report.md +++ b/reports/report.md @@ -5145,7 +5145,7 @@ Name clashes with a built-in-symbol. Consider renaming it. State variables that are not updated following deployment should be declared constant to save gas. Add the `constant` attribute to state variables that never change. -
93 Found Instances +
79 Found Instances - Found in src/AssemblyExample.sol [Line: 5](../tests/contract-playground/src/AssemblyExample.sol#L5) @@ -5184,30 +5184,6 @@ State variables that are not updated following deployment should be declared con address public manager; ``` -- Found in src/DeletionNestedMappingStructureContract.sol [Line: 12](../tests/contract-playground/src/DeletionNestedMappingStructureContract.sol#L12) - - ```solidity - mapping(address => Person) private people; - ``` - -- Found in src/EnumerableSetIteration.sol [Line: 11](../tests/contract-playground/src/EnumerableSetIteration.sol#L11) - - ```solidity - EnumerableSet.Bytes32Set private bytes32Set; - ``` - -- Found in src/EnumerableSetIteration.sol [Line: 12](../tests/contract-playground/src/EnumerableSetIteration.sol#L12) - - ```solidity - EnumerableSet.AddressSet private addressSet; - ``` - -- Found in src/EnumerableSetIteration.sol [Line: 13](../tests/contract-playground/src/EnumerableSetIteration.sol#L13) - - ```solidity - EnumerableSet.UintSet private uintSet; - ``` - - Found in src/FunctionInitializingState.sol [Line: 6](../tests/contract-playground/src/FunctionInitializingState.sol#L6) ```solidity @@ -5268,12 +5244,6 @@ State variables that are not updated following deployment should be declared con uint[] public uintArray; // 4 ``` -- Found in src/InconsistentUints.sol [Line: 16](../tests/contract-playground/src/InconsistentUints.sol#L16) - - ```solidity - mapping(uint256 => uint other) u2uMapping; // 5 3 - ``` - - Found in src/IncorrectCaretOperator.sol [Line: 10](../tests/contract-playground/src/IncorrectCaretOperator.sol#L10) ```solidity @@ -5370,12 +5340,6 @@ State variables that are not updated following deployment should be declared con uint256 public testUint256; ``` -- Found in src/PublicVariableReadInExternalContext.sol [Line: 7](../tests/contract-playground/src/PublicVariableReadInExternalContext.sol#L7) - - ```solidity - mapping(uint256 => bool) public testMap; - ``` - - Found in src/ReturnBomb.sol [Line: 61](../tests/contract-playground/src/ReturnBomb.sol#L61) ```solidity @@ -5496,42 +5460,12 @@ State variables that are not updated following deployment should be declared con uint256[5] public dummy; ``` -- Found in src/StateVariablesManipulation.sol [Line: 114](../tests/contract-playground/src/StateVariablesManipulation.sol#L114) - - ```solidity - Person[5][1] public personsUltimate; - ``` - -- Found in src/StateVariablesManipulation.sol [Line: 117](../tests/contract-playground/src/StateVariablesManipulation.sol#L117) - - ```solidity - Person public dummy; - ``` - -- Found in src/StateVariablesManipulation.sol [Line: 223](../tests/contract-playground/src/StateVariablesManipulation.sol#L223) - - ```solidity - Person public person; - ``` - -- Found in src/StateVariablesManipulation.sol [Line: 224](../tests/contract-playground/src/StateVariablesManipulation.sol#L224) - - ```solidity - Person public person2; - ``` - - Found in src/StateVariablesManipulation.sol [Line: 225](../tests/contract-playground/src/StateVariablesManipulation.sol#L225) ```solidity uint256[5][1] public allAges; ``` -- Found in src/StateVariablesManipulation.sol [Line: 227](../tests/contract-playground/src/StateVariablesManipulation.sol#L227) - - ```solidity - Person public dummy; - ``` - - Found in src/StateVariablesManipulation.sol [Line: 278](../tests/contract-playground/src/StateVariablesManipulation.sol#L278) ```solidity @@ -5550,12 +5484,6 @@ State variables that are not updated following deployment should be declared con uint[1] public storageArray; ``` -- Found in src/TautologyOrContradiction.sol [Line: 5](../tests/contract-playground/src/TautologyOrContradiction.sol#L5) - - ```solidity - mapping(uint256 => uint72) map; - ``` - - Found in src/TautologyOrContradiction.sol [Line: 6](../tests/contract-playground/src/TautologyOrContradiction.sol#L6) ```solidity @@ -5586,12 +5514,6 @@ State variables that are not updated following deployment should be declared con uint256[] public arr; // GOOD ``` -- Found in src/UninitializedStateVariable.sol [Line: 13](../tests/contract-playground/src/UninitializedStateVariable.sol#L13) - - ```solidity - mapping(uint256 => uint256[]) private map; // GOOD - ``` - - Found in src/UninitializedStateVariable.sol [Line: 15](../tests/contract-playground/src/UninitializedStateVariable.sol#L15) ```solidity @@ -5700,12 +5622,6 @@ State variables that are not updated following deployment should be declared con this is longer comment */ uint256 s_5 = 0; ``` -- Found in src/nested_mappings/LaterVersion.sol [Line: 17](../tests/contract-playground/src/nested_mappings/LaterVersion.sol#L17) - - ```solidity - mapping(uint256 => structMain) public s_mapOfNestedStructs; - ``` -
diff --git a/reports/report.sarif b/reports/report.sarif index 2ecfcb24..c8eede0a 100644 --- a/reports/report.sarif +++ b/reports/report.sarif @@ -8381,50 +8381,6 @@ } } }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/DeletionNestedMappingStructureContract.sol" - }, - "region": { - "byteLength": 6, - "byteOffset": 236 - } - } - }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/EnumerableSetIteration.sol" - }, - "region": { - "byteLength": 10, - "byteOffset": 392 - } - } - }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/EnumerableSetIteration.sol" - }, - "region": { - "byteLength": 10, - "byteOffset": 441 - } - } - }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/EnumerableSetIteration.sol" - }, - "region": { - "byteLength": 7, - "byteOffset": 487 - } - } - }, { "physicalLocation": { "artifactLocation": { @@ -8535,17 +8491,6 @@ } } }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/InconsistentUints.sol" - }, - "region": { - "byteLength": 10, - "byteOffset": 434 - } - } - }, { "physicalLocation": { "artifactLocation": { @@ -8722,17 +8667,6 @@ } } }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/PublicVariableReadInExternalContext.sol" - }, - "region": { - "byteLength": 39, - "byteOffset": 162 - } - } - }, { "physicalLocation": { "artifactLocation": { @@ -8953,50 +8887,6 @@ } } }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/StateVariablesManipulation.sol" - }, - "region": { - "byteLength": 15, - "byteOffset": 3271 - } - } - }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/StateVariablesManipulation.sol" - }, - "region": { - "byteLength": 5, - "byteOffset": 3338 - } - } - }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/StateVariablesManipulation.sol" - }, - "region": { - "byteLength": 6, - "byteOffset": 6102 - } - } - }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/StateVariablesManipulation.sol" - }, - "region": { - "byteLength": 7, - "byteOffset": 6128 - } - } - }, { "physicalLocation": { "artifactLocation": { @@ -9008,17 +8898,6 @@ } } }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/StateVariablesManipulation.sol" - }, - "region": { - "byteLength": 5, - "byteOffset": 6190 - } - } - }, { "physicalLocation": { "artifactLocation": { @@ -9052,17 +8931,6 @@ } } }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/TautologyOrContradiction.sol" - }, - "region": { - "byteLength": 30, - "byteOffset": 97 - } - } - }, { "physicalLocation": { "artifactLocation": { @@ -9118,17 +8986,6 @@ } } }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/UninitializedStateVariable.sol" - }, - "region": { - "byteLength": 3, - "byteOffset": 503 - } - } - }, { "physicalLocation": { "artifactLocation": { @@ -9326,17 +9183,6 @@ "byteOffset": 486 } } - }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "src/nested_mappings/LaterVersion.sol" - }, - "region": { - "byteLength": 20, - "byteOffset": 416 - } - } } ], "message": { diff --git a/reports/templegold-report.md b/reports/templegold-report.md index 8b5caa62..c9640889 100644 --- a/reports/templegold-report.md +++ b/reports/templegold-report.md @@ -8706,7 +8706,7 @@ If `x` is a boolean, there is no need to do `if(x == true)` or `if(x == false)`. State variables that are not updated following deployment should be declared constant to save gas. Add the `constant` attribute to state variables that never change. -
23 Found Instances +
11 Found Instances - Found in contracts/amm/TempleUniswapV2Pair.sol [Line: 29](../tests/2024-07-templegold/protocol/contracts/amm/TempleUniswapV2Pair.sol#L29) @@ -8715,30 +8715,12 @@ State variables that are not updated following deployment should be declared con uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event ``` -- Found in contracts/core/MultiOtcOffer.sol [Line: 32](../tests/2024-07-templegold/protocol/contracts/core/MultiOtcOffer.sol#L32) - - ```solidity - EnumerableSet.Bytes32Set private _otcMarketIds; - ``` - -- Found in contracts/core/OpsManager.sol [Line: 18](../tests/2024-07-templegold/protocol/contracts/core/OpsManager.sol#L18) - - ```solidity - mapping(IERC20 => TreasuryFarmingRevenue) public pools; - ``` - - Found in contracts/core/RebasingERC20.sol [Line: 18](../tests/2024-07-templegold/protocol/contracts/core/RebasingERC20.sol#L18) ```solidity uint256 public totalShares; ``` -- Found in contracts/core/RebasingERC20.sol [Line: 25](../tests/2024-07-templegold/protocol/contracts/core/RebasingERC20.sol#L25) - - ```solidity - mapping(address => uint256) public shareBalanceOf; - ``` - - Found in contracts/core/Vault.sol [Line: 33](../tests/2024-07-templegold/protocol/contracts/core/Vault.sol#L33) ```solidity @@ -8763,42 +8745,12 @@ State variables that are not updated following deployment should be declared con uint256 public lastUpdateTime; ``` -- Found in contracts/fakes/templegold/TempleGoldStakingMock.sol [Line: 71](../tests/2024-07-templegold/protocol/contracts/fakes/templegold/TempleGoldStakingMock.sol#L71) - - ```solidity - mapping(address delegate => uint256 balance) private _delegateBalances; - ``` - -- Found in contracts/fakes/templegold/TempleGoldStakingMock.sol [Line: 73](../tests/2024-07-templegold/protocol/contracts/fakes/templegold/TempleGoldStakingMock.sol#L73) - - ```solidity - mapping(address user => uint256 withdrawTime) public userWithdrawTimes; - ``` - -- Found in contracts/fakes/templegold/TempleGoldStakingMock.sol [Line: 79](../tests/2024-07-templegold/protocol/contracts/fakes/templegold/TempleGoldStakingMock.sol#L79) - - ```solidity - mapping(address account => EnumerableSet.UintSet indexes) private _accountStakes; - ``` - - Found in contracts/templegold/AuctionBase.sol [Line: 13](../tests/2024-07-templegold/protocol/contracts/templegold/AuctionBase.sol#L13) ```solidity uint256 internal _currentEpochId; ``` -- Found in contracts/templegold/AuctionBase.sol [Line: 15](../tests/2024-07-templegold/protocol/contracts/templegold/AuctionBase.sol#L15) - - ```solidity - mapping(uint256 epochId => EpochInfo info) internal epochs; - ``` - -- Found in contracts/templegold/AuctionBase.sol [Line: 17](../tests/2024-07-templegold/protocol/contracts/templegold/AuctionBase.sol#L17) - - ```solidity - mapping(address depositor => mapping(uint256 epochId => uint256 amount)) public override depositors; - ``` - - Found in contracts/templegold/TempleGoldStaking.sol [Line: 40](../tests/2024-07-templegold/protocol/contracts/templegold/TempleGoldStaking.sol#L40) ```solidity @@ -8817,30 +8769,6 @@ State variables that are not updated following deployment should be declared con uint256 public override lastUpdateTime; ``` -- Found in contracts/v2/TreasuryReservesVault.sol [Line: 60](../tests/2024-07-templegold/protocol/contracts/v2/TreasuryReservesVault.sol#L60) - - ```solidity - EnumerableSet.AddressSet internal _strategySet; - ``` - -- Found in contracts/v2/TreasuryReservesVault.sol [Line: 70](../tests/2024-07-templegold/protocol/contracts/v2/TreasuryReservesVault.sol#L70) - - ```solidity - EnumerableSet.AddressSet internal _borrowTokenSet; - ``` - -- Found in contracts/v2/circuitBreaker/TempleCircuitBreakerProxy.sol [Line: 34](../tests/2024-07-templegold/protocol/contracts/v2/circuitBreaker/TempleCircuitBreakerProxy.sol#L34) - - ```solidity - EnumerableSet.Bytes32Set internal _identifiers; - ``` - -- Found in contracts/v2/safeGuards/ThresholdSafeGuard.sol [Line: 58](../tests/2024-07-templegold/protocol/contracts/v2/safeGuards/ThresholdSafeGuard.sol#L58) - - ```solidity - EnumerableSet.AddressSet internal _safeTxExecutors; - ``` - - Found in contracts/v2/strategies/AbstractStrategy.sol [Line: 26](../tests/2024-07-templegold/protocol/contracts/v2/strategies/AbstractStrategy.sol#L26) ```solidity