Skip to content

#14 feat: add PERF016 rule detecting repeated scans of the same table - #109

Merged
RAprogramm merged 1 commit into
mainfrom
14
Jul 14, 2026
Merged

#14 feat: add PERF016 rule detecting repeated scans of the same table#109
RAprogramm merged 1 commit into
mainfrom
14

Conversation

@RAprogramm

Copy link
Copy Markdown
Owner

Closes #14

New performance rule PERF016 (Info): flags statements that scan one table multiple times (self-joins, repeated subqueries over the same data) by counting word-bounded FROM/JOIN references. A CTE, window function, or conditional aggregation usually reads the table once.

  • README, Cargo.toml description, docs updated to 34 rules; version bumped to 0.15.0
  • 3 new tests: subquery re-scan, self-join, single-scan negative

Local checks: fmt, clippy -D warnings, tests, cargo qual (0 issues), mdbook build — all green.

@github-actions

Copy link
Copy Markdown
Contributor

Rust Diff Analysis

Tip

PR size is within limits. Good job keeping changes focused!

Limits — configured thresholds for this repository

Each metric is compared against its configured maximum. If any limit is exceeded, the PR check fails.

Metric Value Limit Status
Production Units 6 30
Weighted Score 11 100
Lines Added 62 200

Understanding the metrics:

  • Production Units: Functions, structs, enums, traits, and other semantic code units in production code
  • Weighted Score: Complexity score based on unit types (public APIs weigh more than private)
  • Lines Added: Raw count of new lines in production code
Summary — breakdown of changes by category

Production code counts toward limits. Test code is tracked but doesn't affect limits.

Metric Production Test
Functions 4 -
Structs/Enums 1 -
Other 1 -
Lines added +62 +19
Lines removed -0 -0
Total units 6 3
Production Changes — 6 units modified

Semantic units (functions, structs, etc.) that were added or modified in production code.

File Unit Type Changes
src/rules.rs:182-243 RuleRunner::with_config function +1 -0
src/rules/performance.rs:741-746 RepeatedTableScan struct +6 -0
src/rules/performance.rs:748-766 table_scan_count function +19 -0
src/rules/performance.rs:768-803 Rule for RepeatedTableScan impl +3 -0
src/rules/performance.rs:769-776 Rule for RepeatedTableScan::info function +8 -0
src/rules/performance.rs:778-802 Rule for RepeatedTableScan::check function +25 -0
Test Changes — 3 units modified

Test code changes don't count toward PR size limits.

File Unit Type Changes
tests/rules_tests.rs:184-190 test_repeated_table_scan_flagged function +7 -0
tests/rules_tests.rs:192-198 test_self_join_flagged function +7 -0
tests/rules_tests.rs:200-204 test_single_scan_not_flagged function +5 -0
Analysis Scope

Analyzed: 3 Rust files

Skipped files:

  • 6 non-Rust files

Skipped file list:

  • Cargo.lock (non-Rust)
  • Cargo.toml (non-Rust)
  • README.md (non-Rust)
  • docs/src/introduction.md (non-Rust)
  • docs/src/rules/index.md (non-Rust)
  • docs/src/rules/performance.md (non-Rust)

Rust Diff Analyzer

@github-actions

Copy link
Copy Markdown
Contributor

Cargo Quality Analysis

Tip

All quality checks passed. Code meets all standards!

Results — issues found by each analyzer

Each analyzer checks for specific code patterns. Zero issues means the check passed.

Analyzer Issues Status
path_import 0
format_args 0
empty_lines 0
inline_comments 0
mod_rs 0
Total 0
Analyzers — what each check does

These analyzers enforce consistent code style and best practices.

Analyzer Description How to fix
path_import Detects inline path imports like std::path::Path Use use statements at the top
format_args Detects format!("{}", x) patterns Use format!("{x}") syntax
empty_lines Detects empty lines inside function bodies Remove extra blank lines
inline_comments Detects // comment inside functions Move to doc comments or remove
mod_rs Detects mod.rs files (use modern module style) Rename foo/mod.rs to foo.rs
Raw Output — detailed analysis log
Total issues: 0
Fixable: 0

Cargo Quality

Comment thread src/rules/performance.rs
pub struct RepeatedTableScan;

/// Counts FROM/JOIN references to `table` at word boundaries.
fn table_scan_count(upper: &str, table: &str) -> usize {
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@RAprogramm
RAprogramm merged commit f90d28e into main Jul 14, 2026
29 checks passed
@RAprogramm
RAprogramm deleted the 14 branch July 14, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PERF016: Detect same table accessed multiple times

2 participants