1,070 matches across 25 files for func main lang:Go lang:Go lang:Go lang:Go lang:Go lang:Go
snippet_mode: auto · sorted by relevance
processor/workers.go GO 34 matches · showing 5 view file →
73// reset, every file in the second call matches a hash recorded by the first and
74// the whole result comes back empty.
75func cleanDuplicates() {
76 duplicates.Clear()
77}
· · ·
78
79func checkForMatchSingle(currentByte byte, index int, endPoint int, matches []byte, fileJob *FileJob) bool {
80 potentialMatch := true
81 if currentByte == matches[0] {
· · ·
95}
96
97func isWhitespace(currentByte byte) bool {
98 if currentByte != ' ' && currentByte != '\t' && currentByte != '\n' && currentByte != '\r' {
99 return false
· · ·
103}
104
105func isIdentifierContinue(b byte) bool {
106 return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b >= '0' && b <= '9') || b == '_'
107}
· · ·
108
109func hasNonWhitespaceBefore(content []byte, index int) bool {
110 for i := index - 1; i >= 0; i-- {
111 if !isWhitespace(content[i]) {
+ 29 more matches in this file
processor/history_authors.go GO 27 matches · showing 5 view file →
18
19// authorsTopN is the cap on tabular rows for the author rollup. CSV/JSON
20// output is not capped. The remainder collapses into a single "others (N)"
21// row in the tabular table.
22const authorsTopN = 15
· · ·
77}
78
79func newHistoryAuthorsObserver() *historyAuthorsObserver {
80 return &historyAuthorsObserver{
81 blame: map[string][]authorID{},
· · ·
90// baseline snapshot — every pre-window line maps to sentinelAuthorID so
91// surviving untouched lines are correctly attributed to "(before window)".
92func (o *historyAuthorsObserver) Seed(baseline BaselineSnapshot) {
93 o.registry = newAuthorRegistry(baseline.Mailmap)
94 for path, bf := range baseline.Files {
· · ·
103}
104
105func (o *historyAuthorsObserver) Observe(c CommitInfo, changes []FileChange) {
106 aid := o.registry.intern(c.Author, c.Email)
107 if prev, ok := o.lastSeen[aid]; !ok || c.When.After(prev) {
· · ·
131}
132
133func (o *historyAuthorsObserver) Finalise(window HistoryWindow, head HeadSnapshot) {
134 o.window = window
135 o.snapshot = head
+ 22 more matches in this file
processor/history_blame.go GO 21 matches · showing 5 view file →
30// name+email so two commit identities mapped to the same canonical pair
31// collapse to one authorID. When fold is true, a second index folds
32// distinct emails that share the same (lowercase name, email domain) — a
33// best-effort fallback for repos without a .mailmap.
34type authorRegistry struct {
· · ·
35 nameToID map[string]authorID
36 byNameDomain map[string]authorID
37 records []authorRecord
38 mm *mailmap
· · ·
40}
41
42func newAuthorRegistry(mm *mailmap) *authorRegistry {
43 return newAuthorRegistryWithFold(mm, FoldAuthors)
44}
· · ·
45
46func newAuthorRegistryWithFold(mm *mailmap, fold bool) *authorRegistry {
47 return &authorRegistry{
48 nameToID: map[string]authorID{},
· · ·
49 byNameDomain: map[string]authorID{},
50 records: []authorRecord{{}}, // slot 0 = sentinelAuthorID
51 mm: mm,
+ 16 more matches in this file
processor/report_render.go GO 52 matches · showing 5 view file →
34// first use so a normal scc invocation pays nothing for the report path. The
35// returned root template has both "report" and "card" defined.
36func reportTemplate() *template.Template {
37 reportTmplOnce.Do(func() {
38 root := template.New("report").Funcs(reportFuncs)
· · ·
37 reportTmplOnce.Do(func() {
38 root := template.New("report").Funcs(reportFuncs)
39 reportTmpl = template.Must(root.Parse(reportTemplateSrc))
· · ·
38 root := template.New("report").Funcs(reportFuncs)
39 reportTmpl = template.Must(root.Parse(reportTemplateSrc))
40 template.Must(reportTmpl.New("card").Parse(reportCardSrc))
· · ·
49// that future template helpers can surface "you asked for X but it's not a
50// real section" hints without re-parsing.
51func parseReportSkip(raw string) {
52 parseReportSkipTo(raw, os.Stderr)
53}
· · ·
56// destination is plumbed through so unit tests can capture stderr output
57// without resorting to os.Stderr redirection.
58func parseReportSkipTo(raw string, warnW io.Writer) {
59 ReportSkipNames = map[string]bool{}
60 if strings.TrimSpace(raw) == "" {
+ 47 more matches in this file
processor/processor.go GO 27 matches · showing 5 view file →
174}
175
176func parseRemapRules(value string) []remapRule {
177 rules := []remapRule{}
178
· · ·
190}
191
192func newRemapConfig(remapAll string, remapUnknown string) remapConfig {
193 c := remapConfig{
194 all: parseRemapRules(remapAll),
· · ·
200 // guarantees that language was ever loaded — CountStats would then find no
201 // features and count the file as plain text, with no comments and no
202 // complexity. Done once here at setup rather than in the remap functions
203 // themselves, which run per file on the hot path.
204 for _, rule := range c.all {
· · ·
382
383// HistoryBuckets is the time-bucket resolution for the timeline reports.
384// Wired to --buckets in main.go; default 60.
385var HistoryBuckets = 60
386
· · ·
387// FoldAuthors enables the name+domain identity folding fallback applied
388// after the mailmap. Toggled off via --no-fold-authors.
389var FoldAuthors = true
+ 22 more matches in this file
processor/report.go GO 27 matches · showing 5 view file →
20
21// DefaultReportName is the file name used when --report is invoked without
22// a path (pflag's NoOptDefVal). main.go wires this in as the bare-flag
23// default; runReport compares ReportOut to it to decide whether the user
24// supplied an explicit path or relied on the default.
· · ·
35
36// ReportSkipNames is the parsed, lower-cased set of section names supplied
37// via --report-skip. Wired from main.go (spec 05). CollectReportData reads
38// this through ReportSkipped to decide which *Result pointers to nil out
39// before returning.
· · ·
64// --report-skip. Section names are case-insensitive — callers can pass
65// either case.
66func ReportSkipped(section string) bool {
67 if len(ReportSkipNames) == 0 {
68 return false
· · ·
265
266 // Rendered share-card SVG (data: URL safe). Populated by RenderReport
267 // before the main template runs so it can be embedded as og:image.
268 CardSVG template.HTML
269}
· · ·
283}
284
285func saveReportFlags() reportFlagState {
286 return reportFlagState{
287 UlocMode: UlocMode,
+ 22 more matches in this file
processor/history_ignore.go GO 8 matches · showing 5 view file →
24}
25
26func (h *historyIgnore) Match(p string, isDir bool) bool {
27 if h == nil || h.matcher == nil {
28 return false
· · ·
35// parses them, and produces a matcher. Respects the existing --no-ignore
36// (Ignore) and --no-scc-ignore (SccIgnore) flag globals.
37func buildHistoryIgnore(repo *git.Repository, head plumbing.Hash) (*historyIgnore, error) {
38 commit, err := repo.CommitObject(head)
39 if err != nil {
· · ·
46
47 var patterns []gitignore.Pattern
48 err = tree.Files().ForEach(func(f *object.File) error {
49 if f.Mode == filemode.Dir || f.Mode == filemode.Submodule || f.Mode == filemode.Symlink {
50 return nil
· · ·
65 defer reader.Close()
66
67 domain := splitDomain(path.Dir(f.Name))
68 patterns = append(patterns, parseIgnoreFile(reader, domain)...)
69 return nil
· · ·
68 patterns = append(patterns, parseIgnoreFile(reader, domain)...)
69 return nil
70 })
+ 3 more matches in this file
processor/history_render.go GO 12 matches · showing 5 view file →
17// historyHeader renders the centred two-line "<break> <name> · last N
18// commits · from → to <break>" block that every tabular report uses.
19func historyHeader(reportName string, w HistoryWindow, wide bool) string {
20 break_ := tabularBreakFor(wide)
21 var sb strings.Builder
· · ·
27}
28
29func formatHeaderLine(reportName string, w HistoryWindow) string {
30 if w.Commits == 0 {
31 return reportName + " · no commits"
· · ·
39// produce, honouring --no-hborder and --ci. Centralised here so every
40// history renderer agrees with the language tables.
41func tabularBreakFor(wide bool) string {
42 if wide {
43 return getTabularWideBreak()
· · ·
49// Falls back to ASCII '#' when --ci is on or output is not a TTY (CSV-safe
50// callers should not use this helper).
51func renderBar(ratio float64, width int) string {
52 if width <= 0 {
53 return ""
· · ·
69 total := ratio * float64(width)
70 full := int(total)
71 remainder := total - float64(full)
72 var sb strings.Builder
73 for i := 0; i < full; i++ {
+ 7 more matches in this file
processor/history.go GO 32 matches · showing 5 view file →
20
21// HistoryDepth is the maximum number of commits the history engine walks. 0
22// means "entire history". Wired to --depth in main.go.
23var HistoryDepth = 1000
24
· · ·
142// pass user input unchecked. A degenerate window (from == to or to before
143// from) yields Width=0; all commits land in bucket 0 / N-1.
144func NewBucketing(from, to time.Time, n int) Bucketing {
145 if n <= 0 {
146 n = 1
· · ·
156// clamp to 0 (defensive — should not happen given the walk window). Times at
157// or after To clamp to N-1.
158func (b Bucketing) Index(t time.Time) int {
159 if b.N <= 0 {
160 return 0
· · ·
181// Start returns the wall-clock start time of bucket i. Indexes outside
182// [0, N) are clamped.
183func (b Bucketing) Start(i int) time.Time {
184 if b.N <= 0 {
185 return b.From
· · ·
195
196// emptySnapshot is what observers see when HEAD is missing or empty.
197func emptySnapshot() HeadSnapshot {
198 return HeadSnapshot{Files: map[string]HeadFile{}}
199}
+ 27 more matches in this file
scripts/include.go GO 9 matches · showing 5 view file →
1// SPDX-License-Identifier: MIT
2
3package main
4
5import (
· · ·
36// compiled into this binary, which is the *old* constants.go (compiled before
37// this run rewrote it), so LANGUAGES.md always lagged the JSON by one pass.
38func loadLanguages() (map[string]processor.Language, error) {
39 files, _ := os.ReadDir(".")
40 langs := map[string]processor.Language{}
· · ·
74
75// encodes the language database as string literals in constants.go
76func generateConstants(langs map[string]processor.Language) error {
77 buf := &bytes.Buffer{}
78
· · ·
79 t, err := template.New("codeGenerator").Funcs(template.FuncMap{
80 "quote": strconv.Quote,
81 }).Parse(langTemplate)
· · ·
97 return fmt.Errorf("failed to open constants file: %v", err)
98 }
99 defer func(file *os.File) {
100 _ = file.Close()
101 }(out)
+ 4 more matches in this file
processor/history_coupling.go GO 35 matches · showing 5 view file →
69// 100%; multiplied by high test-file complexity that buries the real work.
70// Volume keeps the heavyweight couplings on top and matches --hotspots.
71func (c CouplingCount) WeightedScore() float64 {
72 return float64(c.Shared) * float64(min(c.ComplexityA, c.ComplexityB))
73}
· · ·
76// co-change first, then degree, then path. Shared by the raw sort and used as
77// the tiebreak under weighted ranking.
78func lessCouplingRaw(a, b CouplingCount) bool {
79 if a.Shared != b.Shared {
80 return a.Shared > b.Shared
· · ·
92// when the Cognitive global is on (matching --hotspots), cyclomatic otherwise.
93// A path absent from HEAD contributes zero, so it can never lift a pair's score.
94func headComplexity(head HeadSnapshot, path string) int64 {
95 hf, ok := head.Files[path]
96 if !ok {
· · ·
107// for the human-facing table only; the raw counts sit beside it so the number
108// is never a black box. Returns 0 when the union is empty.
109func (c CouplingCount) Degree() float64 {
110 union := c.CommitsA + c.CommitsB - c.Shared
111 if union <= 0 {
· · ·
141type pairKey struct{ a, b string }
142
143func newCouplingObserver() *couplingObserver {
144 return &couplingObserver{
145 maxFilesPerCommit: CouplingMaxFilesPerCommit,
+ 30 more matches in this file
mcp.go GO 16 matches · showing 5 view file →
1// SPDX-License-Identifier: MIT
2
3package main
4
5import (
· · ·
24var mcpMu sync.Mutex
25
26func startMCPServer() {
27 mcpServer := server.NewMCPServer(
28 "scc",
· · ·
218}
219
220func mcpAnalyzeHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
221 args := request.GetArguments()
222
· · ·
430}
431
432func mcpHotspotsHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
433 args := request.GetArguments()
434
· · ·
487}
488
489func mcpCouplingHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
490 args := request.GetArguments()
491
+ 11 more matches in this file
config.go GO 35 matches · showing 5 view file →
1// SPDX-License-Identifier: MIT
2
3package main
4
5import (
· · ·
22// the user-facing `completion` command. These must reach cobra with the genuine
23// argv, so config discovery is skipped for them.
24func isCompletionInvocation(args []string) bool {
25 if len(args) < 2 {
26 return false
· · ·
69// config file from injecting count targets. When true (@file) positional lines
70// are kept, preserving the existing @file behaviour.
71func parseConfigArgs(content string, allowPositional bool) []string {
72 var args []string
73
· · ·
116// quote-aware tokens, stripping an unquoted trailing '#' comment. Backslash is
117// a literal outside quotes.
118func tokenizeConfigLine(line string) []string {
119 var tokens []string
120 var sb strings.Builder
· · ·
122 inToken := false
123
124 flush := func() {
125 if inToken {
126 tokens = append(tokens, sb.String())
+ 30 more matches in this file
cmd/badges/main.go GO 25 matches · showing 5 view file →
1package main
2
3import (
· · ·
38)
39
40func intPtr(i int) *int {
41 return &i
42}
· · ·
43
44func timePtr(t time.Duration) *time.Duration {
45 return &t
46}
· · ·
47
48func main() {
49 http.HandleFunc("/health-check/", func(w http.ResponseWriter, r *http.Request) {
50 locationLogMutex.Lock()
· · ·
49 http.HandleFunc("/health-check/", func(w http.ResponseWriter, r *http.Request) {
50 locationLogMutex.Lock()
51 for k, v := range locationTracker {
+ 20 more matches in this file
main.go GO 7 matches · showing 5 view file →
1// SPDX-License-Identifier: MIT
2
3package main
4
5import (
· · ·
15)
16
17func printShellCompletion(cmd *cobra.Command, command string) error {
18 switch command {
19 case "bash":
· · ·
30}
31
32func printFlagSuggestion(flagSet *pflag.FlagSet, unknownFlag string) {
33 flags := processor.GetMostSimilarFlags(flagSet, unknownFlag)
34 if len(flags) == 0 {
· · ·
48
49//go:generate go run scripts/include.go
50func main() {
51 // f, _ := os.Create("scc.pprof")
52 // pprof.StartCPUProfile(f)
· · ·
56 // the bare boolean form and the explicit --mcp=true form pflag accepts, so the
57 // server starts consistently however the flag is spelled.
58 if slices.ContainsFunc(os.Args[1:], func(a string) bool {
59 return a == "--mcp" || a == "--mcp=true"
60 }) {
+ 2 more matches in this file
processor/trace.go GO 17 matches · showing 5 view file →
17)
18
19func (tl traceLevel) String() string {
20 switch tl {
21 case levelTrace:
· · ·
33
34// Get the time as standard UTC/Zulu format
35func getFormattedTime() string {
36 return time.Now().UTC().Format(time.RFC3339)
37}
· · ·
38
39func prepareMsg(template string, args []any) string {
40 if len(args) == 0 {
41 return template
· · ·
45}
46
47func doPrint(dst io.Writer, level traceLevel, template string, args []any) {
48 _, _ = fmt.Fprintf(dst, "%s %s: %s\n", level, getFormattedTime(), prepareMsg(template, args))
49}
· · ·
50
51// Prints a message to stdout if flag to enable warning output is set
52func printWarn(msg string) {
53 if Verbose {
54 doPrint(os.Stdout, levelWarn, msg, nil)
+ 12 more matches in this file
processor/report_test.go GO 60 matches · showing 5 view file →
14)
15
16func writeTestFile(path, content string) error {
17 return os.WriteFile(path, []byte(content), 0o644)
18}
· · ·
22// happy path of the spec: GitAvailable=true, all four git pointers non-nil,
23// per-file table and cost results present.
24func TestCollectReportDataOnFixtureRepo(t *testing.T) {
25 ProcessConstants()
26
· · ·
27 dir := makeFixtureRepo(t, []map[string]string{
28 {"a.go": "package a\n\nfunc A() {}\n"},
29 {"a.go": "package a\n\nfunc A() {}\n\nfunc B() {}\n", "b.go": "package a\n\nfunc C() {}\n"},
30 {"a.go": "package a\n\nfunc A() {}\n\nfunc B() {}\n\nfunc D() {}\n"},
· · ·
29 {"a.go": "package a\n\nfunc A() {}\n\nfunc B() {}\n", "b.go": "package a\n\nfunc C() {}\n"},
30 {"a.go": "package a\n\nfunc A() {}\n\nfunc B() {}\n\nfunc D() {}\n"},
31 })
· · ·
30 {"a.go": "package a\n\nfunc A() {}\n\nfunc B() {}\n\nfunc D() {}\n"},
31 })
32
+ 55 more matches in this file
config_test.go GO 49 matches · showing 5 view file →
1// SPDX-License-Identifier: MIT
2
3package main
4
5import (
· · ·
22// runSCCDir runs the test binary as scc in the given working directory, with
23// optional extra environment entries (KEY=VALUE).
24func runSCCDir(t *testing.T, dir string, env []string, args ...string) (string, error) {
25 t.Helper()
26 bin, err := filepath.Abs(sccBinPath)
· · ·
38}
39
40func TestParseConfigArgs(t *testing.T) {
41 t.Parallel()
42 tests := []struct {
· · ·
129
130 for _, tc := range tests {
131 t.Run(tc.name, func(t *testing.T) {
132 got := parseConfigArgs(tc.content, tc.allowPositional)
133 if !slices.Equal(got, tc.want) {
· · ·
138}
139
140func TestPreScanConfig(t *testing.T) {
141 t.Parallel()
142 tests := []struct {
+ 44 more matches in this file
regression_test.go GO 45 matches · showing 5 view file →
1// SPDX-License-Identifier: MIT
2
3package main
4
5import (
· · ·
18// The tests in this file guard against regressions to pre-existing behaviour
19// introduced by the config-dotfile work (spec/01-config-dotfile). They focus on
20// functionality that existed before the feature and could have been silently
21// changed by the registerFlags refactor, the shared @file tokenizer and the
22// config discovery/merge pipeline - cases the feature's own tests do not cover.
· · ·
31// union must keep the defaults as a non-removable safety net. .svn is the canary:
32// nothing else skips it, so if preservation breaks it reappears in the output.
33func TestRegressionExcludeDirPreservesDefaults(t *testing.T) {
34 dir := t.TempDir()
35 layout := map[string]string{".svn": "x.go", "vendor": "y.go", "keep": "z.go"}
· · ·
62// lockfile defaults. package-lock.json is the canary - before the fix pflag's
63// replace-on-first-Set would have let it through.
64func TestRegressionExcludeFilePreservesDefaults(t *testing.T) {
65 dir := t.TempDir()
66 files := map[string]string{
· · ·
67 "main.go": "package main\n",
68 "package-lock.json": "{\"a\":1}\n",
69 "myignore.txt": "hello\n",
+ 40 more matches in this file
processor/workers_test.go GO 102 matches · showing 5 view file →
10)
11
12func (job *FileJob) SetContent(content string) {
13 job.Content = []byte(content)
14 job.Bytes = int64(len(job.Content))
· · ·
15}
16
17func TestIsWhitespace(t *testing.T) {
18 if !isWhitespace(' ') {
19 t.Errorf("Expected to be true")
· · ·
21}
22
23func TestIsBinaryTrue(t *testing.T) {
24 DisableCheckBinary = false
25
· · ·
29}
30
31func TestIsBinaryDisableCheck(t *testing.T) {
32 DisableCheckBinary = true
33
· · ·
37}
38
39func TestCountStatsLines(t *testing.T) {
40 Trace = false
41 Debug = false
+ 97 more matches in this file
processor/history_authors_test.go GO 60 matches · showing 5 view file →
28// using the caller's named author. Used to exercise per-author attribution
29// in the authors observer.
30func makeAuthoredRepo(t *testing.T, commits []authoredCommit) string {
31 t.Helper()
32 ProcessConstants()
· · ·
72// findAuthorRow returns the row whose canonical name matches `name`, or
73// fails the test.
74func findAuthorRow(t *testing.T, rows []authorRow, name string) authorRow {
75 t.Helper()
76 for _, r := range rows {
· · ·
83}
84
85func TestAuthorsLastToucherAttribution(t *testing.T) {
86 saveDepth := HistoryDepth
87 HistoryDepth = 100
· · ·
88 t.Cleanup(func() { HistoryDepth = saveDepth })
89
90 // Alice introduces 7 lines; Bob rewrites lines 4–7 (4 lines).
· · ·
91 // Net: Alice owns 3, Bob owns 4. No (before window) — full history walked.
92 first := "package x\nfunc A() {}\nfunc B() {}\nfunc C() {}\nfunc D() {}\nfunc E() {}\nfunc F() {}\n"
93 // 7 lines: line1=package, line2=A, line3=B, line4=C, line5=D, line6=E, line7=F.
94 // We want Bob to rewrite lines 4-7 (4 lines).
+ 55 more matches in this file
processor/history_blame_test.go GO 34 matches · showing 5 view file →
8)
9
10func TestApplyDiffToBlameNewFile(t *testing.T) {
11 got := applyDiffToBlame(nil, 3, []LineRange{{Start: 1, Count: 3}}, nil, 7)
12 want := []authorID{7, 7, 7}
· · ·
16}
17
18func TestApplyDiffToBlameAppend(t *testing.T) {
19 prev := []authorID{1, 1}
20 got := applyDiffToBlame(prev, 4, []LineRange{{Start: 3, Count: 2}}, nil, 9)
· · ·
25}
26
27func TestApplyDiffToBlamePureDelete(t *testing.T) {
28 prev := []authorID{1, 1, 1, 1}
29 got := applyDiffToBlame(prev, 2, nil, []LineRange{{Start: 2, Count: 2}}, 9)
· · ·
34}
35
36func TestApplyDiffToBlameReplaceMiddle(t *testing.T) {
37 // 5 lines from author 1; replace line 3 with two lines from author 2.
38 prev := []authorID{1, 1, 1, 1, 1}
· · ·
47}
48
49func TestApplyDiffToBlamePadsToNewLines(t *testing.T) {
50 // Diff arithmetic disagrees with newLines — defensive pad with sentinel.
51 got := applyDiffToBlame(nil, 4, nil, nil, 9)
+ 29 more matches in this file
processor/workers_cognitive_test.go GO 39 matches · showing 5 view file →
8// Cognitive global enabled and returns the resulting FileJob so callers can
9// assert on both Complexity and Cognitive.
10func countCognitive(t *testing.T, language, content string) FileJob {
11 t.Helper()
12 ProcessConstants()
· · ·
21// on, so callers can assert on the CognitiveLine array as well as the whole-file
22// tally.
23func countCognitiveLines(t *testing.T, language, content string) FileJob {
24 t.Helper()
25 ProcessConstants()
· · ·
31}
32
33func sumInt64(xs []int64) int64 {
34 var total int64
35 for _, x := range xs {
· · ·
41// The per-line array must total to the whole-file Cognitive value, for flat and
42// nested files alike.
43func TestCognitiveLineSumEqualsCognitive(t *testing.T) {
44 Cognitive = true
45 defer func() { Cognitive = false }()
· · ·
45 defer func() { Cognitive = false }()
46
47 cases := map[string]string{
+ 34 more matches in this file
processor/history_coupling_test.go GO 26 matches · showing 5 view file →
11
12// hasCandidate reports whether want is among the candidate forms.
13func hasCandidate(got []string, want string) bool {
14 for _, g := range got {
15 if g == want {
· · ·
23// the bare git path. This was the original --coupling-for bug: the prefix was
24// passed through and never matched, after a full history walk.
25func TestCouplingTargetCandidatesStripsDotSlash(t *testing.T) {
26 got := couplingTargetCandidates("/repo", "./processor/constants.go")
27 if !hasCandidate(got, "processor/constants.go") {
· · ·
30}
31
32func TestCouplingTargetCandidatesBarePathUnchanged(t *testing.T) {
33 got := couplingTargetCandidates("/repo", "processor/constants.go")
34 if !hasCandidate(got, "processor/constants.go") {
· · ·
37}
38
39func TestCouplingTargetCandidatesAbsoluteBecomesRepoRelative(t *testing.T) {
40 got := couplingTargetCandidates("/repo", filepath.FromSlash("/repo/processor/constants.go"))
41 if !hasCandidate(got, "processor/constants.go") {
· · ·
46// A path outside the repository can never be a git path, so it must yield no
47// candidates rather than a "../" form that would be looked up and miss.
48func TestCouplingTargetCandidatesRejectsEscapingPaths(t *testing.T) {
49 if got := couplingTargetCandidates("/repo", filepath.FromSlash("/etc/passwd")); len(got) != 0 {
50 t.Errorf("expected no candidates for a path outside the repo, got %v", got)
+ 21 more matches in this file
processor/file_test.go GO 31 matches · showing 5 view file →
11)
12
13func TestGetExtension(t *testing.T) {
14 got := getExtension("something.c")
15 expected := "c"
· · ·
20}
21
22func TestGetExtensionNoExtension(t *testing.T) {
23 got := getExtension("something")
24 expected := "something"
· · ·
29}
30
31func TestGetExtensionMultipleDots(t *testing.T) {
32 got := getExtension(".travis.yml")
33 expected := "travis.yml"
· · ·
38}
39
40func TestGetExtensionMultipleExtensions(t *testing.T) {
41 got := getExtension("something.go.yml")
42 expected := "go.yml"
· · ·
47}
48
49func TestGetExtensionStartsWith(t *testing.T) {
50 got := getExtension(".gitignore")
51 expected := ".gitignore"
+ 26 more matches in this file
Search syntax
auth loginboth terms (AND is implicit)
auth OR logineither term
NOT path:vendorexclude matches
"exact phrase"quoted exact match
/func\s+Test/regex
handler~1fuzzy (Levenshtein 1)
file:*_test.gofilename glob
path:pkg/auth/**full path glob
lang:golanguage filter

Search any public repo from your terminal

This page calls POST /api/v1/code_search. Same tool, available over MCP for Claude/Cursor/Copilot.