1,280 matches across 25 files for error
snippet_mode: grep · sorted by relevance
NOTES.md MARKDOWN 1 matches view file →
58- Fix potential MCP issue (a148002) and MCP settings/sorting/limit tweaks.
59- Fix circular symlinks bug (#694).
60- Catch error when mapping to an unknown language (30fa28a); fix a panic
61 (dc8c92e).
62- Fix for issue #412 (#719).
README.md MARKDOWN 5 matches view file →
73`$ sudo snap install scc`
74
75*NB* Snap installed applications cannot run outside of `/home` <https://askubuntu.com/questions/930437/permission-denied-error-when-running-apps-installed-as-snap-packages-ubuntu-17> so you may encounter issues if you use snap and attempt to run outside this directory.
76
77#### Homebrew
· · ·
662- 75% (High Density): Very terse, expressive code. Every line counts. (Example: Clojure, Haskell)
663- 60% - 70% (Standard): A healthy balance of logic and structural ceremony. (Example: Java, Python)
664- < 55% (High Boilerplate): High repetition. Likely due to mandatory error handling, auto-generated code, or verbose configuration. (Example: C#, CSS)
665
666See <https://boyter.org/posts/boilerplate-tax-ranking-popular-languages-by-density/> for more details.
· · ·
867| `--no-fold-authors` | off | Disable the name + email-domain identity folding fallback applied after `.mailmap`. |
868
869Each report is standalone: `--hotspots`, `--coupling` (or `--coupling-for`), and `--by-author` / `--timeline` are mutually exclusive, and combining them is an error. `--coupling-for FILE` implies `--coupling`. With `--by-author` set, `--timeline` switches from the author rollup to the author timeline. Alone, `--timeline` renders the languages timeline.
870
871#### Hotspots - `--hotspots`
· · ·
1000- `.gitignore` is already applied by git when each commit was recorded; `.ignore` / `.sccignore` are honoured by the engine (disable with `--no-ignore` / `--no-scc-ignore`).
1001- Merge commits are diffed against their first parent (`git log --first-parent` semantics).
1002- Rename detection uses go-git's similarity heuristic; large renames may inflate hotspot churn and reset blame attribution. Shallow clones produce a clear error rather than a panic.
1003- `Lines±` is the sum of added and removed lines, so files rewritten in place count twice the displaced size.
1004- Symlinks are skipped (v1). Binary detection is unchanged.
· · ·
1700If you are running `scc` in a low memory environment < 512 MB of RAM you may need to set `--file-gc-count` to a lower value such as `0` to force the garbage collector to be on at all times.
1701
1702A sign that this is required will be `scc` crashing with panic errors.
1703
1704### Tests
cmd/badges/main.go GO 12 matches · showing 5 view file →
3import (
4 "context"
5 "errors"
6 "fmt"
7 "math"
· · ·
63
64 if filterBad(loc) {
65 log.Error().Str(uniqueCode, "bfee4bd8").Str("loc", loc.String()).Msg("filter bad")
66 return
67 }
· · ·
71 res, err := process(1, loc)
72 if err != nil {
73 log.Error().Str(uniqueCode, "03ec75c3").Err(err).Str("loc", loc.String()).Send()
74 w.WriteHeader(http.StatusBadRequest)
75 _, _ = w.Write([]byte("something bad happened sorry"))
· · ·
108 addr := ":8080"
109 log.Info().Str(uniqueCode, "1876ce1e").Str("addr", addr).Msg("serving")
110 if err := http.ListenAndServe(addr, nil); err != nil && !errors.Is(err, http.ErrServerClosed) {
111 log.Error().Str(uniqueCode, "c28556e8").Err(err).Send()
112 os.Exit(1)
· · ·
111 log.Error().Str(uniqueCode, "c28556e8").Err(err).Send()
112 os.Exit(1)
113 }
+ 7 more matches in this file
cmd/badges/main_test.go GO 5 matches view file →
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)
60 }
61 })
· · ·
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)
128 }
129 })
· · ·
170 got, err := processUrlPath(tt.args.path)
171 if (err != nil) != tt.wantErr {
172 t.Errorf("processUrlPath() error = %v, wantErr %v", err, tt.wantErr)
173 return
174 }
· · ·
175 if !reflect.DeepEqual(got, tt.want) {
176 t.Errorf("processUrlPath() got = %v, want %v", got, tt.want)
177 }
178 })
· · ·
298 t.Run(tt.name, func(t *testing.T) {
299 if got := parseBadgeSettings(tt.values); !reflect.DeepEqual(got, tt.want) {
300 t.Errorf("parseBadgeSettings() = %v, want %v", got, tt.want)
301 }
302 })
config.go GO 14 matches · showing 5 view file →
185
186// discoverConfigArgs resolves the global and project config sources
187func discoverConfigArgs(noConfig, findRoot bool, explicitPath string) (globalTokens, projectTokens []string, err error) {
188 // Global source: --config wins, else SCC_CONFIG_PATH (when non-empty and not
189 // disabled), else nothing. No default location, no home-dir stat.
· · ·
202 if readErr != nil {
203 // Explicit source the user asked for: surface and exit non-zero.
204 return nil, nil, fmt.Errorf("could not read config file %q: %w", globalPath, readErr)
205 }
206 globalTokens = tokens
· · ·
229// readConfigFile reads and tokenizes a config source, recording it for trace
230// output and unknown-flag attribution.
231func readConfigFile(path, label string) (tokens []string, err error) {
232 defer func() {
233 if r := recover(); r != nil {
· · ·
234 err = fmt.Errorf("panic while reading config: %v", r)
235 }
236 }()
· · ·
325 return real
326 }
327 boolFunc := func(real func(string) error) func(string) error {
328 if b.inert {
329 return func(string) error { return nil }
+ 9 more matches in this file
config_test.go GO 63 matches · showing 5 view file →
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)
· · ·
132 got := parseConfigArgs(tc.content, tc.allowPositional)
133 if !slices.Equal(got, tc.want) {
134 t.Errorf("parseConfigArgs(%q, %v) = %q, want %q", tc.content, tc.allowPositional, got, tc.want)
135 }
136 })
· · ·
163 noConfig, findRoot, path := preScanConfig(tc.args)
164 if noConfig != tc.wantNoConfig || findRoot != tc.wantFindRoot || path != tc.wantPath {
165 t.Errorf("preScanConfig(%q) = (%v,%v,%q), want (%v,%v,%q)",
166 tc.args, noConfig, findRoot, path, tc.wantNoConfig, tc.wantFindRoot, tc.wantPath)
167 }
· · ·
175
176 if got := mergeSliceDefault(nil, defaults); !slices.Equal(got, defaults) {
177 t.Errorf("empty set should fall back to defaults, got %q", got)
178 }
179 if got := mergeSliceDefault([]string{"vendor"}, defaults); !slices.Equal(got, []string{".git", ".hg", ".svn", "vendor"}) {
· · ·
180 t.Errorf("defaults should be preserved, got %q", got)
181 }
182 if got := mergeSliceDefault([]string{"vendor", "dist"}, defaults); !slices.Equal(got, []string{".git", ".hg", ".svn", "vendor", "dist"}) {
+ 58 more matches in this file
go.sum 2 matches view file →
93github.com/pjbgf/sha1cd v0.6.0 h1:3WJ8Wz8gvDz29quX1OcEmkAlUg9diU4GxJHqs0/XiwU=
94github.com/pjbgf/sha1cd v0.6.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
95github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
96github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
97github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
· · ·
96github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
97github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
98github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
languages.json JSON 1 matches view file →
377 "else if ",
378 "try ",
379 "on error ",
380 "and ",
381 "or "
main.go GO 10 matches · showing 5 view file →
4
5import (
6 "errors"
7 "fmt"
8 "os"
· · ·
15)
16
17func printShellCompletion(cmd *cobra.Command, command string) error {
18 switch command {
19 case "bash":
· · ·
26 return cmd.GenPowerShellCompletion(os.Stdout)
27 default:
28 return errors.New("Unknown shell: " + command)
29 }
30}
· · ·
71 b, err := os.ReadFile(filename)
72 if err != nil {
73 fmt.Fprintf(os.Stderr, "Error reading flags from a file: %s\n", err)
74 os.Exit(1)
75 }
· · ·
89 if !isCompletionInvocation(os.Args) {
90 noConfig, findRoot, explicitPath := preScanConfig(os.Args)
91 var discoverErr error
92 globalTokens, projectTokens, discoverErr = discoverConfigArgs(noConfig, findRoot, explicitPath)
93 if discoverErr != nil {
+ 5 more matches in this file
main_test.go GO 33 matches · showing 5 view file →
29}
30
31func runSCC(args ...string) (string, error) {
32 args = slices.Insert(args, 0, sccTestFlag)
33 cmd := exec.Command(sccBinPath, args...)
· · ·
269 }
270 if !strings.Contains(output, "MATLAB") {
271 t.Errorf("can not find MATLAB, output: %s", output)
272 }
273 if !strings.Contains(output, "Objective C") {
· · ·
274 t.Errorf("can not find Objective C, output:\n%s", output)
275 }
276}
· · ·
280 output, err := runSCC("--not-a-real-option")
281 if err == nil {
282 t.Fatal("scc should exit with error code")
283 }
284 if !strings.Contains(output, "Error: unknown flag: --not-a-real-option") {
· · ·
284 if !strings.Contains(output, "Error: unknown flag: --not-a-real-option") {
285 t.Fatalf("scc should report invalid options, output:\n%s", output)
286 }
+ 28 more matches in this file
mcp.go GO 16 matches · showing 5 view file →
147
148 errLogger := log.New(os.Stderr, "scc-mcp: ", log.LstdFlags)
149 if err := server.ServeStdio(mcpServer, server.WithErrorLogger(errLogger)); err != nil {
150 _, _ = fmt.Fprintf(os.Stderr, "scc-mcp: server error: %v\n", err)
151 os.Exit(1)
· · ·
150 _, _ = fmt.Fprintf(os.Stderr, "scc-mcp: server error: %v\n", err)
151 os.Exit(1)
152 }
· · ·
218}
219
220func mcpAnalyzeHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
221 args := request.GetArguments()
222
· · ·
230 absPath, err := filepath.Abs(path)
231 if err != nil {
232 return mcp.NewToolResultError(fmt.Sprintf("invalid path: %v", err)), nil
233 }
234
· · ·
235 // Verify path can be accessed
236 if _, err := os.Stat(absPath); err != nil {
237 return mcp.NewToolResultError(fmt.Sprintf("path cannot be accessed: %s: %v", absPath, err)), nil
238 }
239
+ 11 more matches in this file
mcp_test.go GO 20 matches · showing 5 view file →
108 result, err := mcpAnalyzeHandler(context.Background(), req)
109 if err != nil {
110 t.Fatalf("mcpAnalyzeHandler returned error: %v", err)
111 }
112 if result.IsError {
· · ·
112 if result.IsError {
113 t.Fatalf("mcpAnalyzeHandler returned tool error: %+v", result.Content)
114 }
· · ·
113 t.Fatalf("mcpAnalyzeHandler returned tool error: %+v", result.Content)
114 }
115 if len(result.Content) == 0 {
· · ·
139
140// callCoupling invokes the coupling MCP handler with the given arguments and
141// returns the result, failing the test on a transport-level (non-tool) error.
142func callCoupling(t *testing.T, args map[string]any) *mcp.CallToolResult {
143 t.Helper()
· · ·
147 res, err := mcpCouplingHandler(context.Background(), req)
148 if err != nil {
149 t.Fatalf("handler returned transport error: %v", err)
150 }
151 if res == nil {
+ 15 more matches in this file
packages/chocolatey/tools/chocolateyinstall.ps1 POWERSHELL 2 matches view file →
6# 2. Follow the documentation below to learn how to create a package for the package type you are creating.
7# 3. In Chocolatey scripts, ALWAYS use absolute paths - $toolsDir gets you to the package's tools directory.
8$ErrorActionPreference = 'Stop'; # stop on all errors
9#Items that could be replaced based on what you call chocopkgup.exe with
10#{{PackageName}} - Package Name (should be same as nuspec file and folder) |/p
· · ·
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
packages/chocolatey/tools/chocolateyuninstall.ps1 POWERSHELL 1 matches view file →
11## If this is an exe, change fileType, silentArgs, and validExitCodes
12
13$ErrorActionPreference = 'Stop'; # stop on all errors
14$packageArgs = @{
15 packageName = $env:ChocolateyPackageName
processor/cocomo_test.go GO 9 matches · showing 5 view file →
15 // Should be around 582
16 if got < 580 || got > 585 {
17 t.Errorf("Got %f", got)
18 }
19}
· · ·
25 // Should be around 2602469
26 if got < 2602460 || got > 2602480 {
27 t.Errorf("Got %f", got)
28 }
29}
· · ·
35 // Should be around 2.7
36 if got < 2.6 || got > 2.8 {
37 t.Errorf("Got %f", got)
38 }
39}
· · ·
50 want := eff * (56286.0 / 12.0) * 2.4
51 if math.Abs(got-want) > 1e-6 {
52 t.Errorf("EstimateCost truncated the monthly wage: got %v want %v (diff %v)", got, want, got-want)
53 }
54}
· · ·
186
187 if tt.wantEffort != 0 && !floatApproxEqual(effort, tt.wantEffort) {
188 t.Errorf("effort = %v, want %v", effort, tt.wantEffort)
189 }
190 if tt.wantSched != 0 && !floatApproxEqual(sched, tt.wantSched) {
+ 4 more matches in this file
processor/cognitive_nesting_test.go GO 11 matches · showing 5 view file →
72 for name, job := range map[string]FileJob{"deep": deep, "deNested": mid, "flat": shallow} {
73 if job.Complexity != 4 {
74 t.Errorf("%s: expected Complexity 4 (four ifs), got %d", name, job.Complexity)
75 }
76 }
· · ·
78 // Exact cognitive values from the 1+nesting rule.
79 if deep.Cognitive != 14 {
80 t.Errorf("deepChain Cognitive: expected 14, got %d", deep.Cognitive)
81 }
82 if mid.Cognitive != 10 {
· · ·
83 t.Errorf("deNested Cognitive: expected 10, got %d", mid.Cognitive)
84 }
85 if shallow.Cognitive != 8 {
· · ·
86 t.Errorf("flat Cognitive: expected 8, got %d", shallow.Cognitive)
87 }
88
· · ·
90 // strictly higher, even at identical cyclomatic complexity.
91 if !(deep.Cognitive > mid.Cognitive && mid.Cognitive > shallow.Cognitive) {
92 t.Errorf("expected deep > deNested > flat, got %d, %d, %d",
93 deep.Cognitive, mid.Cognitive, shallow.Cognitive)
94 }
+ 6 more matches in this file
processor/constants.go GO 1 matches view file →
697 "else if ",
698 "try ",
699 "on error ",
700 "and ",
701 "or ",
processor/detector.go GO 7 matches · showing 5 view file →
6 "bytes"
7 "cmp"
8 "errors"
9 "slices"
10 "strings"
· · ·
12
13var (
14 errMissingShebang = errors.New("missing shebang")
15 errUnknownShebang = errors.New("unknown shebang")
16 errUnableToDetermineShebangCmd = errors.New("unable to determine shebang command")
· · ·
15 errUnknownShebang = errors.New("unknown shebang")
16 errUnableToDetermineShebangCmd = errors.New("unable to determine shebang command")
17)
· · ·
16 errUnableToDetermineShebangCmd = errors.New("unable to determine shebang command")
17)
18
· · ·
19// DetectLanguage detects a language based on the filename returns the language extension and error
20func DetectLanguage(name string) ([]string, string) {
21 extension := ""
+ 2 more matches in this file
processor/detector_test.go GO 46 matches · showing 5 view file →
15
16 if ext != "css" {
17 t.Error("Expected css got", ext)
18 }
19 AllowListExtensions = []string{}
· · ·
30 possible, extension := DetectLanguage(filename)
31 if extension != wantExtension {
32 t.Errorf("DetectLanguage(%q) extension = %q, want %q", filename, extension, wantExtension)
33 }
34 if !slices.Contains(possible, "Mojo") {
· · ·
35 t.Errorf("DetectLanguage(%q) languages = %v, want Mojo", filename, possible)
36 }
37 }
· · ·
44
45 if x != "" || y == nil {
46 t.Error("Expected no match got", x)
47 }
48
· · ·
50
51 if x != "" || y == nil {
52 t.Error("Expected no match got", x)
53 }
54}
+ 41 more matches in this file
processor/duplicates_test.go GO 1 matches view file →
46 for i := range first {
47 if first[i].Count != second[i].Count {
48 t.Errorf("language %s: first run counted %d files, second counted %d", first[i].Name, first[i].Count, second[i].Count)
49 }
50 }
processor/file.go GO 3 matches view file →
66 }
67
68 var err error
69 symPath, err = filepath.EvalSymlinks(path)
70 if err != nil {
· · ·
71 printError(err.Error())
72 return nil
73 }
· · ·
74 fileInfo, err = os.Lstat(symPath)
75 if err != nil {
76 printError(err.Error())
77 return nil
78 }
processor/file_test.go GO 25 matches · showing 5 view file →
16
17 if got != expected {
18 t.Errorf("Expected %s got %s", expected, got)
19 }
20}
· · ·
25
26 if got != expected {
27 t.Errorf("Expected %s got %s", expected, got)
28 }
29}
· · ·
34
35 if got != expected {
36 t.Errorf("Expected %s got %s", expected, got)
37 }
38}
· · ·
43
44 if got != expected {
45 t.Errorf("Expected %s got %s", expected, got)
46 }
47}
· · ·
52
53 if got != expected {
54 t.Errorf("Expected %s got %s", expected, got)
55 }
56}
+ 20 more matches in this file
processor/filereader.go GO 3 matches view file →
22
23// ReadFile actually reads the file into a buffer size controlled by LargeByteCount
24func (reader *FileReader) ReadFile(path string, size int) ([]byte, error) {
25 fd, err := os.Open(path)
26 if err != nil {
· · ·
27 return nil, fmt.Errorf("error opening %s: %v", path, err)
28 }
29 defer func(file *os.File) {
· · ·
46 _, err = reader.Buffer.ReadFrom(fd)
47 if err != nil {
48 return nil, fmt.Errorf("error reading %s: %w", path, err)
49 }
50
processor/formatters_cognitive_test.go GO 23 matches · showing 5 view file →
49
50 if !strings.Contains(res, "Cognitive") {
51 t.Errorf("wide cognitive output missing Cognitive header:\n%s", res)
52 }
53 // language total and grand total are both 11 + 20 = 31
· · ·
54 if !strings.Contains(res, "31") {
55 t.Errorf("wide cognitive output missing summed cognitive 31:\n%s", res)
56 }
57}
· · ·
64
65 if strings.Contains(res, "Cognitive") {
66 t.Errorf("wide output leaked Cognitive column while disabled:\n%s", res)
67 }
68 // Break lines must stay at the original 109-rune width when disabled.
· · ·
69 for _, line := range strings.Split(res, "\n") {
70 if strings.HasPrefix(line, "─") && len([]rune(line)) != 109 {
71 t.Errorf("disabled wide break width changed: got %d want 109", len([]rune(line)))
72 }
73 }
· · ·
85
86 if !strings.Contains(res, "Complexity") {
87 t.Errorf("short view lost the Complexity header:\n%s", res)
88 }
89 if strings.Contains(res, "Cognitive") {
+ 18 more matches in this file
processor/formatters_percent_test.go GO 2 matches view file →
41 res := fn(job())
42 if strings.Contains(res, "NaN") {
43 t.Errorf("expected no NaN in --percent output, got:\n%s", res)
44 }
45 if !strings.Contains(res, "0.0%") {
· · ·
46 t.Errorf("expected a 0.0%% entry for the empty categories, got:\n%s", res)
47 }
48 })
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.