codemod/abap-file-too-many-lines-miner
Analyze ABAP source files and report files whose physical line count exceeds a configurable maximum, emitting per-file metrics and remediation guidance to reduce maintainability risks from overly large implementation units.
# @codemod/abap-file-too-many-lines-miner
Analyze ABAP source files and report files whose physical line count exceeds a configurable maximum, emitting per-file metrics and remediation guidance to reduce maintainability risks from overly large implementation units.
This codemod implements a read-only mining workflow for oversized ABAP implementation units. It does not rewrite source files.
## Installation
```bash
# Run the local package
npx codemod workflow run -w . -t /path/to/abap-repo
```
## Usage
The workflow scans candidate files as plain text, normalizes line endings, counts physical lines, and reports any file whose count is strictly greater than `maxLines`.
ABAP detection rules:
- Canonical `.abap` files are analyzed by default.
- Non-standard filenames are only analyzed when both of these are true:
- `detectByContentSniffing=true`
- `includeGlobs` is widened to include those files, for example `**/*`
- Generated files with markers such as `<generated>` or `do not edit` are skipped when `excludeGenerated=true`.
- Symlink handling follows the Codemod sandbox path policy. `followSymlinks=true` is accepted for workflow compatibility, but explicit real-path de-duplication is limited by the current JSSG runtime surface.
Reporting behavior:
- One warning finding is emitted per violating file with stable fields:
- `rule_id`
- `file_path`
- `file_type`
- `physical_line_count`
- `max_allowed_lines`
- `lines_over_limit`
- `severity`
- `remediation_guidance`
- Metrics are emitted through `codemod:metrics` for per-file counts, per-type totals, repository totals, percentiles, max observed line count, and skipped-file reasons.
- Source files are never edited.
Parameters:
- `maxLines`: non-negative integer threshold, default `1000`
- `includeGlobs`: comma or newline separated candidate file globs, default `**/*.abap`
- `excludeGlobs`: comma or newline separated skip globs
- `excludeGenerated`: `true` or `false`, default `true`
- `followSymlinks`: `true` or `false`, default `false`
- `detectByContentSniffing`: `true` or `false`, default `false`
- `fileTypeInference`: `true` or `false`, default `true`
Examples:
```bash
# Default threshold on standard .abap exports
npx codemod workflow run -w . -t /path/to/abap-repo --no-interactive
# Lower threshold for a focused audit
npx codemod workflow run -w . -t /path/to/abap-repo --param maxLines=600 --no-interactive
# Include non-standard filenames and classify them by content
npx codemod workflow run -w . -t /path/to/abap-repo \
--param includeGlobs=**/* \
--param detectByContentSniffing=true \
--no-interactive
```
Implementation note:
Codemod does not currently expose a native ABAP parser in JSSG, so this package intentionally performs read-only physical-line analysis over matched file text. The workflow uses a JSSG carrier step and `codemod:metrics`, but violation detection depends only on normalized file content length, not AST structure.
## Development
```bash
# Run fixture tests and a workflow smoke check
pnpm test
# Validate the workflow
npx codemod workflow validate -w workflow.yaml
# Publish to registry
npx codemod login
npx codemod publish
```
## License
MIT