Repository navigation
feat: add T-SQL rules T001-T004 and FETCH NEXT pagination support - #23
Merged
Merged
Conversation
Closes #22. T001 with-nolock, T002 xp-cmdshell, T003 cursor-declaration, T004 deprecated-outer-join. Plus W002/W006 regex tweak so T-SQL OFFSET/FETCH NEXT pagination counts as bounded. 18 new tests, 80 total passing.
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.
Closes #22.
Adds four T-SQL-specific rules and a small regex tweak so T-SQL
pagination no longer trips the LIMIT-aware warnings.
New rules
with-nolock(warning). FlagsWITH (NOLOCK)table hints.Causes dirty reads.
xp-cmdshell(error). FlagsEXEC xp_cmdshell. Shell-execsurface that should never appear in application SQL.
cursor-declaration(warning). FlagsDECLARE ... CURSOR.Row-by-row processing where set-based SQL usually does better.
deprecated-outer-join(error). Flags*=and=*old-styleouter-join syntax. Unsupported in SQL Server 2012 and later. Uses a
negative lookbehind to avoid matching modern compound-assignment
expressions like
SET @x *= 2.Regex tweak
W002
missing-limitand W006orderby-without-limitnow matchFETCH\s+(FIRST|NEXT)instead of onlyFETCH\s+FIRST, so T-SQL'sOFFSET n ROWS FETCH NEXT m ROWS ONLYpagination counts as bounded.Scope notes
The originally proposed
old-style-joinrule is already covered byS001
ImplicitCrossJoin, so dropped to avoid duplicate findings.Version bump, README rule-count refresh, and
.pre-commit-config.yamlrev update are intentionally left for a release-prep PR so
precommit_rev_matches_tagdoes not complain about a tag that doesnot yet exist.
Tests
18 new tests in
tests/test_tsql.pycovering each rule's positiveand negative cases, including:
WITH cte AS.xp_cmdshellcase-insensitively, ignoressp_executesql.DECLARE @i INT.*=and=*, ignores compound assignment, plainassignment, and modern JOIN syntax.
FETCH FIRST(existing) andFETCH NEXT(new) T-SQL pagination.Full suite: 80 passed, 1 skipped.