Skip to content

feat: add file complexity analyzer for review prioritization#36

Closed
SimonOyaneder wants to merge 1 commit into
mainfrom
feat/add-file-analyzer
Closed

feat: add file complexity analyzer for review prioritization#36
SimonOyaneder wants to merge 1 commit into
mainfrom
feat/add-file-analyzer

Conversation

@SimonOyaneder

Copy link
Copy Markdown
Owner

Summary

  • Adds a new file analyzer module that computes complexity scores for repository files
  • Includes token counting, content hashing, and parallel processing helpers
  • Stores analysis results in PostgreSQL for review prioritization

Test plan

  • Unit tests for complexity scoring
  • Integration test with real PostgreSQL

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@canon-review canon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 4 pattern deviations: 🔴 2 high · 🟡 2 medium


// ── Types ────────────────────────────────────────────────────────────

interface file_analysis_result {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Naming Convention · medium · confidence: 99%

Type/interface names use snake_case instead of PascalCase.

Existing pattern: Interfaces are PascalCase (e.g., IndexProgress, RepoParams, PullRequestInfo).
Reference: src/intelligence/indexer.ts

Suggested change
interface file_analysis_result {
interface FileAnalysisResult {
filePath: string;
tokenCount: number;
contentHash: string;
complexityScore: number;
}
interface AnalysisSummary {
totalFiles: number;
totalTokens: number;
highComplexityFiles: string[];
}


// ── Helpers ──────────────────────────────────────────────────────────

const compute_content_hash = (content: string): string => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Duplicated Code · high · confidence: 98%

Reimplements hashing logic instead of using the shared hash utility.

Existing pattern: Hashing file/content strings is centralized via sha256Hash from src/lib/hash and reused by intelligence/github handlers.
Reference: src/intelligence/indexer.ts

Suggested change
const compute_content_hash = (content: string): string => {
import { sha256Hash } from "../lib/hash";
const computeContentHash = (content: string): string => {
return sha256Hash(content).slice(0, 16);
};


// ── Concurrency helper ───────────────────────────────────────────────

const run_in_parallel = async <T, R>(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Duplicated Code · high · confidence: 97%

Adds a local concurrency mapper instead of using the shared concurrency utility.

Existing pattern: Parallel async mapping is centralized via mapWithConcurrency from src/lib/concurrency and reused in intelligence/github flows.
Reference: src/intelligence/indexer.ts

Suggested change
const run_in_parallel = async <T, R>(
import { mapWithConcurrency } from "../lib/concurrency";
const results = await mapWithConcurrency(
entries,
5,
async ([path, content]) => analyzeSingleFile(path, content),
);

);
}
await client.query("COMMIT");
} catch (err) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Pattern Violation · medium · confidence: 95%

Catch variable name and rethrow pattern deviates from repository transaction pattern (error / throw error).

Existing pattern: DB transaction blocks catch error, rollback, then throw error.
Reference: CANON.md

Suggested change
} catch (err) {
} catch (error) {
await client.query("ROLLBACK");
throw error;
}

@SimonOyaneder SimonOyaneder deleted the feat/add-file-analyzer branch February 27, 2026 14:47
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.

1 participant