feat(audit): rich rollups + per-line indentation fix - 2136 total lines
Added 3 new top-level rollups (hot_paths.md, dead_fields.md, plus enriched summary.md, candidates.md, decomposition_matrix.md): - summary.md: per-aggregate memory_dim + access pattern tables, full cross-validation verdict per aggregate - decomposition_matrix.md: all 10 aggregates ranked by current cost, flagged-for-refactoring section, insufficient_data section - candidates.md: ranked optimization candidates with detail per step - hot_paths.md: top 5 hot consumers per aggregate (by field access count) - dead_fields.md: fields accessed (per-consumer breakdown) Total report: 2136 lines (was 1814).
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
with open(r'C:\projects\manual_slop_tier2\src\code_path_audit_rollups.py', 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# Lines 263-265 need fixing
|
||||
# Line 263: ' for i, ...:' - keep as is (1 space indent for top-level for)
|
||||
# Line 264: ' lines.append...' - should be 2 spaces (inside for body)
|
||||
# Line 265: ' lines.append("")' - should be 2 spaces (inside for body)
|
||||
|
||||
# Find and fix all lines 264+ that are at 3-space indent inside a for loop
|
||||
new_lines = []
|
||||
in_for = False
|
||||
for i, line in enumerate(lines):
|
||||
if i == 263:
|
||||
in_for = True
|
||||
new_lines.append(line)
|
||||
continue
|
||||
if in_for and line.startswith(' ') and not line.startswith(' '):
|
||||
# Reduce 3-space indent to 2-space
|
||||
new_lines.append(' ' + line[3:])
|
||||
else:
|
||||
new_lines.append(line)
|
||||
|
||||
with open(r'C:\projects\manual_slop_tier2\src\code_path_audit_rollups.py', 'w') as f:
|
||||
f.writelines(new_lines)
|
||||
print('fixed')
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Fix indentation in rollups file."""
|
||||
import re
|
||||
|
||||
filepath = r'C:\projects\manual_slop_tier2\src\code_path_audit_rollups.py'
|
||||
|
||||
with open(filepath, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Find all for loops and fix their body indent to be 2 spaces
|
||||
# Pattern: at start of line, 2 spaces + "for " + ... + ":" then body should be 2-space indent too
|
||||
# Currently the body has 3 spaces, we want 2
|
||||
|
||||
lines = content.split('\n')
|
||||
new_lines = []
|
||||
for i, line in enumerate(lines):
|
||||
stripped = line.lstrip()
|
||||
indent = len(line) - len(stripped)
|
||||
# Lines that start with 3 spaces and have content (likely inside a for loop body)
|
||||
if indent == 3 and stripped:
|
||||
# Check if previous line was a for/if/while (probably at 1 or 2 space indent)
|
||||
if i > 0:
|
||||
prev = lines[i-1]
|
||||
prev_stripped = prev.rstrip()
|
||||
if prev_stripped.endswith(':') and not prev_stripped.startswith('#'):
|
||||
# This line is inside a for/if body, reduce indent by 1
|
||||
new_lines.append(' ' + stripped)
|
||||
continue
|
||||
new_lines.append(line)
|
||||
|
||||
with open(filepath, 'w') as f:
|
||||
f.write('\n'.join(new_lines))
|
||||
|
||||
print('fixed')
|
||||
@@ -0,0 +1,43 @@
|
||||
"""Brute-force normalize indentation: every line at N spaces should be at the deepest appropriate indent."""
|
||||
import re
|
||||
|
||||
filepath = r'C:\projects\manual_slop_tier2\src\code_path_audit_rollups.py'
|
||||
|
||||
with open(filepath, 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# Walk lines, track expected indent depth via for/if/while/with/def/class
|
||||
# and fix each line's indent to match expected
|
||||
def get_indent(line):
|
||||
return len(line) - len(line.lstrip(' '))
|
||||
|
||||
new_lines = []
|
||||
expected_indent = 0
|
||||
prev_block_open = False
|
||||
for i, line in enumerate(lines):
|
||||
stripped = line.lstrip()
|
||||
if not stripped or stripped.startswith('#'):
|
||||
new_lines.append(line)
|
||||
continue
|
||||
cur_indent = get_indent(line)
|
||||
if cur_indent > expected_indent + 2:
|
||||
# Too deep — reset to expected
|
||||
new_lines.append(' ' * (expected_indent + 2) + stripped)
|
||||
elif cur_indent < expected_indent:
|
||||
# Dedent
|
||||
new_lines.append(' ' * expected_indent + stripped)
|
||||
expected_indent = cur_indent
|
||||
else:
|
||||
new_lines.append(line)
|
||||
# If line ends with ':', increase expected for next line
|
||||
if stripped.rstrip().endswith(':') and not stripped.startswith(' '):
|
||||
expected_indent += 2
|
||||
# If line is a 'return' or 'pass' or endswith, decrease expected
|
||||
elif stripped.startswith(('return ', 'pass', 'break', 'continue', 'raise ')):
|
||||
# next line should be at or above this indent
|
||||
pass
|
||||
|
||||
with open(filepath, 'w') as f:
|
||||
f.writelines(new_lines)
|
||||
|
||||
print('normalized')
|
||||
Reference in New Issue
Block a user