101 lines
4.2 KiB
Markdown
101 lines
4.2 KiB
Markdown
# PR#112: A Moved File with Only Package and Import Changes Is Mechanical
|
|
|
|
Version: minor
|
|
|
|
> **WARNING:** This document describes only the change applied in this PR.
|
|
> It may already be outdated once the next PR is merged.
|
|
> Historic PR documentation is not maintained along with new PRs; treat it as a snapshot.
|
|
|
|
## Related Links
|
|
|
|
- [werkregie PR#86](https://git.javagil.de/mi/werkregie/pulls/86): names follow javagil.de.
|
|
- [werkbaum PR#11](https://git.javagil.de/mi/werkbaum/pulls/11): the move that got YELLOW for its size.
|
|
|
|
## Problem
|
|
|
|
werkregie PR#86 moves the JVM packages of all werk repositories to `de.javagil.<repo>`.
|
|
Such a move renames each file and changes its `package` line and some `import` lines.
|
|
werkrevisor counts a renamed file as mechanical only if its content stays the same,
|
|
so each moved file counts for `[size] max_files`.
|
|
werkbaum PR#11 moved 46 files and got YELLOW only for `max_files = 30`.
|
|
Werkator (272 files), Werkjournal (114) and werkregie (70) follow with the same kind of PR.
|
|
|
|
## Non-Goals
|
|
|
|
- No change of `[size]`; the moved files leave the count because they become mechanical.
|
|
- No change for a renamed file without content changes; it stays mechanical as before.
|
|
|
|
## Specification
|
|
|
|
### Feature: a moved file with only package and import changes is mechanical
|
|
|
|
#### Scenario#112.01: a pure move does not count
|
|
|
|
… so that a package move across many files needs no human for its size.
|
|
|
|
- **Given** a renamed Java or Kotlin file whose diff changes only its `package` and `import` lines
|
|
- **When** werkrevisor applies its rules
|
|
- **Then** the file is mechanical as "imports, renamed" and does not count for `[size]`
|
|
|
|
##### Verified by
|
|
|
|
- [test_mechanical: test_rename_with_only_package_and_import_changes](../../tests/test_mechanical.py)
|
|
- [test_mechanical: test_moved_files_do_not_count_for_the_size_limits](../../tests/test_mechanical.py)
|
|
|
|
#### Scenario#112.02: a move with a changed line of logic counts
|
|
|
|
… so that a move cannot hide a change of the code.
|
|
|
|
- **Given** a renamed file whose diff also changes a line that no rule explains under its old or its new name
|
|
- **When** werkrevisor applies its rules
|
|
- **Then** the file is not mechanical and counts for `[size]`
|
|
|
|
##### Verified by
|
|
|
|
- [test_mechanical: test_rename_with_a_logic_change_is_not_mechanical](../../tests/test_mechanical.py)
|
|
- [test_mechanical: test_rename_keeps_the_rules_of_the_old_name](../../tests/test_mechanical.py)
|
|
|
|
#### Scenario#112.03: a move into another category counts
|
|
|
|
… so that a test cannot become main code, or a document code, without a review.
|
|
|
|
- **Given** a file renamed from one category to another, e.g. from `src/test/` to `src/main/`
|
|
- **When** its diff changes only its `package` and `import` lines
|
|
- **Then** the file is not mechanical
|
|
|
|
##### Verified by
|
|
|
|
- [test_mechanical: test_rename_into_another_category_is_not_mechanical](../../tests/test_mechanical.py)
|
|
|
|
#### Scenario#112.04: an import change without a move counts as before
|
|
|
|
… so that the change keeps the existing rule for modified files.
|
|
|
|
- **Given** a modified file that is not renamed and changes only its `import` lines
|
|
- **When** werkrevisor applies its rules
|
|
- **Then** the file is mechanical as "imports", as before
|
|
|
|
##### Verified by
|
|
|
|
- [test_mechanical: test_java_and_kotlin_import_and_package_lines](../../tests/test_mechanical.py)
|
|
|
|
## Solution
|
|
|
|
- `werkrevisor/mechanical.py`: a renamed file goes through the import and whitespace rules like a modified one;
|
|
if they explain every changed line, its label is "renamed" plus the rules, e.g. "imports, renamed".
|
|
A renamed file with content changes keeps its file extension, and a whitespace-significant name, e.g. `*.py`,
|
|
counts under its old and its new name.
|
|
- `werkrevisor/rules.py`: a renamed file with content changes is mechanical only if its old and new path
|
|
are in the same category.
|
|
- README `[mechanical]`: the rule for a renamed file.
|
|
- Version 0.43.0.
|
|
|
|
A mechanical file goes neither to the model nor to Jev, and this PR keeps that for moved files.
|
|
Its diff holds only `package` and `import` lines, so Jev would judge the same lines for each of hundreds of files,
|
|
with nothing to find in them.
|
|
The hard rules still apply to both names of a renamed file, e.g. a move into or out of a risky path gives YELLOW.
|
|
|
|
## Open Questions
|
|
|
|
None.
|