Skip to content

feat(golang): Go function and method declaration parsing (PR-03)#522

Merged
shivasurya merged 1 commit into
mainfrom
shiva/golang-pr03-declarations
Feb 15, 2026
Merged

feat(golang): Go function and method declaration parsing (PR-03)#522
shivasurya merged 1 commit into
mainfrom
shiva/golang-pr03-declarations

Conversation

@shivasurya
Copy link
Copy Markdown
Owner

Summary

  • Parse Go function declarations, method declarations, and init() into CodeGraph nodes
  • Set Modifier (public/private) based on Go export rules (uppercase = public)
  • Return function Node as currentContext for child call node linking
  • Add FunctionInfo/MethodInfo structs in golang package (avoids circular dependency)
  • Resolves PR-02 lint failures: setGoSourceLocation and isGoSourceFile now used

Test plan

  • func Foo(a, b int) string {} → correct Node with params, return type, Modifier="public"
  • func foo() {} → Node{Modifier: "private"}
  • func init() {} → Node{Type: "init_function"}
  • func Printf(format string, args ...interface{}) {} → variadic params handled
  • func Read(p []byte) (int, error) {} → multiple return types
  • func (s *Server) Start() error {} → Node{Type: "method", Interface: ["S"]}
  • func (s Server) String() string {} → value receiver, same result
  • func (s *S) stop() {} → Node{Modifier: "private"}
  • Java method_declaration regression: still works with isJavaSourceFile guard
  • go build ./... compiles without errors
  • go test ./graph/golang/... — 100% coverage on declarations.go
  • go test ./graph/... — no regressions
  • go vet ./... reports zero findings

🤖 Generated with Claude Code

@shivasurya shivasurya added the enhancement New feature or request label Feb 14, 2026
@shivasurya shivasurya self-assigned this Feb 14, 2026
@shivasurya shivasurya added the enhancement New feature or request label Feb 14, 2026
@safedep
Copy link
Copy Markdown

safedep Bot commented Feb 14, 2026

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

This report is generated by SafeDep Github App

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 14, 2026

Codecov Report

❌ Patch coverage is 97.46835% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.93%. Comparing base (c19850d) to head (e4d94c8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sast-engine/graph/parser_golang.go 94.73% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #522      +/-   ##
==========================================
+ Coverage   82.83%   82.93%   +0.09%     
==========================================
  Files         124      125       +1     
  Lines       14462    14540      +78     
==========================================
+ Hits        11980    12059      +79     
+ Misses       2030     2027       -3     
- Partials      452      454       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shivasurya shivasurya changed the title feat: Go function and method declaration parsing feat(golang): Go function and method declaration parsing (PR-03) Feb 14, 2026
Copy link
Copy Markdown
Owner Author

shivasurya commented Feb 15, 2026

Merge activity

  • Feb 15, 4:00 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 15, 4:03 AM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 15, 4:04 AM UTC: @shivasurya merged this pull request with Graphite.

@shivasurya shivasurya changed the base branch from shiva/golang-pr02-helpers-scaffold to graphite-base/522 February 15, 2026 04:01
@shivasurya shivasurya changed the base branch from graphite-base/522 to main February 15, 2026 04:02
Parse Go function declarations, method declarations (with receivers), and
init() functions into CodeGraph nodes. These are the primary symbols that
the call graph builder indexes.

New golang package types:
- FunctionInfo: holds name, params, return type, visibility, init flag
- MethodInfo: embeds FunctionInfo + receiver type (pointer stripped)

Dispatcher functions in parser_golang.go:
- parseGoFunctionDeclaration: creates function_declaration or init_function nodes
- parseGoMethodDeclaration: creates method nodes with Interface=[receiverType]

Both set SourceLocation, Modifier (public/private), and isGoSourceFile on
every node. Resolves PR-02 lint failures (setGoSourceLocation and
isGoSourceFile now used).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@shivasurya shivasurya force-pushed the shiva/golang-pr03-declarations branch from 2e1dc04 to e4d94c8 Compare February 15, 2026 04:03
@github-actions
Copy link
Copy Markdown

Code Pathfinder Security Scan

Pass Critical High Medium Low Info

No security issues detected.

Metric Value
Files Scanned 4
Rules 38

Powered by Code Pathfinder

@shivasurya shivasurya merged commit b2882ff into main Feb 15, 2026
5 checks passed
@shivasurya shivasurya deleted the shiva/golang-pr03-declarations branch February 15, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant