Readability refactors in sql_metadata and test fixture formatting - #667
Open
inquilabee wants to merge 1 commit into
Open
Readability refactors in sql_metadata and test fixture formatting#667inquilabee wants to merge 1 commit into
inquilabee wants to merge 1 commit into
Conversation
Simplify regex match indexing, ternary patterns, and min() default usage in the core package; ruff-format test SQL fixtures with trailing whitespace.
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.
I rely on sql-metadata for SQL parsing in analytics pipelines and wanted to contribute a small readability pass on the core package while running ShipGate for a broader quality picture.
Summary
Repo health: 58/100
ShipGate reported 72 format issues (mostly trailing whitespace in test SQL fixtures) and ~124 refactoring opportunities (strict pass) on a full-repo scan. Security scans and duplication checks were clean; the main themes are cyclomatic complexity in
column_extractor/parser, large module sizes, and optional strict-refactor simplifications. This PR applies an auto-fix pass on the production package plus ruff formatting on a handful of test files where line-length and whitespace were noisy.Hotspots and improvement notes below are scoped to Python (
*.py) source.What you are doing right
sql_metadata; mypy strict mode on the package is green.ColumnExtractor,TableExtractor,NestedResolver) with lazy caching on theParserfacade — well documented inARCHITECTURE.md.What you could improve
_handle_cteand_handle_aliasincolumn_extractor.pyrank C on cyclomatic complexity (CC 11–12);values_dictinparser.pyis similar — incremental helper extraction would help over time.column_extractor.py(~900 lines),nested_resolver.py, andparser.pyexceed typical module-size gates — consider splitting by clause type when the next feature lands.NoReturnimport inquery_type_extractor.pyappears unused (vulture) — safe cleanup follow-up.assign-if-exp, walrus, and regex group indexing; many are optional style wins.make formatontest/would clear most of the 72 format findings.Changes
shipgate format --target sql_metadatashipgate refactor fix sql_metadata+ strict hintsuse-getitem-for-re-match-groups,use-named-expression,min-default, ternary cleanupruff format+ruff check --fixontest/match[1]) instead of.group(1)inparser.pyandsql_cleaner.py.column_extractor.py,generalizator.py, andtable_extractor.py.We're testing ShipGate on real-world projects to learn whether it works well in practice. This review summary was generated from ShipGate check output and AI-assisted analysis. Feedback on the findings or approach is welcome and appreciated — docs.
Full ShipGate findings: review gist