← Repo overview
/
boyter/ scc
/
search
@460a6e8
316 matches across 13 files for func main lang:Go lang:Go lang:Go
snippet_mode: auto · sorted by relevance
63 }
64
65 ▶ func checkForMatchSingle(currentByte byte, index int, endPoint int, matches []byte, fileJob *FileJob) bool {
66 potentialMatch := true
67 if currentByte == matches[0] {
· · ·
81 }
82
83 ▶ func isWhitespace(currentByte byte) bool {
84 if currentByte != ' ' && currentByte != '\t' && currentByte != '\n' && currentByte != '\r' {
85 return false
· · ·
89 }
90
91 ▶ func isIdentifierContinue(b byte) bool {
92 return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b >= '0' && b <= '9') || b == '_'
93 }
· · ·
94
95 ▶ func hasNonWhitespaceBefore(content []byte, index int) bool {
96 for i := index - 1; i >= 0; i-- {
97 if !isWhitespace(content[i]) {
· · ·
103 }
104
105 ▶ func nextNonWhitespaceIndex(content []byte, index int) int {
106 for index < len(content) && isWhitespace(content[index]) {
107 index++
+ 26 more matches in this file
1 // SPDX-License-Identifier: MIT
2
3 ▶ package main
4
5 import (
· · ·
30 // Reads all .json files in the current folder
31 // and encodes them as strings literals in constants.go
32 ▶ func generateConstants() error {
33 files, _ := os.ReadDir(".")
34 buf := &bytes.Buffer{}
· · ·
42 return fmt.Errorf("failed to open file '%s': %v", f.Name(), err)
43 }
44 ▶ defer func(file *os.File) {
45 _ = file.Close()
46 }(f)
· · ·
57 }
58
59 ▶ t, err := template.New("codeGenerator").Funcs(template.FuncMap{
60 "quote": strconv.Quote,
61 }).Parse(langTemplate)
· · ·
77 return fmt.Errorf("failed to open constants file: %v", err)
78 }
79 ▶ defer func(file *os.File) {
80 _ = file.Close()
81 }(out)
+ 3 more matches in this file
1 // SPDX-License-Identifier: MIT
2
3 ▶ package main
4
5 import (
· · ·
24 var mcpMu sync.Mutex
25
26 ▶ func startMCPServer() {
27 mcpServer := server.NewMCPServer(
28 "scc",
· · ·
149 }
150
151 ▶ func mcpAnalyzeHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
152 args := request.GetArguments()
153
· · ·
352 }
353
354 ▶ func jsonMarshal(v interface{}) ([]byte, error) {
355 return json.MarshalIndent(v, "", " ")
356 }
· · ·
358 // sortFileJobs sorts a slice of FileJob pointers using the current
359 // processor.SortBy value so that the most relevant files come first.
360 ▶ func sortFileJobs(files []*processor.FileJob) {
361 switch processor.SortBy {
362 case "name", "names", "language", "languages", "lang", "langs":
+ 9 more matches in this file
161 }
162
163 ▶ func parseRemapRules(value string) []remapRule {
164 rules := []remapRule{}
165
· · ·
177 }
178
179 ▶ func newRemapConfig(remapAll string, remapUnknown string) remapConfig {
180 return remapConfig{
181 all: parseRemapRules(remapAll),
· · ·
312 // ConfigureGc needs to be set outside of ProcessConstants because it should only be enabled in command line
313 // mode https://github.com/boyter/scc/issues/32
314 ▶ func ConfigureGc() {
315 gcPercent = debug.SetGCPercent(gcPercent)
316 }
· · ·
317
318 // ConfigureLazy is a simple setter used to turn on lazy loading used only by command line
319 ▶ func ConfigureLazy(lazy bool) {
320 isLazy = lazy
321 }
· · ·
323 // ProcessConstants is responsible for setting up the language features based on the JSON file that is stored in constants
324 // Needs to be called at least once in order for anything to actually happen
325 ▶ func ProcessConstants() {
326 startTime := makeTimestampNano()
327 for name, value := range languageDatabase {
+ 12 more matches in this file
1 ▶ package main
2
3 import (
· · ·
38 )
39
40 ▶ func intPtr(i int) *int {
41 return &i
42 }
· · ·
43
44 ▶ func timePtr(t time.Duration) *time.Duration {
45 return &t
46 }
· · ·
47
48 ▶ func 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
1 // SPDX-License-Identifier: MIT
2
3 ▶ package main
4
5 import (
· · ·
15 )
16
17 ▶ func printShellCompletion(cmd *cobra.Command, command string) error {
18 switch command {
19 case "bash":
· · ·
30 }
31
32 ▶ func 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
50 ▶ func main() {
51 // f, _ := os.Create("scc.pprof")
52 // pprof.StartCPUProfile(f)
· · ·
83 Long: fmt.Sprintf("Sloc, Cloc and Code. Count lines of code in a directory with complexity estimation.\nVersion %s\nBen Boyter <ben@boyter.org> + Contributors", processor.Version),
84 Version: processor.Version,
85 ▶ Run: func(cmd *cobra.Command, args []string) {
86 processor.DirFilePaths = args
87 processor.ConfigureGc()
10 )
11
12 ▶ func (job *FileJob) SetContent(content string) {
13 job.Content = []byte(content)
14 job.Bytes = int64(len(job.Content))
· · ·
15 }
16
17 ▶ func TestIsWhitespace(t *testing.T) {
18 if !isWhitespace(' ') {
19 t.Errorf("Expected to be true")
· · ·
21 }
22
23 ▶ func TestIsBinaryTrue(t *testing.T) {
24 DisableCheckBinary = false
25
· · ·
29 }
30
31 ▶ func TestIsBinaryDisableCheck(t *testing.T) {
32 DisableCheckBinary = true
33
· · ·
37 }
38
39 ▶ func TestCountStatsLines(t *testing.T) {
40 Trace = false
41 Debug = false
+ 93 more matches in this file
7 // https://github.com/boyter/scc/issues/72
8 // Turns out the above is due to BOM being present for that file
9 ▶ func TestCountStatsIssue72(t *testing.T) {
10 ProcessConstants()
11 fileJob := FileJob{
· · ·
52 }
53
54 ▶ func TestCountStatsPr76(t *testing.T) {
55 ProcessConstants()
56 fileJob := FileJob{
· · ·
58 }
59
60 ▶ fileJob.SetContent(`package main
61 var MyString = ` + "`\\`" + `
62 // Comment`)
· · ·
82
83 // https://github.com/boyter/scc/issues/62
84 ▶ func TestCountStatsIssue62(t *testing.T) {
85 ProcessConstants()
86 fileJob := FileJob{
· · ·
123 }
124
125 ▶ func TestCountStatsIssue123(t *testing.T) {
126 ProcessConstants()
127 fileJob := FileJob{
+ 6 more matches in this file
11 )
12
13 ▶ func TestGetExtension(t *testing.T) {
14 got := getExtension("something.c")
15 expected := "c"
· · ·
20 }
21
22 ▶ func TestGetExtensionNoExtension(t *testing.T) {
23 got := getExtension("something")
24 expected := "something"
· · ·
29 }
30
31 ▶ func TestGetExtensionMultipleDots(t *testing.T) {
32 got := getExtension(".travis.yml")
33 expected := "travis.yml"
· · ·
38 }
39
40 ▶ func TestGetExtensionMultipleExtensions(t *testing.T) {
41 got := getExtension("something.go.yml")
42 expected := "go.yml"
· · ·
47 }
48
49 ▶ func TestGetExtensionStartsWith(t *testing.T) {
50 got := getExtension(".gitignore")
51 expected := ".gitignore"
+ 21 more matches in this file
8 )
9
10 ▶ func TestLocomoComplexityDensityZeroCode(t *testing.T) {
11 got := LocomoComplexityDensity(10, 0)
12 if got != 0 {
· · ·
15 }
16
17 ▶ func TestLocomoComplexityDensity(t *testing.T) {
18 got := LocomoComplexityDensity(30, 100)
19 if math.Abs(got-0.3) > 0.001 {
· · ·
22 }
23
24 ▶ func TestLocomoComplexityFactor(t *testing.T) {
25 // density 0.3, weight 5 → 1 + sqrt(0.3)*5 ≈ 1 + 0.5477*5 ≈ 3.738
26 got := LocomoComplexityFactor(0.3, 5)
· · ·
30 }
31
32 ▶ func TestLocomoComplexityFactorLowDensity(t *testing.T) {
33 // density 0.05, weight 5 → 1 + sqrt(0.05)*5 ≈ 1 + 0.2236*5 ≈ 2.118
34 got := LocomoComplexityFactor(0.05, 5)
· · ·
38 }
39
40 ▶ func TestLocomoIterationFactor(t *testing.T) {
41 // density 0.3, base 1.5, weight 2 → 1.5 + sqrt(0.3)*2 ≈ 1.5 + 1.095 ≈ 2.595
42 got := LocomoIterationFactor(0.3, 1.5, 2)
+ 13 more matches in this file
1 ▶ package main
2
3 import (
· · ·
14 )
15
16 ▶ const sccTestFlag string = "-test.main"
17
18 var sccBinPath = os.Args[0]
· · ·
19
20 ▶ func TestMain(m *testing.M) {
21 idx := slices.Index(os.Args, sccTestFlag)
22 if idx != -1 {
· · ·
23 os.Args = slices.Delete(os.Args, idx, idx+1)
24 ▶ main()
25 return
26 }
· · ·
29 }
30
31 ▶ func runSCC(args ...string) (string, error) {
32 args = slices.Insert(args, 0, sccTestFlag)
33 cmd := exec.Command(sccBinPath, args...)
+ 41 more matches in this file
7 )
8
9 ▶ func TestCountStatsJava(t *testing.T) {
10 ProcessConstants()
11 fileJob := FileJob{
· · ·
21 {
22 int j = 0; // Not counted
23 ▶ public static void main(String[] args)
24 {
25 Foo f = new Foo();
· · ·
56 }
57
58 ▶ func TestCountStatsAccuracyCPlusPlus(t *testing.T) {
59 ProcessConstants()
60 fileJob := FileJob{
· · ·
72 * Simple test
73 */
74 ▶ int main()
75 {
76 cout<<"Hello world"<<endl;
· · ·
98 }
99
100 ▶ func TestCountStatsAccuracyRakefile(t *testing.T) {
101 ProcessConstants()
102 fileJob := FileJob{
+ 3 more matches in this file
1 ▶ package main
2
3 import (
· · ·
7 )
8
9 ▶ func Test_resolveColor(t *testing.T) {
10 tests := []struct {
11 name string
· · ·
55
56 for _, tt := range tests {
57 ▶ t.Run(tt.name, func(t *testing.T) {
58 if got := resolveColor(tt.color); got != tt.want {
59 t.Errorf("resolveColor(%q) = %q, want %q", tt.color, got, tt.want)
· · ·
63 }
64
65 ▶ func Test_formatCount(t *testing.T) {
66 type args struct {
67 count float64
· · ·
123 }
124 for _, tt := range tests {
125 ▶ t.Run(tt.name, func(t *testing.T) {
126 if got := formatCount(tt.args.count); got != tt.want {
127 t.Errorf("formatCount() = %v, want %v", got, tt.want)
+ 4 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.