update constable-states to consider constructor vars which can be immutable

pull/1455/head
alpharush 2 years ago
parent a41f86739d
commit faed6d7fb2
  1. 101
      slither/detectors/variables/possible_const_state_variables.py
  2. 206
      tests/detectors/constable-states/0.4.25/const_state_variables.sol.0.4.25.ConstCandidateStateVars.json
  3. 1
      tests/detectors/constable-states/0.5.16/const_state_variables.sol
  4. 261
      tests/detectors/constable-states/0.5.16/const_state_variables.sol.0.5.16.ConstCandidateStateVars.json
  5. 8
      tests/detectors/constable-states/0.6.11/const_state_variables.sol
  6. 286
      tests/detectors/constable-states/0.6.11/const_state_variables.sol.0.6.11.ConstCandidateStateVars.json
  7. 14
      tests/detectors/constable-states/0.7.6/const_state_variables.sol
  8. 480
      tests/detectors/constable-states/0.7.6/const_state_variables.sol.0.7.6.ConstCandidateStateVars.json
  9. 52
      tests/detectors/constable-states/0.8.0/const_state_variables.sol
  10. 690
      tests/detectors/constable-states/0.8.0/const_state_variables.sol.0.8.0.ConstCandidateStateVars.json
  11. 7
      tests/detectors/constable-states/0.8.0/immutable.sol
  12. 3
      tests/detectors/constable-states/0.8.0/immutable.sol.0.8.0.ConstCandidateStateVars.json
  13. 2
      tests/test_detectors.py

@ -14,6 +14,7 @@ from slither.core.declarations import Contract, Function
from slither.core.declarations.solidity_variables import SolidityFunction from slither.core.declarations.solidity_variables import SolidityFunction
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.formatters.variables.possible_const_state_variables import custom_format from slither.formatters.variables.possible_const_state_variables import custom_format
from slither.core.expressions import CallExpression, NewContract
def _is_valid_type(v: StateVariable) -> bool: def _is_valid_type(v: StateVariable) -> bool:
@ -44,15 +45,17 @@ class ConstCandidateStateVars(AbstractDetector):
""" """
ARGUMENT = "constable-states" ARGUMENT = "constable-states"
HELP = "State variables that could be declared constant" HELP = "State variables that could be declared constant or immutable"
IMPACT = DetectorClassification.OPTIMIZATION IMPACT = DetectorClassification.OPTIMIZATION
CONFIDENCE = DetectorClassification.HIGH CONFIDENCE = DetectorClassification.HIGH
WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#state-variables-that-could-be-declared-constant" WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#state-variables-that-could-be-declared-constant-or-immutable"
WIKI_TITLE = "State variables that could be declared constant" WIKI_TITLE = "State variables that could be declared constant or immutable"
WIKI_DESCRIPTION = "Constant state variables should be declared constant to save gas." WIKI_DESCRIPTION = "State variables that are not updated following deployment should be declared constant or immutable to save gas."
WIKI_RECOMMENDATION = "Add the `constant` attributes to state variables that never change." WIKI_RECOMMENDATION = (
"Add the `constant` or `immutable` attribute to state variables that never change."
)
# https://solidity.readthedocs.io/en/v0.5.2/contracts.html#constant-state-variables # https://solidity.readthedocs.io/en/v0.5.2/contracts.html#constant-state-variables
valid_solidity_function = [ valid_solidity_function = [
@ -71,54 +74,66 @@ class ConstCandidateStateVars(AbstractDetector):
if not v.expression: if not v.expression:
return True return True
# B b = new B(); b cannot be constant, so filter out and recommend it be immutable
if isinstance(v.expression, CallExpression) and isinstance(
v.expression.called, NewContract
):
return False
export = ExportValues(v.expression) export = ExportValues(v.expression)
values = export.result() values = export.result()
if not values: if not values:
return True return True
if all((val in self.valid_solidity_function or _is_constant_var(val) for val in values)): else:
return True return all(
return False (val in self.valid_solidity_function or _is_constant_var(val) for val in values)
)
def _detect(self) -> List[Output]: def _detect(self) -> List[Output]:
"""Detect state variables that could be const""" """Detect state variables that could be constant or immutable"""
results = [] results = {}
variables = []
functions = []
for c in self.compilation_unit.contracts:
variables.append(c.state_variables)
functions.append(c.all_functions_called)
all_variables_l = [c.state_variables for c in self.compilation_unit.contracts] valid_candidates: Set[StateVariable] = {
all_variables: Set[StateVariable] = { item for sublist in variables for item in sublist if _valid_candidate(item)
item for sublist in all_variables_l for item in sublist
} }
all_non_constant_elementary_variables = {v for v in all_variables if _valid_candidate(v)}
all_functions: List[Function] = list(
all_functions_nested = [c.all_functions_called for c in self.compilation_unit.contracts] {item1 for sublist in functions for item1 in sublist if isinstance(item1, Function)}
all_functions = list(
{
item1
for sublist in all_functions_nested
for item1 in sublist
if isinstance(item1, Function)
}
) )
all_variables_written = [ variables_written = []
f.state_variables_written for f in all_functions if not f.is_constructor_variables constructor_variables_written = []
] for f in all_functions:
all_variables_written = {item for sublist in all_variables_written for item in sublist} if f.is_constructor_variables:
constructor_variables_written.append(f.state_variables_written)
constable_variables: List[Variable] = [ else:
v variables_written.append(f.state_variables_written)
for v in all_non_constant_elementary_variables
if (v not in all_variables_written) and self._constant_initial_expression(v) variables_written = {item for sublist in variables_written for item in sublist}
] constructor_variables_written = {
# Order for deterministic results item for sublist in constructor_variables_written for item in sublist
constable_variables = sorted(constable_variables, key=lambda x: x.canonical_name) }
for v in valid_candidates:
# Create a result for each finding if v not in variables_written:
for v in constable_variables: if self._constant_initial_expression(v):
info = [v, " should be constant\n"] results[v.canonical_name] = self.generate_result([v, " should be constant \n"])
json = self.generate_result(info)
results.append(json) # immutable attribute available in Solidity 0.6.5 and above
# https://blog.soliditylang.org/2020/04/06/solidity-0.6.5-release-announcement/
return results elif (
v in constructor_variables_written
and self.compilation_unit.solc_version > "0.6.4"
):
results[v.canonical_name] = self.generate_result([v, " should be immutable \n"])
# Order by canonical name for deterministic results
return [results[k] for k in sorted(results)]
@staticmethod @staticmethod
def _format(compilation_unit: SlitherCompilationUnit, result: Dict) -> None: def _format(compilation_unit: SlitherCompilationUnit, result: Dict) -> None:

@ -4,19 +4,19 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "myFriendsAddress", "name": "text2",
"source_mapping": { "source_mapping": {
"start": 132, "start": 333,
"length": 76, "length": 20,
"filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
7 14
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 81 "ending_column": 25
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
@ -56,10 +56,10 @@
} }
} }
], ],
"description": "A.myFriendsAddress (tests/detectors/constable-states/0.4.25/const_state_variables.sol#7) should be constant\n", "description": "A.text2 (tests/detectors/constable-states/0.4.25/const_state_variables.sol#14) should be constant \n",
"markdown": "[A.myFriendsAddress](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L7) should be constant\n", "markdown": "[A.text2](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L14) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L7", "first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L14",
"id": "1454db80653b732bf6acbe54ff0ae4707002207a2a8216708c12d61c88a43e5f", "id": "2f06e04545cea7e7a8998c65d5419f335bf2579a6ce6a832eac9c87392fd5c1a",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -68,19 +68,79 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "test", "name": "mySistersAddress",
"source_mapping": { "source_mapping": {
"start": 237, "start": 496,
"length": 20, "length": 76,
"filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
10 26
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 25 "ending_column": 81
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "B",
"source_mapping": {
"start": 473,
"length": 271,
"filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"is_dependency": false,
"lines": [
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "B.mySistersAddress (tests/detectors/constable-states/0.4.25/const_state_variables.sol#26) should be constant \n",
"markdown": "[B.mySistersAddress](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L26) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L26",
"id": "3b5bff93954a48a79387e7981e8c45d78edc575a0988a10f1c7f439b9f930539",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "myFriendsAddress",
"source_mapping": {
"start": 132,
"length": 76,
"filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"is_dependency": false,
"lines": [
7
],
"starting_column": 5,
"ending_column": 81
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
@ -120,10 +180,10 @@
} }
} }
], ],
"description": "A.test (tests/detectors/constable-states/0.4.25/const_state_variables.sol#10) should be constant\n", "description": "A.myFriendsAddress (tests/detectors/constable-states/0.4.25/const_state_variables.sol#7) should be constant \n",
"markdown": "[A.test](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L10) should be constant\n", "markdown": "[A.myFriendsAddress](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L7) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L10", "first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L7",
"id": "5d9e3fb413322b71a93e90f7e89bd8c83cd4884d577d039598c681fe9db38b1d", "id": "52fd72f6870c4b504d1bcf9fb44249658e2077474d66208a33a47d2668b8db49",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -132,19 +192,19 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "should_be_constant_2", "name": "should_be_constant",
"source_mapping": { "source_mapping": {
"start": 841, "start": 793,
"length": 33, "length": 42,
"filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
43 42
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 38 "ending_column": 47
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
@ -180,70 +240,10 @@
} }
} }
], ],
"description": "MyConc.should_be_constant_2 (tests/detectors/constable-states/0.4.25/const_state_variables.sol#43) should be constant\n", "description": "MyConc.should_be_constant (tests/detectors/constable-states/0.4.25/const_state_variables.sol#42) should be constant \n",
"markdown": "[MyConc.should_be_constant_2](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L43) should be constant\n", "markdown": "[MyConc.should_be_constant](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L42) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L43", "first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L42",
"id": "9a48a4122de1a6a4774a9f1e0d4917bd0fa08f17b4af41b86ba07689e51bf711", "id": "8d08797efc8230b480ec669c7e2bf53c3b3d16bc59bf7770934b34fd892934f8",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "mySistersAddress",
"source_mapping": {
"start": 496,
"length": 76,
"filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"is_dependency": false,
"lines": [
26
],
"starting_column": 5,
"ending_column": 81
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "B",
"source_mapping": {
"start": 473,
"length": 271,
"filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"is_dependency": false,
"lines": [
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "B.mySistersAddress (tests/detectors/constable-states/0.4.25/const_state_variables.sol#26) should be constant\n",
"markdown": "[B.mySistersAddress](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L26) should be constant\n",
"first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L26",
"id": "bee93a722c8eae4a48aade67d8ef537d84c106f48fc9eb738c795fce10d3bc63",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -252,19 +252,19 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "should_be_constant", "name": "should_be_constant_2",
"source_mapping": { "source_mapping": {
"start": 793, "start": 841,
"length": 42, "length": 33,
"filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
42 43
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 47 "ending_column": 38
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
@ -300,10 +300,10 @@
} }
} }
], ],
"description": "MyConc.should_be_constant (tests/detectors/constable-states/0.4.25/const_state_variables.sol#42) should be constant\n", "description": "MyConc.should_be_constant_2 (tests/detectors/constable-states/0.4.25/const_state_variables.sol#43) should be constant \n",
"markdown": "[MyConc.should_be_constant](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L42) should be constant\n", "markdown": "[MyConc.should_be_constant_2](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L43) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L42", "first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L43",
"id": "cbcafa2a3efba4d21ac1b51b4b823e5082d556bc3d6cf3fd2ab3188f9f218fc1", "id": "d08c6d1e331083b42c45c222691dd1e6d880814c66d114971875337ca61ba9c9",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -312,16 +312,16 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "text2", "name": "test",
"source_mapping": { "source_mapping": {
"start": 333, "start": 237,
"length": 20, "length": 20,
"filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.4.25/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
14 10
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 25 "ending_column": 25
@ -364,10 +364,10 @@
} }
} }
], ],
"description": "A.text2 (tests/detectors/constable-states/0.4.25/const_state_variables.sol#14) should be constant\n", "description": "A.test (tests/detectors/constable-states/0.4.25/const_state_variables.sol#10) should be constant \n",
"markdown": "[A.text2](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L14) should be constant\n", "markdown": "[A.test](tests/detectors/constable-states/0.4.25/const_state_variables.sol#L10) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L14", "first_markdown_element": "tests/detectors/constable-states/0.4.25/const_state_variables.sol#L10",
"id": "df11e6201c4558a8c5cd90b55b134b9ca8f07203b2264d3aa93bd7745e8cb4ba", "id": "e407a1b57b4d25949ef7c4e6d97197605857099a94774a9c7a848d7dd3463668",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"

@ -41,6 +41,7 @@ contract MyConc{
uint constant A = 1; uint constant A = 1;
bytes32 should_be_constant = sha256('abc'); bytes32 should_be_constant = sha256('abc');
uint should_be_constant_2 = A + 1; uint should_be_constant_2 = A + 1;
B should_be_constant_3 = B(address(0));
address not_constant = msg.sender; address not_constant = msg.sender;
uint not_constant_2 = getNumber(); uint not_constant_2 = getNumber();
uint not_constant_3 = 10 + block.number; uint not_constant_3 = 10 + block.number;

@ -4,50 +4,47 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "myFriendsAddress", "name": "should_be_constant_3",
"source_mapping": { "source_mapping": {
"start": 132, "start": 880,
"length": 76, "length": 38,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
7 44
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 81 "ending_column": 43
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "A", "name": "MyConc",
"source_mapping": { "source_mapping": {
"start": 29, "start": 746,
"length": 441, "length": 386,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
4, 39,
5, 40,
6, 41,
7, 42,
8, 43,
9, 44,
10, 45,
11, 46,
12, 47,
13, 48,
14, 49,
15, 50,
16, 51,
17, 52,
18, 53
19,
20,
21
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -56,10 +53,10 @@
} }
} }
], ],
"description": "A.myFriendsAddress (tests/detectors/constable-states/0.5.16/const_state_variables.sol#7) should be constant\n", "description": "MyConc.should_be_constant_3 (tests/detectors/constable-states/0.5.16/const_state_variables.sol#44) should be constant \n",
"markdown": "[A.myFriendsAddress](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L7) should be constant\n", "markdown": "[MyConc.should_be_constant_3](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L44) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L7", "first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L44",
"id": "1454db80653b732bf6acbe54ff0ae4707002207a2a8216708c12d61c88a43e5f", "id": "29247b0a9939e854ad51bf3b2f58705156aa8b7e446e646b1832467d362b5b3e",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -68,16 +65,16 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "test", "name": "text2",
"source_mapping": { "source_mapping": {
"start": 237, "start": 333,
"length": 20, "length": 20,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
10 14
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 25 "ending_column": 25
@ -120,10 +117,10 @@
} }
} }
], ],
"description": "A.test (tests/detectors/constable-states/0.5.16/const_state_variables.sol#10) should be constant\n", "description": "A.text2 (tests/detectors/constable-states/0.5.16/const_state_variables.sol#14) should be constant \n",
"markdown": "[A.test](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L10) should be constant\n", "markdown": "[A.text2](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L14) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L10", "first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L14",
"id": "5d9e3fb413322b71a93e90f7e89bd8c83cd4884d577d039598c681fe9db38b1d", "id": "2f06e04545cea7e7a8998c65d5419f335bf2579a6ce6a832eac9c87392fd5c1a",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -132,46 +129,46 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "should_be_constant_2", "name": "mySistersAddress",
"source_mapping": { "source_mapping": {
"start": 841, "start": 496,
"length": 33, "length": 76,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
43 26
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 38 "ending_column": 81
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "MyConc", "name": "B",
"source_mapping": { "source_mapping": {
"start": 746, "start": 473,
"length": 342, "length": 271,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
39, 24,
40, 25,
41, 26,
42, 27,
43, 28,
44, 29,
45, 30,
46, 31,
47, 32,
48, 33,
49, 34,
50, 35,
51, 36,
52 37
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -180,10 +177,10 @@
} }
} }
], ],
"description": "MyConc.should_be_constant_2 (tests/detectors/constable-states/0.5.16/const_state_variables.sol#43) should be constant\n", "description": "B.mySistersAddress (tests/detectors/constable-states/0.5.16/const_state_variables.sol#26) should be constant \n",
"markdown": "[MyConc.should_be_constant_2](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L43) should be constant\n", "markdown": "[B.mySistersAddress](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L26) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L43", "first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L26",
"id": "9a48a4122de1a6a4774a9f1e0d4917bd0fa08f17b4af41b86ba07689e51bf711", "id": "3b5bff93954a48a79387e7981e8c45d78edc575a0988a10f1c7f439b9f930539",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -192,16 +189,16 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "mySistersAddress", "name": "myFriendsAddress",
"source_mapping": { "source_mapping": {
"start": 496, "start": 132,
"length": 76, "length": 76,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
26 7
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 81 "ending_column": 81
@ -209,29 +206,33 @@
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "B", "name": "A",
"source_mapping": { "source_mapping": {
"start": 473, "start": 29,
"length": 271, "length": 441,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
24, 4,
25, 5,
26, 6,
27, 7,
28, 8,
29, 9,
30, 10,
31, 11,
32, 12,
33, 13,
34, 14,
35, 15,
36, 16,
37 17,
18,
19,
20,
21
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -240,10 +241,10 @@
} }
} }
], ],
"description": "B.mySistersAddress (tests/detectors/constable-states/0.5.16/const_state_variables.sol#26) should be constant\n", "description": "A.myFriendsAddress (tests/detectors/constable-states/0.5.16/const_state_variables.sol#7) should be constant \n",
"markdown": "[B.mySistersAddress](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L26) should be constant\n", "markdown": "[A.myFriendsAddress](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L7) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L26", "first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L7",
"id": "bee93a722c8eae4a48aade67d8ef537d84c106f48fc9eb738c795fce10d3bc63", "id": "52fd72f6870c4b504d1bcf9fb44249658e2077474d66208a33a47d2668b8db49",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -272,7 +273,7 @@
"name": "MyConc", "name": "MyConc",
"source_mapping": { "source_mapping": {
"start": 746, "start": 746,
"length": 342, "length": 386,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
@ -291,7 +292,8 @@
49, 49,
50, 50,
51, 51,
52 52,
53
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -300,10 +302,10 @@
} }
} }
], ],
"description": "MyConc.should_be_constant (tests/detectors/constable-states/0.5.16/const_state_variables.sol#42) should be constant\n", "description": "MyConc.should_be_constant (tests/detectors/constable-states/0.5.16/const_state_variables.sol#42) should be constant \n",
"markdown": "[MyConc.should_be_constant](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L42) should be constant\n", "markdown": "[MyConc.should_be_constant](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L42) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L42", "first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L42",
"id": "cbcafa2a3efba4d21ac1b51b4b823e5082d556bc3d6cf3fd2ab3188f9f218fc1", "id": "8d08797efc8230b480ec669c7e2bf53c3b3d16bc59bf7770934b34fd892934f8",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -312,16 +314,77 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "text2", "name": "should_be_constant_2",
"source_mapping": { "source_mapping": {
"start": 333, "start": 841,
"length": 33,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false,
"lines": [
43
],
"starting_column": 5,
"ending_column": 38
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 746,
"length": 386,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false,
"lines": [
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_constant_2 (tests/detectors/constable-states/0.5.16/const_state_variables.sol#43) should be constant \n",
"markdown": "[MyConc.should_be_constant_2](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L43) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L43",
"id": "d08c6d1e331083b42c45c222691dd1e6d880814c66d114971875337ca61ba9c9",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "test",
"source_mapping": {
"start": 237,
"length": 20, "length": 20,
"filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.5.16/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
14 10
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 25 "ending_column": 25
@ -364,10 +427,10 @@
} }
} }
], ],
"description": "A.text2 (tests/detectors/constable-states/0.5.16/const_state_variables.sol#14) should be constant\n", "description": "A.test (tests/detectors/constable-states/0.5.16/const_state_variables.sol#10) should be constant \n",
"markdown": "[A.text2](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L14) should be constant\n", "markdown": "[A.test](tests/detectors/constable-states/0.5.16/const_state_variables.sol#L10) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L14", "first_markdown_element": "tests/detectors/constable-states/0.5.16/const_state_variables.sol#L10",
"id": "df11e6201c4558a8c5cd90b55b134b9ca8f07203b2264d3aa93bd7745e8cb4ba", "id": "e407a1b57b4d25949ef7c4e6d97197605857099a94774a9c7a848d7dd3463668",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"

@ -1,5 +1,3 @@
//pragma solidity ^0.4.24;
contract A { contract A {
@ -36,15 +34,17 @@ contract B is A {
} }
} }
contract MyConc{ contract MyConc {
uint constant A = 1; uint constant A = 1;
bytes32 should_be_constant = sha256('abc'); bytes32 should_be_constant = sha256('abc');
uint should_be_constant_2 = A + 1; uint should_be_constant_2 = A + 1;
B should_be_constant_3 = B(address(0));
address not_constant = msg.sender; address not_constant = msg.sender;
uint not_constant_2 = getNumber(); uint not_constant_2 = getNumber();
uint not_constant_3 = 10 + block.number; uint not_constant_3 = 10 + block.number;
B not_constant_4 = new B();
function getNumber() public returns(uint){ function getNumber() public returns(uint){
return block.number; return block.number;
} }

@ -4,50 +4,48 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "myFriendsAddress", "name": "should_be_constant_3",
"source_mapping": { "source_mapping": {
"start": 132, "start": 853,
"length": 76, "length": 38,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
7 42
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 81 "ending_column": 43
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "A", "name": "MyConc",
"source_mapping": { "source_mapping": {
"start": 29, "start": 718,
"length": 441, "length": 415,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
4, 37,
5, 38,
6, 39,
7, 40,
8, 41,
9, 42,
10, 43,
11, 44,
12, 45,
13, 46,
14, 47,
15, 48,
16, 49,
17, 50,
18, 51,
19, 52
20,
21
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -56,10 +54,10 @@
} }
} }
], ],
"description": "A.myFriendsAddress (tests/detectors/constable-states/0.6.11/const_state_variables.sol#7) should be constant\n", "description": "MyConc.should_be_constant_3 (tests/detectors/constable-states/0.6.11/const_state_variables.sol#42) should be constant \n",
"markdown": "[A.myFriendsAddress](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L7) should be constant\n", "markdown": "[MyConc.should_be_constant_3](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L42) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L7", "first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L42",
"id": "1454db80653b732bf6acbe54ff0ae4707002207a2a8216708c12d61c88a43e5f", "id": "29247b0a9939e854ad51bf3b2f58705156aa8b7e446e646b1832467d362b5b3e",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -68,16 +66,16 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "test", "name": "text2",
"source_mapping": { "source_mapping": {
"start": 237, "start": 305,
"length": 20, "length": 20,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
10 12
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 25 "ending_column": 25
@ -87,13 +85,15 @@
"type": "contract", "type": "contract",
"name": "A", "name": "A",
"source_mapping": { "source_mapping": {
"start": 29, "start": 1,
"length": 441, "length": 441,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
2,
3,
4, 4,
5, 5,
6, 6,
@ -109,9 +109,7 @@
16, 16,
17, 17,
18, 18,
19, 19
20,
21
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -120,10 +118,10 @@
} }
} }
], ],
"description": "A.test (tests/detectors/constable-states/0.6.11/const_state_variables.sol#10) should be constant\n", "description": "A.text2 (tests/detectors/constable-states/0.6.11/const_state_variables.sol#12) should be constant \n",
"markdown": "[A.test](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L10) should be constant\n", "markdown": "[A.text2](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L12) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L10", "first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L12",
"id": "5d9e3fb413322b71a93e90f7e89bd8c83cd4884d577d039598c681fe9db38b1d", "id": "2f06e04545cea7e7a8998c65d5419f335bf2579a6ce6a832eac9c87392fd5c1a",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -132,46 +130,46 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "should_be_constant_2", "name": "mySistersAddress",
"source_mapping": { "source_mapping": {
"start": 841, "start": 468,
"length": 33, "length": 76,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
43 24
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 38 "ending_column": 81
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "MyConc", "name": "B",
"source_mapping": { "source_mapping": {
"start": 746, "start": 445,
"length": 342, "length": 271,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
39, 22,
40, 23,
41, 24,
42, 25,
43, 26,
44, 27,
45, 28,
46, 29,
47, 30,
48, 31,
49, 32,
50, 33,
51, 34,
52 35
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -180,10 +178,10 @@
} }
} }
], ],
"description": "MyConc.should_be_constant_2 (tests/detectors/constable-states/0.6.11/const_state_variables.sol#43) should be constant\n", "description": "B.mySistersAddress (tests/detectors/constable-states/0.6.11/const_state_variables.sol#24) should be constant \n",
"markdown": "[MyConc.should_be_constant_2](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L43) should be constant\n", "markdown": "[B.mySistersAddress](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L24) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L43", "first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L24",
"id": "9a48a4122de1a6a4774a9f1e0d4917bd0fa08f17b4af41b86ba07689e51bf711", "id": "3b5bff93954a48a79387e7981e8c45d78edc575a0988a10f1c7f439b9f930539",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -192,16 +190,16 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "mySistersAddress", "name": "myFriendsAddress",
"source_mapping": { "source_mapping": {
"start": 496, "start": 104,
"length": 76, "length": 76,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
26 5
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 81 "ending_column": 81
@ -209,29 +207,33 @@
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "B", "name": "A",
"source_mapping": { "source_mapping": {
"start": 473, "start": 1,
"length": 271, "length": 441,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
24, 2,
25, 3,
26, 4,
27, 5,
28, 6,
29, 7,
30, 8,
31, 9,
32, 10,
33, 11,
34, 12,
35, 13,
36, 14,
37 15,
16,
17,
18,
19
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -240,10 +242,10 @@
} }
} }
], ],
"description": "B.mySistersAddress (tests/detectors/constable-states/0.6.11/const_state_variables.sol#26) should be constant\n", "description": "A.myFriendsAddress (tests/detectors/constable-states/0.6.11/const_state_variables.sol#5) should be constant \n",
"markdown": "[B.mySistersAddress](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L26) should be constant\n", "markdown": "[A.myFriendsAddress](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L5) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L26", "first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L5",
"id": "bee93a722c8eae4a48aade67d8ef537d84c106f48fc9eb738c795fce10d3bc63", "id": "52fd72f6870c4b504d1bcf9fb44249658e2077474d66208a33a47d2668b8db49",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -254,14 +256,14 @@
"type": "variable", "type": "variable",
"name": "should_be_constant", "name": "should_be_constant",
"source_mapping": { "source_mapping": {
"start": 793, "start": 766,
"length": 42, "length": 42,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
42 40
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 47 "ending_column": 47
@ -271,13 +273,15 @@
"type": "contract", "type": "contract",
"name": "MyConc", "name": "MyConc",
"source_mapping": { "source_mapping": {
"start": 746, "start": 718,
"length": 342, "length": 415,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
37,
38,
39, 39,
40, 40,
41, 41,
@ -300,10 +304,10 @@
} }
} }
], ],
"description": "MyConc.should_be_constant (tests/detectors/constable-states/0.6.11/const_state_variables.sol#42) should be constant\n", "description": "MyConc.should_be_constant (tests/detectors/constable-states/0.6.11/const_state_variables.sol#40) should be constant \n",
"markdown": "[MyConc.should_be_constant](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L42) should be constant\n", "markdown": "[MyConc.should_be_constant](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L40) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L42", "first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L40",
"id": "cbcafa2a3efba4d21ac1b51b4b823e5082d556bc3d6cf3fd2ab3188f9f218fc1", "id": "8d08797efc8230b480ec669c7e2bf53c3b3d16bc59bf7770934b34fd892934f8",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -312,16 +316,78 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "text2", "name": "should_be_constant_2",
"source_mapping": {
"start": 814,
"length": 33,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false,
"lines": [
41
],
"starting_column": 5,
"ending_column": 38
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 415,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_constant_2 (tests/detectors/constable-states/0.6.11/const_state_variables.sol#41) should be constant \n",
"markdown": "[MyConc.should_be_constant_2](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L41) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L41",
"id": "d08c6d1e331083b42c45c222691dd1e6d880814c66d114971875337ca61ba9c9",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "test",
"source_mapping": { "source_mapping": {
"start": 333, "start": 209,
"length": 20, "length": 20,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
14 8
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 25 "ending_column": 25
@ -331,13 +397,15 @@
"type": "contract", "type": "contract",
"name": "A", "name": "A",
"source_mapping": { "source_mapping": {
"start": 29, "start": 1,
"length": 441, "length": 441,
"filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.6.11/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
2,
3,
4, 4,
5, 5,
6, 6,
@ -353,9 +421,7 @@
16, 16,
17, 17,
18, 18,
19, 19
20,
21
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -364,10 +430,10 @@
} }
} }
], ],
"description": "A.text2 (tests/detectors/constable-states/0.6.11/const_state_variables.sol#14) should be constant\n", "description": "A.test (tests/detectors/constable-states/0.6.11/const_state_variables.sol#8) should be constant \n",
"markdown": "[A.text2](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L14) should be constant\n", "markdown": "[A.test](tests/detectors/constable-states/0.6.11/const_state_variables.sol#L8) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L14", "first_markdown_element": "tests/detectors/constable-states/0.6.11/const_state_variables.sol#L8",
"id": "df11e6201c4558a8c5cd90b55b134b9ca8f07203b2264d3aa93bd7745e8cb4ba", "id": "e407a1b57b4d25949ef7c4e6d97197605857099a94774a9c7a848d7dd3463668",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"

@ -1,5 +1,3 @@
//pragma solidity ^0.4.24;
contract A { contract A {
@ -36,15 +34,17 @@ contract B is A {
} }
} }
contract MyConc{ contract MyConc {
uint constant A = 1; uint constant A = 1;
bytes32 should_be_constant = sha256('abc'); bytes32 should_be_constant = sha256('abc');
uint should_be_constant_2 = A + 1; uint should_be_constant_2 = A + 1;
address not_constant = msg.sender; B should_be_constant_3 = B(address(0));
uint not_constant_2 = getNumber(); address should_be_immutable = msg.sender;
uint not_constant_3 = 10 + block.number; uint should_be_immutable_2 = getNumber();
uint should_be_immutable_3 = 10 + block.number;
B should_be_immutable_4 = new B();
function getNumber() public returns(uint){ function getNumber() public returns(uint){
return block.number; return block.number;
} }

@ -4,32 +4,96 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "myFriendsAddress", "name": "should_be_constant_3",
"source_mapping": { "source_mapping": {
"start": 132, "start": 853,
"length": 76, "length": 38,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
7 42
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 81 "ending_column": 43
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_constant_3 (tests/detectors/constable-states/0.7.6/const_state_variables.sol#42) should be constant \n",
"markdown": "[MyConc.should_be_constant_3](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L42) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L42",
"id": "29247b0a9939e854ad51bf3b2f58705156aa8b7e446e646b1832467d362b5b3e",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "text2",
"source_mapping": {
"start": 305,
"length": 20,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
12
],
"starting_column": 5,
"ending_column": 25
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "A", "name": "A",
"source_mapping": { "source_mapping": {
"start": 29, "start": 1,
"length": 441, "length": 441,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
2,
3,
4, 4,
5, 5,
6, 6,
@ -45,9 +109,7 @@
16, 16,
17, 17,
18, 18,
19, 19
20,
21
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -56,10 +118,10 @@
} }
} }
], ],
"description": "A.myFriendsAddress (tests/detectors/constable-states/0.7.6/const_state_variables.sol#7) should be constant\n", "description": "A.text2 (tests/detectors/constable-states/0.7.6/const_state_variables.sol#12) should be constant \n",
"markdown": "[A.myFriendsAddress](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L7) should be constant\n", "markdown": "[A.text2](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L12) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L7", "first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L12",
"id": "1454db80653b732bf6acbe54ff0ae4707002207a2a8216708c12d61c88a43e5f", "id": "2f06e04545cea7e7a8998c65d5419f335bf2579a6ce6a832eac9c87392fd5c1a",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -68,32 +130,156 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "test", "name": "mySistersAddress",
"source_mapping": { "source_mapping": {
"start": 237, "start": 468,
"length": 20, "length": 76,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
10 24
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 25 "ending_column": 81
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "B",
"source_mapping": {
"start": 445,
"length": 271,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "B.mySistersAddress (tests/detectors/constable-states/0.7.6/const_state_variables.sol#24) should be constant \n",
"markdown": "[B.mySistersAddress](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L24) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L24",
"id": "3b5bff93954a48a79387e7981e8c45d78edc575a0988a10f1c7f439b9f930539",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "should_be_immutable",
"source_mapping": {
"start": 897,
"length": 40,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
43
],
"starting_column": 5,
"ending_column": 45
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_immutable (tests/detectors/constable-states/0.7.6/const_state_variables.sol#43) should be immutable \n",
"markdown": "[MyConc.should_be_immutable](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L43) should be immutable \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L43",
"id": "3cabd54a4d3fa32f960965a41bb09b62052286195b47b2b7db670f87e8df21bf",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "myFriendsAddress",
"source_mapping": {
"start": 104,
"length": 76,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
5
],
"starting_column": 5,
"ending_column": 81
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "A", "name": "A",
"source_mapping": { "source_mapping": {
"start": 29, "start": 1,
"length": 441, "length": 441,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
2,
3,
4, 4,
5, 5,
6, 6,
@ -109,9 +295,7 @@
16, 16,
17, 17,
18, 18,
19, 19
20,
21
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -120,10 +304,10 @@
} }
} }
], ],
"description": "A.test (tests/detectors/constable-states/0.7.6/const_state_variables.sol#10) should be constant\n", "description": "A.myFriendsAddress (tests/detectors/constable-states/0.7.6/const_state_variables.sol#5) should be constant \n",
"markdown": "[A.test](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L10) should be constant\n", "markdown": "[A.myFriendsAddress](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L5) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L10", "first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L5",
"id": "5d9e3fb413322b71a93e90f7e89bd8c83cd4884d577d039598c681fe9db38b1d", "id": "52fd72f6870c4b504d1bcf9fb44249658e2077474d66208a33a47d2668b8db49",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -132,16 +316,78 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "should_be_constant_2", "name": "should_be_constant",
"source_mapping": { "source_mapping": {
"start": 841, "start": 766,
"length": 42,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
40
],
"starting_column": 5,
"ending_column": 47
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_constant (tests/detectors/constable-states/0.7.6/const_state_variables.sol#40) should be constant \n",
"markdown": "[MyConc.should_be_constant](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L40) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L40",
"id": "8d08797efc8230b480ec669c7e2bf53c3b3d16bc59bf7770934b34fd892934f8",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "should_be_immutable_4",
"source_mapping": {
"start": 1041,
"length": 33, "length": 33,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
43 46
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 38 "ending_column": 38
@ -151,13 +397,15 @@
"type": "contract", "type": "contract",
"name": "MyConc", "name": "MyConc",
"source_mapping": { "source_mapping": {
"start": 746, "start": 718,
"length": 342, "length": 443,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
37,
38,
39, 39,
40, 40,
41, 41,
@ -180,10 +428,10 @@
} }
} }
], ],
"description": "MyConc.should_be_constant_2 (tests/detectors/constable-states/0.7.6/const_state_variables.sol#43) should be constant\n", "description": "MyConc.should_be_immutable_4 (tests/detectors/constable-states/0.7.6/const_state_variables.sol#46) should be immutable \n",
"markdown": "[MyConc.should_be_constant_2](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L43) should be constant\n", "markdown": "[MyConc.should_be_immutable_4](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L46) should be immutable \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L43", "first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L46",
"id": "9a48a4122de1a6a4774a9f1e0d4917bd0fa08f17b4af41b86ba07689e51bf711", "id": "a15e34bd516e604d7ba3e0746ad0234d0baea38da2e747648316d5d15ee9b3bc",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -192,46 +440,48 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "mySistersAddress", "name": "should_be_immutable_2",
"source_mapping": { "source_mapping": {
"start": 496, "start": 943,
"length": 76, "length": 40,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
26 44
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 81 "ending_column": 45
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "B", "name": "MyConc",
"source_mapping": { "source_mapping": {
"start": 473, "start": 718,
"length": 271, "length": 443,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
24, 37,
25, 38,
26, 39,
27, 40,
28, 41,
29, 42,
30, 43,
31, 44,
32, 45,
33, 46,
34, 47,
35, 48,
36, 49,
37 50,
51,
52
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -240,10 +490,10 @@
} }
} }
], ],
"description": "B.mySistersAddress (tests/detectors/constable-states/0.7.6/const_state_variables.sol#26) should be constant\n", "description": "MyConc.should_be_immutable_2 (tests/detectors/constable-states/0.7.6/const_state_variables.sol#44) should be immutable \n",
"markdown": "[B.mySistersAddress](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L26) should be constant\n", "markdown": "[MyConc.should_be_immutable_2](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L44) should be immutable \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L26", "first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L44",
"id": "bee93a722c8eae4a48aade67d8ef537d84c106f48fc9eb738c795fce10d3bc63", "id": "cb6df1f1ce2f32505c81f257863ceef6d5145ee5a2835af1c6719ad695d145e2",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -252,32 +502,34 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "should_be_constant", "name": "should_be_constant_2",
"source_mapping": { "source_mapping": {
"start": 793, "start": 814,
"length": 42, "length": 33,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
42 41
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 47 "ending_column": 38
}, },
"type_specific_fields": { "type_specific_fields": {
"parent": { "parent": {
"type": "contract", "type": "contract",
"name": "MyConc", "name": "MyConc",
"source_mapping": { "source_mapping": {
"start": 746, "start": 718,
"length": 342, "length": 443,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
37,
38,
39, 39,
40, 40,
41, 41,
@ -300,10 +552,10 @@
} }
} }
], ],
"description": "MyConc.should_be_constant (tests/detectors/constable-states/0.7.6/const_state_variables.sol#42) should be constant\n", "description": "MyConc.should_be_constant_2 (tests/detectors/constable-states/0.7.6/const_state_variables.sol#41) should be constant \n",
"markdown": "[MyConc.should_be_constant](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L42) should be constant\n", "markdown": "[MyConc.should_be_constant_2](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L41) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L42", "first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L41",
"id": "cbcafa2a3efba4d21ac1b51b4b823e5082d556bc3d6cf3fd2ab3188f9f218fc1", "id": "d08c6d1e331083b42c45c222691dd1e6d880814c66d114971875337ca61ba9c9",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"
@ -312,16 +564,78 @@
"elements": [ "elements": [
{ {
"type": "variable", "type": "variable",
"name": "text2", "name": "should_be_immutable_3",
"source_mapping": {
"start": 989,
"length": 46,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
45
],
"starting_column": 5,
"ending_column": 51
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_immutable_3 (tests/detectors/constable-states/0.7.6/const_state_variables.sol#45) should be immutable \n",
"markdown": "[MyConc.should_be_immutable_3](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L45) should be immutable \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L45",
"id": "dc5903ef8f6ec62f53df486fa768a0d817643efe30c90c1308079eee99c316d4",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "test",
"source_mapping": { "source_mapping": {
"start": 333, "start": 209,
"length": 20, "length": 20,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
14 8
], ],
"starting_column": 5, "starting_column": 5,
"ending_column": 25 "ending_column": 25
@ -331,13 +645,15 @@
"type": "contract", "type": "contract",
"name": "A", "name": "A",
"source_mapping": { "source_mapping": {
"start": 29, "start": 1,
"length": 441, "length": 441,
"filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_relative": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH", "filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol", "filename_short": "tests/detectors/constable-states/0.7.6/const_state_variables.sol",
"is_dependency": false, "is_dependency": false,
"lines": [ "lines": [
2,
3,
4, 4,
5, 5,
6, 6,
@ -353,9 +669,7 @@
16, 16,
17, 17,
18, 18,
19, 19
20,
21
], ],
"starting_column": 1, "starting_column": 1,
"ending_column": 2 "ending_column": 2
@ -364,10 +678,10 @@
} }
} }
], ],
"description": "A.text2 (tests/detectors/constable-states/0.7.6/const_state_variables.sol#14) should be constant\n", "description": "A.test (tests/detectors/constable-states/0.7.6/const_state_variables.sol#8) should be constant \n",
"markdown": "[A.text2](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L14) should be constant\n", "markdown": "[A.test](tests/detectors/constable-states/0.7.6/const_state_variables.sol#L8) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L14", "first_markdown_element": "tests/detectors/constable-states/0.7.6/const_state_variables.sol#L8",
"id": "df11e6201c4558a8c5cd90b55b134b9ca8f07203b2264d3aa93bd7745e8cb4ba", "id": "e407a1b57b4d25949ef7c4e6d97197605857099a94774a9c7a848d7dd3463668",
"check": "constable-states", "check": "constable-states",
"impact": "Optimization", "impact": "Optimization",
"confidence": "High" "confidence": "High"

@ -0,0 +1,52 @@
contract A {
address constant public MY_ADDRESS = 0xE0f5206BBD039e7b0592d8918820024e2a7437b9;
address public myFriendsAddress = 0xc0ffee254729296a45a3885639AC7E10F9d54979;
uint public used;
uint public test = 5;
uint constant X = 32**22 + 8;
string constant TEXT1 = "abc";
string text2 = "xyz";
function setUsed() public {
if (msg.sender == MY_ADDRESS) {
used = test;
}
}
}
contract B is A {
address public mySistersAddress = 0x999999cf1046e68e36E1aA2E0E07105eDDD1f08E;
fallback () external {
used = 0;
}
function setUsed(uint a) public {
if (msg.sender == MY_ADDRESS) {
used = a;
}
}
}
contract MyConc {
uint constant A = 1;
bytes32 should_be_constant = sha256('abc');
uint should_be_constant_2 = A + 1;
B should_be_constant_3 = B(address(0));
address should_be_immutable = msg.sender;
uint should_be_immutable_2 = getNumber();
uint should_be_immutable_3 = 10 + block.number;
B should_be_immutable_4 = new B();
function getNumber() public returns(uint){
return block.number;
}
}

@ -0,0 +1,690 @@
[
[
{
"elements": [
{
"type": "variable",
"name": "should_be_constant_3",
"source_mapping": {
"start": 853,
"length": 38,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
42
],
"starting_column": 5,
"ending_column": 43
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_constant_3 (tests/detectors/constable-states/0.8.0/const_state_variables.sol#42) should be constant \n",
"markdown": "[MyConc.should_be_constant_3](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L42) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L42",
"id": "29247b0a9939e854ad51bf3b2f58705156aa8b7e446e646b1832467d362b5b3e",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "text2",
"source_mapping": {
"start": 305,
"length": 20,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
12
],
"starting_column": 5,
"ending_column": 25
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "A",
"source_mapping": {
"start": 1,
"length": 441,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "A.text2 (tests/detectors/constable-states/0.8.0/const_state_variables.sol#12) should be constant \n",
"markdown": "[A.text2](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L12) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L12",
"id": "2f06e04545cea7e7a8998c65d5419f335bf2579a6ce6a832eac9c87392fd5c1a",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "mySistersAddress",
"source_mapping": {
"start": 468,
"length": 76,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
24
],
"starting_column": 5,
"ending_column": 81
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "B",
"source_mapping": {
"start": 445,
"length": 271,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "B.mySistersAddress (tests/detectors/constable-states/0.8.0/const_state_variables.sol#24) should be constant \n",
"markdown": "[B.mySistersAddress](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L24) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L24",
"id": "3b5bff93954a48a79387e7981e8c45d78edc575a0988a10f1c7f439b9f930539",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "should_be_immutable",
"source_mapping": {
"start": 897,
"length": 40,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
43
],
"starting_column": 5,
"ending_column": 45
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_immutable (tests/detectors/constable-states/0.8.0/const_state_variables.sol#43) should be immutable \n",
"markdown": "[MyConc.should_be_immutable](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L43) should be immutable \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L43",
"id": "3cabd54a4d3fa32f960965a41bb09b62052286195b47b2b7db670f87e8df21bf",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "myFriendsAddress",
"source_mapping": {
"start": 104,
"length": 76,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
5
],
"starting_column": 5,
"ending_column": 81
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "A",
"source_mapping": {
"start": 1,
"length": 441,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "A.myFriendsAddress (tests/detectors/constable-states/0.8.0/const_state_variables.sol#5) should be constant \n",
"markdown": "[A.myFriendsAddress](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L5) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L5",
"id": "52fd72f6870c4b504d1bcf9fb44249658e2077474d66208a33a47d2668b8db49",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "should_be_constant",
"source_mapping": {
"start": 766,
"length": 42,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
40
],
"starting_column": 5,
"ending_column": 47
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_constant (tests/detectors/constable-states/0.8.0/const_state_variables.sol#40) should be constant \n",
"markdown": "[MyConc.should_be_constant](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L40) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L40",
"id": "8d08797efc8230b480ec669c7e2bf53c3b3d16bc59bf7770934b34fd892934f8",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "should_be_immutable_4",
"source_mapping": {
"start": 1041,
"length": 33,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
46
],
"starting_column": 5,
"ending_column": 38
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_immutable_4 (tests/detectors/constable-states/0.8.0/const_state_variables.sol#46) should be immutable \n",
"markdown": "[MyConc.should_be_immutable_4](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L46) should be immutable \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L46",
"id": "a15e34bd516e604d7ba3e0746ad0234d0baea38da2e747648316d5d15ee9b3bc",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "should_be_immutable_2",
"source_mapping": {
"start": 943,
"length": 40,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
44
],
"starting_column": 5,
"ending_column": 45
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_immutable_2 (tests/detectors/constable-states/0.8.0/const_state_variables.sol#44) should be immutable \n",
"markdown": "[MyConc.should_be_immutable_2](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L44) should be immutable \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L44",
"id": "cb6df1f1ce2f32505c81f257863ceef6d5145ee5a2835af1c6719ad695d145e2",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "should_be_constant_2",
"source_mapping": {
"start": 814,
"length": 33,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
41
],
"starting_column": 5,
"ending_column": 38
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_constant_2 (tests/detectors/constable-states/0.8.0/const_state_variables.sol#41) should be constant \n",
"markdown": "[MyConc.should_be_constant_2](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L41) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L41",
"id": "d08c6d1e331083b42c45c222691dd1e6d880814c66d114971875337ca61ba9c9",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "should_be_immutable_3",
"source_mapping": {
"start": 989,
"length": 46,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
45
],
"starting_column": 5,
"ending_column": 51
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "MyConc",
"source_mapping": {
"start": 718,
"length": 443,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "MyConc.should_be_immutable_3 (tests/detectors/constable-states/0.8.0/const_state_variables.sol#45) should be immutable \n",
"markdown": "[MyConc.should_be_immutable_3](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L45) should be immutable \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L45",
"id": "dc5903ef8f6ec62f53df486fa768a0d817643efe30c90c1308079eee99c316d4",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "variable",
"name": "test",
"source_mapping": {
"start": 209,
"length": 20,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
8
],
"starting_column": 5,
"ending_column": 25
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "A",
"source_mapping": {
"start": 1,
"length": 441,
"filename_relative": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/constable-states/0.8.0/const_state_variables.sol",
"is_dependency": false,
"lines": [
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
],
"starting_column": 1,
"ending_column": 2
}
}
}
}
],
"description": "A.test (tests/detectors/constable-states/0.8.0/const_state_variables.sol#8) should be constant \n",
"markdown": "[A.test](tests/detectors/constable-states/0.8.0/const_state_variables.sol#L8) should be constant \n",
"first_markdown_element": "tests/detectors/constable-states/0.8.0/const_state_variables.sol#L8",
"id": "e407a1b57b4d25949ef7c4e6d97197605857099a94774a9c7a848d7dd3463668",
"check": "constable-states",
"impact": "Optimization",
"confidence": "High"
}
]
]

@ -1,7 +0,0 @@
contract C{
uint immutable v;
constructor() public{
v = 0;
}
}

@ -497,7 +497,7 @@ ALL_TEST_OBJECTS = [
), ),
Test( Test(
all_detectors.ConstCandidateStateVars, all_detectors.ConstCandidateStateVars,
"immutable.sol", "const_state_variables.sol",
"0.8.0", "0.8.0",
), ),
Test( Test(

Loading…
Cancel
Save