Skip to content

Commit

Permalink
cli/reportgen
Browse files Browse the repository at this point in the history
  • Loading branch information
TilakMaddy committed Aug 19, 2024
1 parent e93a66e commit 1d16b0f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 435 deletions.
10 changes: 9 additions & 1 deletion aderyn_core/src/detect/low/state_variable_could_be_constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 1 addition & 7 deletions reports/adhoc-sol-files-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details><summary>14 Found Instances</summary>
<details><summary>13 Found Instances</summary>


- Found in InconsistentUints.sol [Line: 7](../tests/adhoc-sol-files/InconsistentUints.sol#L7)
Expand All @@ -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
Expand Down
32 changes: 1 addition & 31 deletions reports/ccip-functions-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details><summary>27 Found Instances</summary>
<details><summary>22 Found Instances</summary>


- 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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
```

</details>


Expand Down
84 changes: 0 additions & 84 deletions reports/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"
}
]
}
Expand Down
86 changes: 1 addition & 85 deletions reports/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details><summary>93 Found Instances</summary>
<details><summary>79 Found Instances</summary>


- Found in src/AssemblyExample.sol [Line: 5](../tests/contract-playground/src/AssemblyExample.sol#L5)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
```

</details>


Expand Down
Loading

0 comments on commit 1d16b0f

Please sign in to comment.