adevar-move
Version:
CLI tool to scope Move projects for auditing - counts lines of code excluding comments, blank lines, and test macros
144 lines (105 loc) ⢠3.91 kB
Markdown
# Adevar Move
A CLI tool to scope Move projects for auditing by counting lines of code, excluding comments, blank lines, and test macros.
## Features
- š Recursively scans directories for `.move` files
- š Counts lines of code excluding:
- Single-line comments (`//`)
- Block comments (`/* */`)
- Blank lines and whitespace-only lines
- Test code within `#[test]` and `#[test_only]` macros
- š Outputs a formatted table with individual file stats and totals
- šÆ Perfect for audit scoping and project analysis
## Installation
### Global Installation (Recommended)
```bash
npm install -g adevar-move
```
### Local Installation
```bash
npm install adevar-move
```
## Usage
### Command Line
```bash
# Analyze current directory
adevar-move
# Analyze specific directory
adevar-move /path/to/move/project
# Examples
adevar-move ./contracts
adevar-move ../my-move-project
```
### Programmatic Usage
```javascript
const { analyzeProject } = require('adevar-move');
const result = analyzeProject('/path/to/move/project');
console.log(`Total LOC: ${result.totalLOC}`);
console.log(`Files: ${result.totalFiles}`);
```
## Output Example
```
š Move Project Audit Scope Analysis
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāā
ā File ā Lines of Code ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāā¤
ā sources/token.move ā 150 ā
ā sources/marketplace.move ā 200 ā
ā sources/governance/voting.move ā 120 ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāā¤
ā TOTAL ā 470 ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāā
Summary: 3 files, 470 total lines of code
```
## What Gets Excluded
### Comments
```move
// This single-line comment is excluded
/* This block comment
is also excluded */
module example {
// This is excluded
public fun valid_code() { } // This line counts as 1 LOC
}
```
### Test Macros
```move
#[test]
fun test_function() {
// This entire function is excluded from LOC count
assert!(true, 0);
}
#[test_only]
module test_helpers {
// This entire module is excluded
}
```
### Blank Lines
```move
module example {
// Empty lines above and below are excluded
public fun function() { } // This counts as 1 LOC
}
```
## Requirements
- Node.js >= 14.0.0
- Works on Windows, macOS, and Linux
## Development
```bash
# Clone the repository
git clone https://github.com/AdevarLabs/adevar-move.git
cd adevar-move
# Install dependencies
npm install
# Run locally
node index.js /path/to/test/project
```
## License
MIT
## Contributing
Pull requests are welcome! Please feel free to submit issues and enhancement requests.
## Changelog
### 1.0.0
- Initial release
- Basic Move file scanning and LOC counting
- Comment and test macro exclusion
- Formatted table output