-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Component
General design optimization (improving efficiency, cleanliness, or developer experience)
Describe the suggested feature and problem it solves.
Suggested Feature: Reordering and Deduplicating Imports
Problem
Currently, the import statements in the /test contain duplicates and are not consistently ordered. This can lead to:
- Reduced readability and maintainability of the code.
- Potential merge conflicts when multiple contributors modify the same files.
- Difficulty in quickly locating dependencies within the import section.
Proposed Solution
- Remove duplicate imports to eliminate redundancy.
- Reorder imports in a structured manner, following a logical grouping such as:
- External dependencies
- Utilities
- Types
- Interfaces
- Libraries
- Contracts
- Test files
- Ensure a consistent ordering convention to improve code clarity and prevent future inconsistencies.
Benefits
- Enhances code readability and maintainability.
- Reduces the likelihood of unnecessary merge conflicts.
- Improves the overall structure of import statements, making them easier to manage.
I will open a pull request after creating this issue.
Describe the desired implementation.
Desired Implementation
1. Remove duplicate imports
- Scan all Solidity files for redundant import statements.
- Remove any duplicates while ensuring all necessary dependencies remain intact.
2. Standardize import order
-
Follow a structured grouping approach to maintain consistency:
- External dependencies (e.g.,
forge-std
,solmate
) - Utilities (e.g.,
./utils/
) - Types (e.g.,
../src/types/
) - Interfaces (e.g.,
../src/interfaces/
) - Libraries (e.g.,
../src/libraries/
) - Contracts (e.g.,
../src/PoolManager.sol
) - Test files (e.g.,
../src/test/
)
- External dependencies (e.g.,
-
Within each category, imports need to be sorted alphabetically.
Example of the new structure
Before:
import {Test} from "forge-std/Test.sol";
import {Vm} from "forge-std/Vm.sol";
import {PoolId} from "../src/types/PoolId.sol";
import {Hooks} from "../src/libraries/Hooks.sol";
import {IPoolManager} from "../src/interfaces/IPoolManager.sol";
import {IProtocolFees} from "../src/interfaces/IProtocolFees.sol";
import {IHooks} from "../src/interfaces/IHooks.sol";
import {PoolKey} from "../src/types/PoolKey.sol";
import {PoolManager} from "../src/PoolManager.sol";
import {PoolSwapTest} from "../src/test/PoolSwapTest.sol";
import {Deployers} from "./utils/Deployers.sol";
import {Currency} from "../src/types/Currency.sol";
import {MockERC20} from "solmate/src/test/utils/mocks/MockERC20.sol";
import {FullMath} from "../src/libraries/FullMath.sol";
import {BalanceDelta} from "../src/types/BalanceDelta.sol";
import {StateLibrary} from "../src/libraries/StateLibrary.sol";
After (reordered and deduplicated):
import {Test} from "forge-std/Test.sol";
import {Vm} from "forge-std/Vm.sol";
import {MockERC20} from "solmate/src/test/utils/mocks/MockERC20.sol";
import {Deployers} from "./utils/Deployers.sol";
import {BalanceDelta} from "../src/types/BalanceDelta.sol";
import {Currency} from "../src/types/Currency.sol";
import {PoolId} from "../src/types/PoolId.sol";
import {PoolKey} from "../src/types/PoolKey.sol";
import {IHooks} from "../src/interfaces/IHooks.sol";
import {IPoolManager} from "../src/interfaces/IPoolManager.sol";
import {IProtocolFees} from "../src/interfaces/IProtocolFees.sol";
import {FullMath} from "../src/libraries/FullMath.sol";
import {Hooks} from "../src/libraries/Hooks.sol";
import {StateLibrary} from "../src/libraries/StateLibrary.sol";
import {PoolManager} from "../src/PoolManager.sol";
import {PoolSwapTest} from "../src/test/PoolSwapTest.sol";
Describe alternatives.
No response
Additional context.
No response