Whole file

slomkowski/nginx-config-formatter

The author described this change as Fix error with brackets in comments.. It counts as a record because the checks below fail on the code as it stood at 73f01a74e and pass on 0c28d599c, with nothing else changed between the two runs.

Fix saved2016-06-16
Sharing licenceApache-2.0 · LICENSE
Change size+6 3

What the code was meant to do, written into the code itself as a save note

Fix error with brackets in comments.

The change

3535 cleaned_lines.append("")
3636 continue
3737 else:
38- cleaned_lines.extend([l.strip() for l in re.split("([\\{\\}])", line) if l != ""])
38+ if line.startswith("#"):
39+ cleaned_lines.append(line)
40+ else:
41+ cleaned_lines.extend([l.strip() for l in re.split("([\\{\\}])", line) if l != ""])
3942
4043 return cleaned_lines
4144
5659 indented_lines = []
5760 current_indent = 0
5861 for line in lines:
59- if line.endswith('}') and current_indent > 0:
62+ if not line.startswith("#") and line.endswith('}') and current_indent > 0:
6063 current_indent -= 1
6164
6265 indented_lines.append(current_indent * INDENTATION + line)
6366
64- if line.endswith('{'):
67+ if not line.startswith("#") and line.endswith('{'):
6568 current_indent += 1
6669
6770 return indented_lines

The check that tells the two apart

failpass·test_nginxfmt.py::TestFormatter::test_clear_lines
failpass·test_nginxfmt.py::TestFormatter::test_perform_indentation

Check file test_nginxfmt.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it73f01a74ec370ba78db50c065938f1ced9dcbd28
Broken version dated2016-06-16
Modulenginxfmt
Units changedclean_lines, perform_indentation
Fingerprintb0bbb7f356e6fc94
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in slomkowski/nginx-config-formatter