341 matches across 17 files for func main
snippet_mode: auto · sorted by relevance
scripts/include.go GO 8 matches · showing 5 view file →
1// SPDX-License-Identifier: MIT
2
3package main
4
5import (
· · ·
30// Reads all .json files in the current folder
31// and encodes them as strings literals in constants.go
32func 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
processor/workers.go GO 31 matches · showing 5 view file →
63}
64
65func checkForMatchSingle(currentByte byte, index int, endPoint int, matches []byte, fileJob *FileJob) bool {
66 potentialMatch := true
67 if currentByte == matches[0] {
· · ·
81}
82
83func isWhitespace(currentByte byte) bool {
84 if currentByte != ' ' && currentByte != '\t' && currentByte != '\n' && currentByte != '\r' {
85 return false
· · ·
89}
90
91func isIdentifierContinue(b byte) bool {
92 return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b >= '0' && b <= '9') || b == '_'
93}
· · ·
94
95func hasNonWhitespaceBefore(content []byte, index int) bool {
96 for i := index - 1; i >= 0; i-- {
97 if !isWhitespace(content[i]) {
· · ·
103}
104
105func nextNonWhitespaceIndex(content []byte, index int) int {
106 for index < len(content) && isWhitespace(content[index]) {
107 index++
+ 26 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 5 matches 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)
· · ·
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()
mcp.go GO 14 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",
· · ·
149}
150
151func mcpAnalyzeHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
152 args := request.GetArguments()
153
· · ·
352}
353
354func 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.
360func sortFileJobs(files []*processor.FileJob) {
361 switch processor.SortBy {
362 case "name", "names", "language", "languages", "lang", "langs":
+ 9 more matches in this file
processor/processor.go GO 17 matches · showing 5 view file →
161}
162
163func parseRemapRules(value string) []remapRule {
164 rules := []remapRule{}
165
· · ·
177}
178
179func 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
314func 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
319func 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
325func ProcessConstants() {
326 startTime := makeTimestampNano()
327 for name, value := range languageDatabase {
+ 12 more matches in this file
processor/workers_test.go GO 98 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
+ 93 more matches in this file
packages/chocolatey/tools/chocolateyuninstall.ps1 POWERSHELL 2 matches view file →
65 Write-Warning "$($key.Count) matches found!"
66 Write-Warning "To prevent accidental data loss, no programs will be uninstalled."
67 Write-Warning "Please alert package maintainer the following keys were matched:"
68 $key | % {Write-Warning "- $($_.DisplayName)"}
69}
· · ·
70
71## OTHER POWERSHELL FUNCTIONS
72## https://chocolatey.org/docs/helpers-reference
73#Uninstall-ChocolateyZipPackage $packageName # Only necessary if you did not unpack to package directory - see https://chocolatey.org/docs/helpers-uninstall-chocolatey-zip-package
processor/workers_regression_test.go GO 11 matches · showing 5 view file →
7// https://github.com/boyter/scc/issues/72
8// Turns out the above is due to BOM being present for that file
9func TestCountStatsIssue72(t *testing.T) {
10 ProcessConstants()
11 fileJob := FileJob{
· · ·
52}
53
54func TestCountStatsPr76(t *testing.T) {
55 ProcessConstants()
56 fileJob := FileJob{
· · ·
58 }
59
60 fileJob.SetContent(`package main
61var MyString = ` + "`\\`" + `
62// Comment`)
· · ·
82
83// https://github.com/boyter/scc/issues/62
84func TestCountStatsIssue62(t *testing.T) {
85 ProcessConstants()
86 fileJob := FileJob{
· · ·
123}
124
125func TestCountStatsIssue123(t *testing.T) {
126 ProcessConstants()
127 fileJob := FileJob{
+ 6 more matches in this file
processor/file_test.go GO 26 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"
+ 21 more matches in this file
processor/locomo_test.go GO 18 matches · showing 5 view file →
8)
9
10func TestLocomoComplexityDensityZeroCode(t *testing.T) {
11 got := LocomoComplexityDensity(10, 0)
12 if got != 0 {
· · ·
15}
16
17func TestLocomoComplexityDensity(t *testing.T) {
18 got := LocomoComplexityDensity(30, 100)
19 if math.Abs(got-0.3) > 0.001 {
· · ·
22}
23
24func 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
32func 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
40func 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
main_test.go GO 46 matches · showing 5 view file →
1package main
2
3import (
· · ·
14)
15
16const sccTestFlag string = "-test.main"
17
18var sccBinPath = os.Args[0]
· · ·
19
20func 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
31func runSCC(args ...string) (string, error) {
32 args = slices.Insert(args, 0, sccTestFlag)
33 cmd := exec.Command(sccBinPath, args...)
+ 41 more matches in this file
processor/workers_tokei_test.go GO 8 matches · showing 5 view file →
7)
8
9func 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
58func TestCountStatsAccuracyCPlusPlus(t *testing.T) {
59 ProcessConstants()
60 fileJob := FileJob{
· · ·
72 * Simple test
73 */
74int main()
75{
76 cout<<"Hello world"<<endl;
· · ·
98}
99
100func TestCountStatsAccuracyRakefile(t *testing.T) {
101 ProcessConstants()
102 fileJob := FileJob{
+ 3 more matches in this file
cmd/badges/main_test.go GO 9 matches · showing 5 view file →
1package main
2
3import (
· · ·
7)
8
9func 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
65func 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
benchmark_to_chart.py PYTHON 5 matches view file →
13
14
15def main():
16 if len(sys.argv) < 2:
17 print(f"Usage: {sys.argv[0]} benchmark_regression.json [title]")
· · ·
40 google.charts.setOnLoadCallback(drawChart);
41
42 function drawChart() {{
43 var data = google.visualization.arrayToDataTable([
44 ['Version', 'Runtime (seconds)'],
· · ·
48 var options = {{
49 title: '{title}',
50 curveType: 'function',
51 legend: {{ position: 'bottom' }}
52 }};
· · ·
66
67
68if __name__ == "__main__":
69 main()
70
· · ·
69 main()
70
README.md MARKDOWN 16 matches · showing 5 view file →
172- [gocloc](https://github.com/hhatto/gocloc) a sloc counter in Go inspired by tokei
173- [loc](https://github.com/cgag/loc) rust implementation similar to tokei but often faster
174- [loccount](https://gitlab.com/esr/loccount) Go implementation written and maintained by ESR
175- [polyglot](https://github.com/vmchale/polyglot) ATS sloc counter
176- [tokei](https://github.com/XAMPPRocky/tokei) fast, accurate and written in rust
· · ·
177- [sloc](https://github.com/flosse/sloc) coffeescript code counter
178- [stto](https://github.com/mainak55512/stto) new Go code counter with a focus on performance
179
180Interesting reading about other code counting projects tokei, loc, polyglot and loccount
· · ·
440Because some languages don't have loops and instead use recursion they can have a lower complexity count. Does this mean they are less complex? Probably not, but the tool cannot see this because it does not build an AST of the code as it only scans through it.
441
442Generally though the complexity there is to help estimate between projects written in the same language, or for finding the most complex file in a project `scc --by-file -s complexity` which can be useful when you are estimating on how hard something is to maintain, or when looking for those files that should probably be refactored.
443
444As for how it works.
· · ·
460there to assist with the estimation of complexity within the project. Quoting the source
461
462> In my opinion, the number this produces should be a better estimate of the complexity of a project. Compared to SLOC, not only are blank lines discounted, but so are close-brace lines and other repetitive code such as common includes. On the other hand, ULOC counts comments, which require just as much maintenance as the code around them does, while avoiding inflating the result with license headers which appear in every file, for example.
463
464You can obtain the ULOC by supplying the `-u` or `--uloc` argument to `scc`.
· · ·
1075### CI/CD Support
1076
1077Some CI/CD systems which will remain nameless do not work very well with the box-lines used by `scc`. To support those systems better there is an option `--ci` which will change the default output to ASCII only.
1078
1079```text
+ 11 more matches in this file
packages/chocolatey/tools/chocolateyinstall.ps1 POWERSHELL 2 matches view file →
75#Install-ChocolateyInstallPackage @packageArgs # https://chocolatey.org/docs/helpers-install-chocolatey-install-package
76
77## Main helper functions - these have error handling tucked into them already
78## see https://chocolatey.org/docs/helpers-reference
79
· · ·
93## see the full list at https://chocolatey.org/docs/helpers-reference
94
95## downloader that the main helpers use to download items
96## if removing $url64, please remove from here
97## - https://chocolatey.org/docs/helpers-get-chocolatey-web-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.