prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  filter `name-reused` to only run on Truffle projects
  The detector should check which platform was used with https://crytic.github.io/crytic-compile/crytic_compile/crytic_compile.html#CryticCompile.platform and https://crytic.github.io/slither/slither/core/compilation_unit.html#SlitherCompilationUnit.crytic_compile 
  https://github.com/crytic/slither/blob/13d7d9f66a6be4f798478fa3735fb63444b46c3d/slither/detectors/slither/name_reused.py#L51-L61
  
  https://github.com/crytic/crytic-compile/blob/b5c538aaa66be44b7a68d9723881a7eba2c20898/crytic_compile/platform/truffle.py#L83-L90
  
  </issue>
  <code>
  [start of slither/detectors/slither/name_reused.py]
  1 from collections import defaultdict
  2 from typing import List
  3 
  4 from slither.core.compilation_unit import SlitherCompilationUnit
  5 from slither.core.declarations import Contract
  6 from slither.detectors.abstract_detector import (
  7     AbstractDetector,
  8     DetectorClassification,
  9     DETECTOR_INFO,
  10 )
  11 from slither.utils.output import Output
  12 
  13 
  14 def _find_missing_inheritance(compilation_unit: SlitherCompilationUnit) -> List[Contract]:
  15     """
  16     Filter contracts with missing inheritance to return only the "most base" contracts
  17     in the inheritance tree.
  18     :param slither:
  19     :return:
  20     """
  21     missings = compilation_unit.contracts_with_missing_inheritance
  22 
  23     ret = []
  24     for b in missings:
  25         is_most_base = True
  26         for inheritance in b.immediate_inheritance:
  27             if inheritance in missings:
  28                 is_most_base = False
  29         if is_most_base:
  30             ret.append(b)
  31 
  32     return ret
  33 
  34 
  35 class NameReused(AbstractDetector):
  36     ARGUMENT = "name-reused"
  37     HELP = "Contract's name reused"
  38     IMPACT = DetectorClassification.HIGH
  39     CONFIDENCE = DetectorClassification.HIGH
  40 
  41     WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#name-reused"
  42 
  43     WIKI_TITLE = "Name reused"
  44 
  45     # region wiki_description
  46     WIKI_DESCRIPTION = """If a codebase has two contracts the similar names, the compilation artifacts
  47 will not contain one of the contracts with the duplicate name."""
  48     # endregion wiki_description
  49 
  50     # region wiki_exploit_scenario
  51     WIKI_EXPLOIT_SCENARIO = """
  52 Bob's `truffle` codebase has two contracts named `ERC20`.
  53 When `truffle compile` runs, only one of the two contracts will generate artifacts in `build/contracts`.
  54 As a result, the second contract cannot be analyzed.
  55 """
  56     # endregion wiki_exploit_scenario
  57 
  58     WIKI_RECOMMENDATION = "Rename the contract."
  59 
  60     # pylint: disable=too-many-locals,too-many-branches
  61     def _detect(self) -> List[Output]:
  62         results = []
  63         compilation_unit = self.compilation_unit
  64 
  65         all_contracts = compilation_unit.contracts
  66         all_contracts_name = [c.name for c in all_contracts]
  67         contracts_name_reused = {
  68             contract for contract in all_contracts_name if all_contracts_name.count(contract) > 1
  69         }
  70 
  71         names_reused = {
  72             name: compilation_unit.get_contract_from_name(name) for name in contracts_name_reused
  73         }
  74 
  75         # First show the contracts that we know are missing
  76         incorrectly_constructed = [
  77             contract
  78             for contract in compilation_unit.contracts
  79             if contract.is_incorrectly_constructed
  80         ]
  81 
  82         inheritance_corrupted = defaultdict(list)
  83         for contract in incorrectly_constructed:
  84             for father in contract.inheritance:
  85                 inheritance_corrupted[father.name].append(contract)
  86 
  87         for contract_name, files in names_reused.items():
  88             info: DETECTOR_INFO = [contract_name, " is re-used:\n"]
  89             for file in files:
  90                 if file is None:
  91                     info += ["\t- In an file not found, most likely in\n"]
  92                 else:
  93                     info += ["\t- ", file, "\n"]
  94 
  95             if contract_name in inheritance_corrupted:
  96                 info += ["\tAs a result, the inherited contracts are not correctly analyzed:\n"]
  97             for corrupted in inheritance_corrupted[contract_name]:
  98                 info += ["\t\t- ", corrupted, "\n"]
  99             res = self.generate_result(info)
  100             results.append(res)
  101 
  102         # Then show the contracts for which one of the father was not found
  103         # Here we are not able to know
  104         most_base_with_missing_inheritance = _find_missing_inheritance(compilation_unit)
  105 
  106         for b in most_base_with_missing_inheritance:
  107             info = [b, " inherits from a contract for which the name is reused.\n"]
  108             if b.inheritance:
  109                 info += ["\t- Slither could not determine which contract has a duplicate name:\n"]
  110                 for inheritance in b.inheritance:
  111                     info += ["\t\t-", inheritance, "\n"]
  112                 info += ["\t- Check if:\n"]
  113                 info += ["\t\t- A inherited contract is missing from this list,\n"]
  114                 info += ["\t\t- The contract are imported from the correct files.\n"]
  115             if b.derived_contracts:
  116                 info += [f"\t- This issue impacts the contracts inheriting from {b.name}:\n"]
  117                 for derived in b.derived_contracts:
  118                     info += ["\t\t-", derived, "\n"]
  119             res = self.generate_result(info)
  120             results.append(res)
  121         return results
  122
  [end of slither/detectors/slither/name_reused.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/slither/detectors/slither/name_reused.py b/slither/detectors/slither/name_reused.py
  --- a/slither/detectors/slither/name_reused.py
  +++ b/slither/detectors/slither/name_reused.py
  @@ -1,6 +1,8 @@
   from collections import defaultdict
   from typing import List
   
  +from crytic_compile.platform import Type as PlatformType
  +
   from slither.core.compilation_unit import SlitherCompilationUnit
   from slither.core.declarations import Contract
   from slither.detectors.abstract_detector import (
  @@ -61,6 +63,8 @@
       def _detect(self) -> List[Output]:
           results = []
           compilation_unit = self.compilation_unit
  +        if compilation_unit.core.crytic_compile.platform != PlatformType.TRUFFLE:
  +            return []
   
           all_contracts = compilation_unit.contracts
           all_contracts_name = [c.name for c in all_contracts]
  
verification_info: {"golden_diff": "diff --git a/slither/detectors/slither/name_reused.py b/slither/detectors/slither/name_reused.py\n--- a/slither/detectors/slither/name_reused.py\n+++ b/slither/detectors/slither/name_reused.py\n@@ -1,6 +1,8 @@\n from collections import defaultdict\n from typing import List\n \n+from crytic_compile.platform import Type as PlatformType\n+\n from slither.core.compilation_unit import SlitherCompilationUnit\n from slither.core.declarations import Contract\n from slither.detectors.abstract_detector import (\n@@ -61,6 +63,8 @@\n     def _detect(self) -> List[Output]:\n         results = []\n         compilation_unit = self.compilation_unit\n+        if compilation_unit.core.crytic_compile.platform != PlatformType.TRUFFLE:\n+            return []\n \n         all_contracts = compilation_unit.contracts\n         all_contracts_name = [c.name for c in all_contracts]\n", "issue": "filter `name-reused` to only run on Truffle projects\nThe detector should check which platform was used with https://crytic.github.io/crytic-compile/crytic_compile/crytic_compile.html#CryticCompile.platform and https://crytic.github.io/slither/slither/core/compilation_unit.html#SlitherCompilationUnit.crytic_compile \r\nhttps://github.com/crytic/slither/blob/13d7d9f66a6be4f798478fa3735fb63444b46c3d/slither/detectors/slither/name_reused.py#L51-L61\r\n\r\nhttps://github.com/crytic/crytic-compile/blob/b5c538aaa66be44b7a68d9723881a7eba2c20898/crytic_compile/platform/truffle.py#L83-L90\n", "before_files": [{"content": "from collections import defaultdict\nfrom typing import List\n\nfrom slither.core.compilation_unit import SlitherCompilationUnit\nfrom slither.core.declarations import Contract\nfrom slither.detectors.abstract_detector import (\n    AbstractDetector,\n    DetectorClassification,\n    DETECTOR_INFO,\n)\nfrom slither.utils.output import Output\n\n\ndef _find_missing_inheritance(compilation_unit: SlitherCompilationUnit) -> List[Contract]:\n    \"\"\"\n    Filter contracts with missing inheritance to return only the \"most base\" contracts\n    in the inheritance tree.\n    :param slither:\n    :return:\n    \"\"\"\n    missings = compilation_unit.contracts_with_missing_inheritance\n\n    ret = []\n    for b in missings:\n        is_most_base = True\n        for inheritance in b.immediate_inheritance:\n            if inheritance in missings:\n                is_most_base = False\n        if is_most_base:\n            ret.append(b)\n\n    return ret\n\n\nclass NameReused(AbstractDetector):\n    ARGUMENT = \"name-reused\"\n    HELP = \"Contract's name reused\"\n    IMPACT = DetectorClassification.HIGH\n    CONFIDENCE = DetectorClassification.HIGH\n\n    WIKI = \"https://github.com/crytic/slither/wiki/Detector-Documentation#name-reused\"\n\n    WIKI_TITLE = \"Name reused\"\n\n    # region wiki_description\n    WIKI_DESCRIPTION = \"\"\"If a codebase has two contracts the similar names, the compilation artifacts\nwill not contain one of the contracts with the duplicate name.\"\"\"\n    # endregion wiki_description\n\n    # region wiki_exploit_scenario\n    WIKI_EXPLOIT_SCENARIO = \"\"\"\nBob's `truffle` codebase has two contracts named `ERC20`.\nWhen `truffle compile` runs, only one of the two contracts will generate artifacts in `build/contracts`.\nAs a result, the second contract cannot be analyzed.\n\"\"\"\n    # endregion wiki_exploit_scenario\n\n    WIKI_RECOMMENDATION = \"Rename the contract.\"\n\n    # pylint: disable=too-many-locals,too-many-branches\n    def _detect(self) -> List[Output]:\n        results = []\n        compilation_unit = self.compilation_unit\n\n        all_contracts = compilation_unit.contracts\n        all_contracts_name = [c.name for c in all_contracts]\n        contracts_name_reused = {\n            contract for contract in all_contracts_name if all_contracts_name.count(contract) > 1\n        }\n\n        names_reused = {\n            name: compilation_unit.get_contract_from_name(name) for name in contracts_name_reused\n        }\n\n        # First show the contracts that we know are missing\n        incorrectly_constructed = [\n            contract\n            for contract in compilation_unit.contracts\n            if contract.is_incorrectly_constructed\n        ]\n\n        inheritance_corrupted = defaultdict(list)\n        for contract in incorrectly_constructed:\n            for father in contract.inheritance:\n                inheritance_corrupted[father.name].append(contract)\n\n        for contract_name, files in names_reused.items():\n            info: DETECTOR_INFO = [contract_name, \" is re-used:\\n\"]\n            for file in files:\n                if file is None:\n                    info += [\"\\t- In an file not found, most likely in\\n\"]\n                else:\n                    info += [\"\\t- \", file, \"\\n\"]\n\n            if contract_name in inheritance_corrupted:\n                info += [\"\\tAs a result, the inherited contracts are not correctly analyzed:\\n\"]\n            for corrupted in inheritance_corrupted[contract_name]:\n                info += [\"\\t\\t- \", corrupted, \"\\n\"]\n            res = self.generate_result(info)\n            results.append(res)\n\n        # Then show the contracts for which one of the father was not found\n        # Here we are not able to know\n        most_base_with_missing_inheritance = _find_missing_inheritance(compilation_unit)\n\n        for b in most_base_with_missing_inheritance:\n            info = [b, \" inherits from a contract for which the name is reused.\\n\"]\n            if b.inheritance:\n                info += [\"\\t- Slither could not determine which contract has a duplicate name:\\n\"]\n                for inheritance in b.inheritance:\n                    info += [\"\\t\\t-\", inheritance, \"\\n\"]\n                info += [\"\\t- Check if:\\n\"]\n                info += [\"\\t\\t- A inherited contract is missing from this list,\\n\"]\n                info += [\"\\t\\t- The contract are imported from the correct files.\\n\"]\n            if b.derived_contracts:\n                info += [f\"\\t- This issue impacts the contracts inheriting from {b.name}:\\n\"]\n                for derived in b.derived_contracts:\n                    info += [\"\\t\\t-\", derived, \"\\n\"]\n            res = self.generate_result(info)\n            results.append(res)\n        return results\n", "path": "slither/detectors/slither/name_reused.py"}]}