import type { SidebarItem } from "./types";

export const forgeDocs: SidebarItem[] = [
  { text: "Overview", link: "/forge" },
  { text: "Building", link: "/forge/build" },
  { text: "Cloning Contracts", link: "/forge/cloning" },
  { text: "Documentation", link: "/forge/documentation" },
  { text: "Contract Bindings", link: "/forge/contract-bindings" },
  { text: "Testing", link: "/forge/testing" },
  { text: "Scripting", link: "/forge/scripting" },
  { text: "Debugging", link: "/forge/debugging" },
  { text: "Gas Tracking", link: "/forge/gas-tracking" },
  { text: "Formatting", link: "/forge/formatting" },
  { text: "Linting", link: "/forge/linting" },
];

const ruleGroup = (text: string, rules: string[]): SidebarItem => ({
  text,
  collapsed: true,
  items: rules.map((rule) => ({ text: rule, link: `/forge/linting/${rule}` })),
});

export const lintingSidebar: SidebarItem[] = [
  {
    text: "Forge",
    items: forgeDocs,
  },
  ruleGroup("High severity", [
    "arbitrary-send-erc20",
    "arbitrary-send-erc20-permit",
    "arbitrary-send-eth",
    "controlled-delegatecall",
    "encode-packed-collision",
    "enumerable-loop-removal",
    "erc20-unchecked-transfer",
    "function-selector-collision",
    "incorrect-exp",
    "incorrect-shift",
    "protected-vars",
    "reentrancy-balance",
    "reentrancy-eth",
    "rtlo",
    "unchecked-call",
    "unprotected-initializer",
  ]),
  ruleGroup("Medium severity", [
    "assert-state-change",
    "boolean-cst",
    "dangerous-unary-operator",
    "divide-before-multiply",
    "ecrecover",
    "incorrect-erc20-interface",
    "incorrect-erc721-interface",
    "incorrect-strict-equality",
    "locked-ether",
    "low-level-calls",
    "mapping-deletion",
    "non-reentrant-not-first",
    "reentrancy-no-eth",
    "tautological-compare",
    "tx-origin",
    "type-based-tautology",
    "uninitialized-local",
    "uninitialized-state",
    "unsafe-oz-erc721-mint",
    "unsafe-typecast",
    "unused-return",
    "weak-prng",
  ]),
  ruleGroup("Low severity", [
    "block-timestamp",
    "calls-loop",
    "delegatecall-loop",
    "deprecated-oz-function",
    "empty-block",
    "incorrect-modifier",
    "inconsistent-type-names",
    "missing-events-access-control",
    "missing-events-arithmetic",
    "missing-zero-check",
    "msg-value-loop",
    "reentrancy-events",
    "require-revert-in-loop",
    "return-bomb",
    "solmate-safe-transfer-lib",
  ]),
  ruleGroup("Informational", [
    "boolean-equal",
    "event-fields",
    "function-init-state",
    "inline-assembly",
    "interface-file-naming",
    "interface-naming",
    "missing-inheritance",
    "mixed-case-function",
    "mixed-case-variable",
    "multi-contract-file",
    "named-struct-fields",
    "pascal-case-struct",
    "pragma-inconsistent",
    "redundant-base-constructor-call",
    "reentrancy-unlimited-gas",
    "screaming-snake-case-const",
    "screaming-snake-case-immutable",
    "too-many-digits",
    "unaliased-plain-import",
    "unsafe-cheatcode",
    "literal-instead-of-constant",
    "modifier-used-only-once",
    "internal-function-used-once",
    "cyclomatic-complexity",
    "incorrect-using-for",
    "unused-error",
    "unused-import",
    "todo-comment",
  ]),
  ruleGroup("Gas optimization", [
    "asm-keccak256",
    "cache-array-length",
    "costly-loop",
    "could-be-constant",
    "could-be-immutable",
    "custom-errors",
    "external-function",
    "unused-state-variables",
    "var-read-using-this",
    "write-after-write",
  ]),
  ruleGroup("Code size", ["unwrapped-modifier-logic"]),
];
