Repository navigation
Fix region - #48
Open
layfield-ccdc wants to merge 4 commits into
Open
Fix region#48layfield-ccdc wants to merge 4 commits into
layfield-ccdc wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Header rewriting can break Python source decoding, duplicate headers after commented using directives, and leave duplicated licence fragments.
4 open issues
What changed in this PR
This PR expands the licence-header checker and fixer to recognise headers throughout leading preambles, including region wrappers, and repair them without unnecessary duplication.
Changes:
- Adds normalised header matching, preamble classification, and duplicate detection.
- Repairs damaged headers in place and inserts missing headers into labelled licence regions.
- Documents detection rules and adds regression tests for regions, formatting, and repeated fixes.
| File | Description |
|---|---|
test/test_licence_headers.py |
Adds coverage for preambles, regions, duplicate removal, and stable fixes. |
README.md |
Documents header detection and repair behaviour. |
main/licence_headers.py |
Implements preamble scanning, flexible matching, and span-based repairs. |
Review effort: Balanced
…n licence header checks and tests NO_JIRA
| return True | ||
| matcher = SequenceMatcher(None, actual, expected, autojunk=False) | ||
| longest = matcher.find_longest_match(0, len(actual), 0, len(expected)).size | ||
| return (longest >= 6 and longest >= len(actual) / 2) or matcher.ratio() >= 0.75 |
| PREAMBLE_DIRECTIVES = { | ||
| '.cs': ( | ||
| re.compile( | ||
| r'^\s*(?:global\s+)?using\s+(?:static\s+)?[\w.]+(?:\s*=\s*[\w.<>, ]+)?\s*;' |
Comment on lines
+365
to
+374
| index = span.end | ||
| while index < len(classified) and _is_padding(classified[index]): | ||
| index += 1 | ||
| if index >= len(classified) or classified[index].kind != 'comment' or _claimed(claimed, index): | ||
| return | ||
| others = [other for other in claimed if other is not span] | ||
| fragment = _confirmed_template_run(classified, index, expected, 1, others) | ||
| if fragment is not None: | ||
| span.end = _include_trailing_marker(classified, fragment[1], others) | ||
| span.valid = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


No description provided.