Skip to content

Commit b05b3af

Browse files
tae2089claude
andcommitted
Remove dead code and fix gofmt drift
Delete verified-unused symbols: existingFilesMissingFrom, importPackageNames, rebuildSearch, newParsedBuildEdgeBatch (service); countNonIgnored, lintRuleDoc (cli/lint). Run gofmt -w over the 13 drifted files. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 8f1ef58 commit b05b3af

14 files changed

Lines changed: 154 additions & 205 deletions

internal/analysis/flows/flows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (t *Tracer) TraceFlowBounded(ctx context.Context, startNodeID uint, opts Tr
143143
Truncated: truncated,
144144
MaxNodes: opts.MaxNodes,
145145
ReturnedNodes: len(members),
146-
ContainsFallbackCalls: containsFallbackCalls,
146+
ContainsFallbackCalls: containsFallbackCalls,
147147
FallbackEdgesCount: fallbackEdges,
148148
}, nil
149149
}

internal/annotation/normalizer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func stripBlockDelimiters(text string, language string) string {
8484
}
8585

8686
// stripPythonDocstringDelimiters removes triple-quote wrappers from a Python docstring body.
87-
// @intent expose the raw docstring text by trying both """ and ''' triple-quote forms.
87+
// @intent expose the raw docstring text by trying both """ and ' triple-quote forms.
8888
func stripPythonDocstringDelimiters(text string) (string, bool) {
8989
for _, quote := range []string{"\"\"\"", "'''"} {
9090
if stripped, ok := stripPythonQuotedString(text, quote); ok {

internal/cli/lint.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ import (
1717
"github.com/tae2089/code-context-graph/internal/pathutil"
1818
)
1919

20-
// countNonIgnored counts lint issues not covered by an ignore rule in .ccg.yaml.
21-
// @intent strict 모드에서 실제 실패로 간주할 lint 항목만 다시 집계한다.
22-
// @domainRule action: ignore로 선언된 규칙은 strict 실패 수에서 제외한다.
23-
func countNonIgnored(report *docs.LintReport) int {
24-
return countNonIgnoredWithRules(report, configuredLintRules())
25-
}
26-
2720
// normalizeLintCategory maps legacy or variant category names to canonical forms.
2821
// @intent ensure rule matching uses consistent category keys regardless of input spelling
2922
// @domainRule "deadref" and "drifted" are accepted aliases for "dead-ref" and "drift"
@@ -261,12 +254,6 @@ func lintRuleFromMapLookup(lookup func(string) (any, bool)) (lintRule, bool) {
261254
return rule, rule.Pattern != "" || rule.Category != "" || rule.Action != ""
262255
}
263256

264-
// lintRuleDoc is the top-level YAML structure for a standalone rules file.
265-
// @intent represent the on-disk format used when rules are stored outside .ccg.yaml
266-
type lintRuleDoc struct {
267-
Rules []lintRule `yaml:"rules"`
268-
}
269-
270257
// lintRule is a single suppression or warn rule entry in .ccg.yaml or auto-rules.yaml.
271258
// @intent carry the pattern, category, and action that determine how a lint finding is handled
272259
// @domainRule auto:true marks rules generated by the Twice Rule engine, not written by the user

internal/parse/binder_test.go

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ func TestBinder_MultipleDeclarations(t *testing.T) {
111111
// 바인딩이 성공함을 검증합니다.
112112
//
113113
// fixture 기준:
114-
// Line 1-4: docstring ("""...""")
115-
// Line 5: @app.route('/api/user')
116-
// Line 6: @login_required
117-
// Line 7: def get_user(): ← tree-sitter StartLine 예상
114+
//
115+
// Line 1-4: docstring ("""...""")
116+
// Line 5: @app.route('/api/user')
117+
// Line 6: @login_required
118+
// Line 7: def get_user(): ← tree-sitter StartLine 예상
118119
//
119120
// gap = 7 - 4 = 3 ≤ maxGap(3) → 바인딩 성공
120121
func TestBinder_PythonDecoratorGap_BindsWithinMaxGap(t *testing.T) {
@@ -188,11 +189,12 @@ func TestBinder_JavaAnnotationGap_PassthroughBinds(t *testing.T) {
188189
// 바인딩이 성공함을 검증합니다.
189190
//
190191
// fixture (attribute_gap.rs) 기준:
191-
// Line 1: /// @intent 비동기 main 진입점
192-
// Line 2: /// @sideEffect 런타임 초기화
193-
// Line 3: #[tokio::main]
194-
// Line 4: #[allow(dead_code)]
195-
// Line 5: async fn main() { ← tree-sitter StartLine
192+
//
193+
// Line 1: /// @intent 비동기 main 진입점
194+
// Line 2: /// @sideEffect 런타임 초기화
195+
// Line 3: #[tokio::main]
196+
// Line 4: #[allow(dead_code)]
197+
// Line 5: async fn main() { ← tree-sitter StartLine
196198
//
197199
// gap = 5 - 2 = 3 ≤ maxGap(3) → 바인딩 성공
198200
func TestBinder_RustAttributeGap_BindsWithinMaxGap(t *testing.T) {
@@ -226,10 +228,11 @@ func TestBinder_RustAttributeGap_BindsWithinMaxGap(t *testing.T) {
226228
// 바인딩이 성공함을 검증합니다.
227229
//
228230
// fixture (attribute_gap.c) 기준:
229-
// Line 1-3: /** ... */ Doxygen
230-
// Line 4: __attribute__((always_inline))
231-
// Line 5: __attribute__((nonnull))
232-
// Line 6: static inline int add(int a, int b) { ← tree-sitter StartLine 예상
231+
//
232+
// Line 1-3: /** ... */ Doxygen
233+
// Line 4: __attribute__((always_inline))
234+
// Line 5: __attribute__((nonnull))
235+
// Line 6: static inline int add(int a, int b) { ← tree-sitter StartLine 예상
233236
//
234237
// gap = 6 - 3 = 3 ≤ maxGap(3) → 바인딩 성공
235238
func TestBinder_CAttributeGap_BindsWithinMaxGap(t *testing.T) {
@@ -292,7 +295,6 @@ func TestBinder_GapWithCodeBetween_NoBinding(t *testing.T) {
292295
}
293296
}
294297

295-
296298
// =============================================================================
297299
// Look-Between 동적 바인딩 테스트
298300
// =============================================================================
@@ -320,10 +322,10 @@ func TestBinder_LookBetween_BlankLinesOnly_Binds(t *testing.T) {
320322
}
321323
sourceLines := []string{
322324
"// @intent 빈 줄 사이 바인딩", // line 1
323-
"", // line 2
324-
"", // line 3
325-
"", // line 4
326-
"func MyFunc() {", // line 5
325+
"", // line 2
326+
"", // line 3
327+
"", // line 4
328+
"func MyFunc() {", // line 5
327329
}
328330

329331
bindings := b.Bind(comments, nodes, "go", sourceLines)
@@ -357,8 +359,8 @@ func TestBinder_LookBetween_CodeBetween_NoBinding(t *testing.T) {
357359
}
358360
sourceLines := []string{
359361
"// @intent 이 주석은 바인딩 안 됨", // line 1
360-
"var x = 42", // line 2 - 코드!
361-
"func MyFunc() {", // line 3
362+
"var x = 42", // line 2 - 코드!
363+
"func MyFunc() {", // line 3
362364
}
363365

364366
bindings := b.Bind(comments, nodes, "go", sourceLines)
@@ -395,8 +397,8 @@ func TestBinder_LookBetween_Adjacent_Gap1_Binds(t *testing.T) {
395397
}
396398
sourceLines := []string{
397399
"// @intent 인접 바인딩", // line 1
398-
"// (continued)", // line 2
399-
"func MyFunc() {", // line 3
400+
"// (continued)", // line 2
401+
"func MyFunc() {", // line 3
400402
}
401403

402404
bindings := b.Bind(comments, nodes, "go", sourceLines)
@@ -439,9 +441,9 @@ func TestBinder_LookBetween_WhitespaceOnlyLines_Binds(t *testing.T) {
439441
}
440442
sourceLines := []string{
441443
"// @intent 공백문자만 있는 줄", // line 1
442-
" ", // line 2 - spaces only
443-
"\t\t", // line 3 - tabs only
444-
"func MyFunc() {", // line 4
444+
" ", // line 2 - spaces only
445+
"\t\t", // line 3 - tabs only
446+
"func MyFunc() {", // line 4
445447
}
446448

447449
bindings := b.Bind(comments, nodes, "go", sourceLines)
@@ -477,9 +479,9 @@ func TestBinder_Passthrough_PythonDecorators_Binds(t *testing.T) {
477479
}
478480
sourceLines := []string{
479481
"# @intent 사용자 조회 엔드포인트", // line 1
480-
"@app.route('/api/user')", // line 2 - decorator
481-
"@login_required", // line 3 - decorator
482-
"def get_user():", // line 4
482+
"@app.route('/api/user')", // line 2 - decorator
483+
"@login_required", // line 3 - decorator
484+
"def get_user():", // line 4
483485
}
484486

485487
bindings := b.Bind(comments, nodes, "python", sourceLines)
@@ -511,13 +513,13 @@ func TestBinder_Passthrough_JavaAnnotations_Binds(t *testing.T) {
511513
{Name: "UserService", Kind: model.NodeKindClass, StartLine: 7, EndLine: 20},
512514
}
513515
sourceLines := []string{
514-
"/**", // line 1
515-
" * @intent 사용자 서비스", // line 2
516-
" */", // line 3
517-
"@Service", // line 4 - annotation
518-
"@Transactional", // line 5 - annotation
519-
"@RequiredArgsConstructor", // line 6 - annotation
520-
"public class UserService {", // line 7
516+
"/**", // line 1
517+
" * @intent 사용자 서비스", // line 2
518+
" */", // line 3
519+
"@Service", // line 4 - annotation
520+
"@Transactional", // line 5 - annotation
521+
"@RequiredArgsConstructor", // line 6 - annotation
522+
"public class UserService {", // line 7
521523
}
522524

523525
bindings := b.Bind(comments, nodes, "java", sourceLines)
@@ -549,11 +551,11 @@ func TestBinder_Passthrough_RustAttributes_Binds(t *testing.T) {
549551
{Name: "main", Kind: model.NodeKindFunction, StartLine: 5, EndLine: 10},
550552
}
551553
sourceLines := []string{
552-
"/// @intent 비동기 main 진입점", // line 1
553-
"/// @sideEffect 런타임 초기화", // line 2
554-
"#[tokio::main]", // line 3 - Rust attribute
555-
"#[allow(dead_code)]", // line 4 - Rust attribute
556-
"async fn main() {", // line 5
554+
"/// @intent 비동기 main 진입점", // line 1
555+
"/// @sideEffect 런타임 초기화", // line 2
556+
"#[tokio::main]", // line 3 - Rust attribute
557+
"#[allow(dead_code)]", // line 4 - Rust attribute
558+
"async fn main() {", // line 5
557559
}
558560

559561
bindings := b.Bind(comments, nodes, "rust", sourceLines)
@@ -584,12 +586,12 @@ func TestBinder_Passthrough_CAttributes_Binds(t *testing.T) {
584586
{Name: "add", Kind: model.NodeKindFunction, StartLine: 6, EndLine: 10},
585587
}
586588
sourceLines := []string{
587-
"/**", // line 1
588-
" * @intent 항상 인라인되는 덧셈", // line 2
589-
" */", // line 3
590-
"__attribute__((always_inline))", // line 4 - C attribute
591-
"[[nodiscard]]", // line 5 - C++17 attribute
592-
"static inline int add(int a, int b) {", // line 6
589+
"/**", // line 1
590+
" * @intent 항상 인라인되는 덧셈", // line 2
591+
" */", // line 3
592+
"__attribute__((always_inline))", // line 4 - C attribute
593+
"[[nodiscard]]", // line 5 - C++17 attribute
594+
"static inline int add(int a, int b) {", // line 6
593595
}
594596

595597
bindings := b.Bind(comments, nodes, "c", sourceLines)
@@ -620,10 +622,10 @@ func TestBinder_Passthrough_OtherComments_Binds(t *testing.T) {
620622
{Name: "MyFunc", Kind: model.NodeKindFunction, StartLine: 4, EndLine: 10},
621623
}
622624
sourceLines := []string{
623-
"// @intent 주석 사이 바인딩", // line 1
624-
"// TODO: 나중에 리팩토링", // line 2 - comment
625+
"// @intent 주석 사이 바인딩", // line 1
626+
"// TODO: 나중에 리팩토링", // line 2 - comment
625627
"// NOTE: 이 함수는 deprecated 예정", // line 3 - comment
626-
"func MyFunc() {", // line 4
628+
"func MyFunc() {", // line 4
627629
}
628630

629631
bindings := b.Bind(comments, nodes, "go", sourceLines)
@@ -657,11 +659,11 @@ func TestBinder_Passthrough_Mixed_Binds(t *testing.T) {
657659
}
658660
sourceLines := []string{
659661
"# @intent 혼합 passthrough 테스트", // line 1
660-
"# type: ignore", // line 2 - comment
661-
"", // line 3 - blank
662-
"@app.route('/test')", // line 4 - decorator
663-
"@requires_auth", // line 5 - decorator
664-
"def handler():", // line 6
662+
"# type: ignore", // line 2 - comment
663+
"", // line 3 - blank
664+
"@app.route('/test')", // line 4 - decorator
665+
"@requires_auth", // line 5 - decorator
666+
"def handler():", // line 6
665667
}
666668

667669
bindings := b.Bind(comments, nodes, "python", sourceLines)
@@ -693,9 +695,9 @@ func TestBinder_Passthrough_DecoratorPlusCode_NoBinding(t *testing.T) {
693695
}
694696
sourceLines := []string{
695697
"# @intent 이건 바인딩 안 됨", // line 1
696-
"@decorator", // line 2 - decorator (passthrough)
697-
"x = 42", // line 3 - actual code!
698-
"def handler():", // line 4
698+
"@decorator", // line 2 - decorator (passthrough)
699+
"x = 42", // line 3 - actual code!
700+
"def handler():", // line 4
699701
}
700702

701703
bindings := b.Bind(comments, nodes, "python", sourceLines)

internal/parse/treesitter/binding_gap_cross_language_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// 테스트 정책:
1010
// - expectBound=true → Green 계약. 정상 바인딩되어야 하며, 실패 시 회귀(normalizer/walker/binder).
1111
// - expectBound=false → Red 계약. 현재 tree-sitter grammar 특성으로 바인딩이 누락됨을
12-
// "명시적으로" 고정. 구현이 개선되어 우연히 바인딩되면 테스트가 실패하므로
13-
// 그때 Green으로 승격하고 skipReason과 walker 보정을 함께 정리한다.
12+
// "명시적으로" 고정. 구현이 개선되어 우연히 바인딩되면 테스트가 실패하므로
13+
// 그때 Green으로 승격하고 skipReason과 walker 보정을 함께 정리한다.
1414
//
1515
// Helper 함수:
1616
// - binderFromWalkerComments, logNodeInfo, logCommentInfo 는
@@ -338,10 +338,10 @@ data class User(val name: String)
338338
}
339339

340340
// Phase 2: 바인딩 시도.
341-
binder := parse.NewBinder()
342-
bindings := binder.Bind(
343-
binderFromWalkerComments(walkerComments), nodes, tc.spec.Name, strings.Split(tc.source, "\n"),
344-
)
341+
binder := parse.NewBinder()
342+
bindings := binder.Bind(
343+
binderFromWalkerComments(walkerComments), nodes, tc.spec.Name, strings.Split(tc.source, "\n"),
344+
)
345345

346346
var target *parse.Binding
347347
for i := range bindings {

internal/parse/treesitter/binding_gap_go_directives_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func TestWalkerBinder_Go_DirectivePollution(t *testing.T) {
6868
t.Log("--- 파싱된 CommentBlock ---")
6969
logCommentInfo(t, walkerComments)
7070

71-
b := parse.NewBinder()
72-
bindings := b.Bind(binderFromWalkerComments(walkerComments), nodes, "go", strings.Split(string(content), "\n"))
71+
b := parse.NewBinder()
72+
bindings := b.Bind(binderFromWalkerComments(walkerComments), nodes, "go", strings.Split(string(content), "\n"))
7373

7474
var intentValue string
7575
var bound bool

internal/parse/treesitter/binding_gap_integration_test.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// 여러 줄 붙어 있으면 @intent docstring/주석이 심볼 노드에 바인딩되지 않는다.
55
//
66
// 이 파일의 테스트는 각 언어별로:
7-
// 1. 실제 tree-sitter로 fixture를 파싱
8-
// 2. 심볼 노드의 실제 StartLine을 t.Logf로 출력
9-
// 3. Binder.Bind 결과를 검증하여 현재 실패 동작을 명시적으로 기록
7+
// 1. 실제 tree-sitter로 fixture를 파싱
8+
// 2. 심볼 노드의 실제 StartLine을 t.Logf로 출력
9+
// 3. Binder.Bind 결과를 검증하여 현재 실패 동작을 명시적으로 기록
1010
//
1111
// 테스트 이름에 _CurrentlyFailsBinding 접미사를 붙여 현재 상태를 명시합니다.
1212
package treesitter
@@ -421,15 +421,17 @@ func TestWalkerBinder_CAttribute_CurrentlyFailsBinding(t *testing.T) {
421421
// # 라인 주석 + 데코레이터 2개 시나리오로 바인딩 실패를 검증합니다.
422422
//
423423
// fixture (decorator_gap_comment.py) 기준:
424-
// Line 1: # @intent 사용자 조회 엔드포인트
425-
// Line 2: # @domainRule 인증 필요
426-
// Line 3: @app.route('/api/user')
427-
// Line 4: @login_required
428-
// Line 5: def get_user(): ← tree-sitter StartLine
424+
//
425+
// Line 1: # @intent 사용자 조회 엔드포인트
426+
// Line 2: # @domainRule 인증 필요
427+
// Line 3: @app.route('/api/user')
428+
// Line 4: @login_required
429+
// Line 5: def get_user(): ← tree-sitter StartLine
429430
//
430431
// 주석EndLine=2, get_user StartLine=5, gap=3 > maxGap(2) → 바인딩 실패 예상
431432
// (단, Python이 decorated_definition으로 StartLine을 데코레이터 첫 줄=3으로 잡으면
432-
// gap=3-2=1이 되어 바인딩 성공 가능성도 있음)
433+
//
434+
// gap=3-2=1이 되어 바인딩 성공 가능성도 있음)
433435
func TestWalkerBinder_PythonDecoratorHashComment_CurrentlyFailsBinding(t *testing.T) {
434436
content := readFixture(t, "python", "decorator_gap_comment.py")
435437
t.Logf("fixture 내용:\n%s", string(content))
@@ -517,11 +519,11 @@ func TestWalkerBinder_PythonDecoratorHashComment_CurrentlyFailsBinding(t *testin
517519
// 이 테스트는 항상 통과하며, 진단 데이터만 수집합니다.
518520
func TestWalkerBinder_GapDiagnosis_AllLanguages(t *testing.T) {
519521
type langCase struct {
520-
spec *LangSpec
521-
lang string
522-
filename string
523-
symName string
524-
symKind model.NodeKind
522+
spec *LangSpec
523+
lang string
524+
filename string
525+
symName string
526+
symKind model.NodeKind
525527
fixtureExt string
526528
}
527529

0 commit comments

Comments
 (0)