Fix minor issues

pull/653/head
Josselin 4 years ago
parent a3daeebfc8
commit 1aa48d10d6
  1. 4
      slither/detectors/abstract_detector.py
  2. 2
      slither/solc_parsing/expressions/expression_parsing.py
  3. 6
      slither/tools/properties/properties/erc20.py
  4. 4
      slither/tools/upgradeability/checks/abstract_checks.py
  5. 26
      slither/utils/comparable_enum.py

@ -1,11 +1,11 @@
import abc
import re
from enum import Enum
from typing import Optional
from slither.utils.colors import green, yellow, red
from slither.formatters.exceptions import FormatImpossible
from slither.formatters.utils.patches import apply_patch, create_diff
from slither.utils.comparable_enum import ComparableEnum
from slither.utils.output import Output
@ -13,7 +13,7 @@ class IncorrectDetectorInitialization(Exception):
pass
class DetectorClassification(Enum): # pylint: disable=too-few-public-methods
class DetectorClassification(ComparableEnum):
HIGH = 0
MEDIUM = 1
LOW = 2

@ -2,7 +2,7 @@ import logging
import re
from typing import Dict, TYPE_CHECKING, Optional, Union
from slither.core.declarations import Event, Enum, Structure, Modifier
from slither.core.declarations import Event, Enum, Structure
from slither.core.declarations.contract import Contract
from slither.core.declarations.function import Function
from slither.core.declarations.solidity_variables import (

@ -50,7 +50,9 @@ ERC20_PROPERTIES = {
}
def generate_erc20(contract: Contract, type_property: str, addresses: Addresses):
def generate_erc20(
contract: Contract, type_property: str, addresses: Addresses
): # pylint: disable=too-many-locals
"""
Generate the ERC20 tests
Files generated:
@ -68,7 +70,7 @@ def generate_erc20(contract: Contract, type_property: str, addresses: Addresses)
:return:
"""
if contract.slither.crytic_compile is None:
logging.error(f"Please compile with crytic-compile")
logging.error("Please compile with crytic-compile")
return
if contract.slither.crytic_compile.type not in [
PlatformType.TRUFFLE,

@ -1,8 +1,8 @@
import abc
from enum import Enum
from typing import Optional
from slither.utils.colors import green, yellow, red
from slither.utils.comparable_enum import ComparableEnum
from slither.utils.output import Output
@ -10,7 +10,7 @@ class IncorrectCheckInitialization(Exception):
pass
class CheckClassification(Enum): # pylint: disable=too-few-public-methods
class CheckClassification(ComparableEnum):
HIGH = 0
MEDIUM = 1
LOW = 2

@ -0,0 +1,26 @@
from enum import Enum
# pylint: disable=comparison-with-callable
class ComparableEnum(Enum):
def __eq__(self, other):
if isinstance(other, ComparableEnum):
return self.value == other.value
return False
def __ne__(self, other):
if isinstance(other, ComparableEnum):
return self.value != other.value
return False
def __lt__(self, other):
if isinstance(other, ComparableEnum):
return self.value < other.value
return False
def __repr__(self):
return "%s" % (str(self.value))
def __hash__(self):
return hash(self.value)
Loading…
Cancel
Save