Simplify unnecessary return paths in relocation and loader modules - #709
Open
inquilabee wants to merge 2 commits into
Open
Simplify unnecessary return paths in relocation and loader modules#709inquilabee wants to merge 2 commits into
inquilabee wants to merge 2 commits into
Conversation
Collapse RET504/RET505 patterns across ELF, PE, Mach-O, and loader modules — behavior-preserving refactors from static analysis review. Co-authored-by: Cursor <cursoragent@cursor.com>
for more information, see https://pre-commit.ci
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.
Summary
Repo health: 53/100
Our analysis found 2,209 format/lint issues (under ShipGate's stricter rules) and about 57 refactoring opportunities across the reviewed scope. Security scans were clean; code duplication is modest (~2.5%); cyclomatic complexity and maintainability index flag several modules; structural refactor suggestions remain in relocation and binding helpers.
This pull request is a sample of those findings — 23 files, ~129 focused line changes — and is not a full format pass or refactor cleanup.
What you are doing right
What you could improve
Refactoring (included in example PR)
elsebranches afterreturn(RET505) across ELF, PE, Mach-O, and loader modules. This PR simplifies 98 of those patterns in 23 files.Maintainability & complexity (follow-up)
Dependencies (follow-up)
pyelftoolsandpyxbeare declared but reported unused by deptry (may be optional/runtime paths).Duplication (follow-up)
Lint / style (follow-up)
Changes
cle/backends/elf/relocation/ppc.py— collapse unnecessaryresulttemporaries before return (20 sites).cle/backends/macho/structs.py,cle/backends/macho/symbol.py,cle/backends/macho/macho.py— RET505/RET504 simplifications in Mach-O parsing.cle/backends/pe/pe.py,cle/backends/pe/relocation/generic.py— remove unnecessary relocation temporaries.cle/backends/coff.py,cle/backends/backend.py,cle/backends/relocation.py— simplify return paths in COFF/PE relocation helpers.cle/loader.py,cle/memory.py— streamline loader and memory serialization returns.cle/backends/elf/metaelf.py,cle/backends/elf/symbol_type.py,cle/backends/elf/variable_type.py— ELF symbol/type helpers.cle/backends/externs/__init__.py,cle/backends/java/soot.py,cle/backends/tls/*.py— minor return-path cleanup in extern and TLS backends.Verification
(Full
uv sync+ pytest requires native build of pyvex/archinfo; not run locally in this review environment.)Review summary produced with ShipGate — a policy-first quality orchestrator that runs linters, formatters, security scanners, and refactor checks from one catalog. This PR used
check+refactor check --strictto find issues; docs.