Ccodemod

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.

abapmaintainabilitymetricsminingcode-mining
Public
0 executions

Run locally

npx codemod @codemod/abap-file-too-many-lines-miner

@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

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

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

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.