mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 12:13:43 +00:00
check-whitespace: fix idempotency issue
See the comment, if there was couple whitespaces at the end of the file without newline, it would take running `check-whitespace` twice to finally fix it.
This commit is contained in:
@@ -276,6 +276,19 @@ class TestChecker:
|
||||
) -> None:
|
||||
self._assert_check(Checker._check_trailing_whitespaces, content, expected_issues, fixed, check, line_ending)
|
||||
|
||||
def test_trailing_whitespace_runs_before_eof_newline(self, tmp_path: Path) -> None:
|
||||
# 'foo\n\s\s` should result in `foo\n`.
|
||||
# If we run eof check first before trailing whitespace check,
|
||||
# it will result in `foo\n\n` instead.
|
||||
filepath = tmp_path / "test.txt"
|
||||
filepath.write_bytes(b"foo\n \n\n")
|
||||
|
||||
checker = Checker(LF)
|
||||
checker.check_trailing_whitespaces(filepath, False)
|
||||
checker.check_eof_newline(filepath, False)
|
||||
|
||||
assert filepath.read_bytes() == b"foo\n"
|
||||
|
||||
@staticmethod
|
||||
def run_tests(extra_args: list[str] | None = None) -> None:
|
||||
pytest.main([__file__, *(extra_args or [])])
|
||||
@@ -382,8 +395,8 @@ def main() -> int:
|
||||
checker.set_newline_for_path(filepath)
|
||||
checker.check_stray_cr(filepath, args.check)
|
||||
checker.check_line_endings_mismatch(filepath, args.check)
|
||||
checker.check_eof_newline(filepath, args.check)
|
||||
checker.check_trailing_whitespaces(filepath, args.check)
|
||||
checker.check_eof_newline(filepath, args.check)
|
||||
print(f"{len(filepaths)} file(s) checked.")
|
||||
if not checker.issues:
|
||||
color = C.GREEN
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
box-shadow: 0 0 0 3px #28a745;
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.classificationView {
|
||||
border-left: 5px solid #28a745;
|
||||
min-height: 200px;
|
||||
@@ -15,20 +15,20 @@
|
||||
padding: 5px;
|
||||
max-height: 400px;
|
||||
}
|
||||
|
||||
|
||||
.selectedClassificationText {
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
|
||||
.back-button {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
||||
.back-button:disabled {
|
||||
cursor: not-allowed;
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
|
||||
.classification-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -36,8 +36,7 @@
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
.classification {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user