Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* Go rule hints — language-specific signals for rules.
*
* `isTestFile` is file-path-based: Go convention enforces `*_test.go`
* via the `go test` toolchain, so this predicate is exact for the test
* concept. No directory convention exists in Go (tests live next to
* source).
*
* Throw-syntax analogue: Go's structural error-propagation is
* `panic(...)`. The `?` / `try!()` analogue doesn't exist; `return err`
* is the conventional error path but is too varied syntactically for a
* regex.
*/
import { isTestFile } from './walk.js';
import type { RuleHints } from '@opensip-tools/graph';
const GO_SIDE_EFFECT_PRIMITIVES: readonly string[] = [
'fmt.Print',
'fmt.Println',
'fmt.Printf',
'fmt.Fprint',
'fmt.Fprintln',
'fmt.Fprintf',
'log.Print',
'log.Println',
'log.Printf',
'log.Fatal',
'log.Fatalln',
'log.Fatalf',
'log.Panic',
'log.Panicln',
'log.Panicf',
'os.Exit',
'os.Setenv',
'os.Unsetenv',
'os.Remove',
'os.RemoveAll',
'os.Create',
'os.WriteFile',
'os.ReadFile',
'os.Mkdir',
'os.MkdirAll',
'time.Sleep',
'rand.Int',
'rand.Intn',
'rand.Float64',
];
// Go's structural throw analogue is `panic(...)`. `return err` is also
// an error path but is too varied to capture via regex.
const GO_THROW_REGEX = /\bpanic\s*\(/;
const GO_GENERATED_FILE_PATTERNS: readonly string[] = [
'**/vendor/**',
'**/*.pb.go',
'**/*_generated.go',
'**/*.gen.go',
'**/zz_generated_*.go',
];
export const goRuleHints: RuleHints = {
isTestFile,
generatedFilePatterns: GO_GENERATED_FILE_PATTERNS,
sideEffectPrimitives: GO_SIDE_EFFECT_PRIMITIVES,
throwSyntaxRegex: GO_THROW_REGEX,
};
|