Skip to content

feat: report 1-based line number with each finding - #5

Open
Chirudeva-Reddy wants to merge 2 commits into
greencalculus:mainfrom
Chirudeva-Reddy:fix/issue-4-report-line-numbers
Open

Chirudeva-Reddy wants to merge 2 commits into
greencalculus:mainfrom
Chirudeva-Reddy:fix/issue-4-report-line-numbers

Conversation

@Chirudeva-Reddy

Copy link
Copy Markdown

Motivation

Resolves #4. Findings previously identified the file and gas name, but omitted the line number within the file. In larger files or CI/editor integrations, 1-based line numbers allow direct inline annotations and fast navigation to the offending cell.

Changes

  • Running offset tracking in records(): Tracked running character offsets across re.split(r"[{}]", text) blocks rather than searching the text again, preserving absolute line positions even across repeated rows.
  • Regex and row offset tracking:
    • basis_maps(): Used ENTRY.finditer inside BASIS_MAP.finditer to capture exact entry line numbers per report basis.
    • tables(): Tracked row line numbers across HTML (<tr...> via re.finditer), Markdown (splitlines() row indices), and CSV formats.
  • Output updates:
    • Added line (1-based integer) to each finding in --json output.
    • Included line numbers in human CLI output (line <N>: ...).
  • Self-test additions: Added a self-test case asserting the exact line number of a known finding.

Verification

  • python3 gwp_basis_check.py --self-test: All 9 existing test cases plus the new line-number test case pass.
  • python3 render_tables.py --check: README tables match reference.
  • python3 gwp_basis_check.py README.md: Passes cleanly.
  • Verified line numbers across TypeScript/Python records, HTML tables, Markdown tables, and CSV tables with --json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report a line number with each finding

1 participant