MCPcopy Create free account
hub / github.com/alibaba/open-code-review / validateReviewOptions

Function validateReviewOptions

cmd/opencodereview/shared_flags.go:105–133  ·  view source on GitHub ↗
(opts *reviewOptions)

Source from the content-addressed store, hash-verified

103}
104
105func validateReviewOptions(opts *reviewOptions) error {
106 if err := validateDiffMode(opts.from, opts.to, opts.commit); err != nil {
107 return err
108 }
109 if opts.preview && opts.resume != "" {
110 return fmt.Errorf("--preview and --resume cannot be used together")
111 }
112 if err := validateAudience(opts.audience); err != nil {
113 return err
114 }
115 const minMaxTools = 10
116 if opts.maxTools < 0 {
117 return fmt.Errorf("--max-tools must be a non-negative integer (0 means use template default)")
118 }
119 if opts.maxTools > 0 && opts.maxTools < minMaxTools {
120 fmt.Fprintf(os.Stderr, "[ocr] --max-tools %d is below minimum %d, using %d\n", opts.maxTools, minMaxTools, minMaxTools)
121 opts.maxTools = minMaxTools
122 }
123 if opts.maxGitProcs < 0 {
124 return fmt.Errorf("--max-git-procs must be a non-negative integer (0 means use default 16)")
125 }
126 if opts.maxTokens < 0 {
127 return fmt.Errorf("--max-tokens must be a non-negative integer (0 means use configured or template default)")
128 }
129 if opts.maxTokensBudget < 0 {
130 return fmt.Errorf("--max-tokens-budget must be a non-negative integer (0 means unlimited)")
131 }
132 return nil
133}
134
135func validateScanOptions(opts *scanOptions) error {
136 if err := validateAudience(opts.audience); err != nil {

Callers 2

parseReviewFlagsFunction · 0.85
review_cmd.goFile · 0.85

Calls 2

validateDiffModeFunction · 0.85
validateAudienceFunction · 0.85

Tested by 1

parseReviewFlagsFunction · 0.68