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

Function validateReviewOptions

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

Source from the content-addressed store, hash-verified

127}
128
129func validateReviewOptions(opts *reviewOptions) error {
130 opts.to = normalizeDiffTarget(opts.from, opts.to, opts.commit)
131 if err := validateDiffMode(opts.from, opts.to, opts.commit); err != nil {
132 return err
133 }
134 if opts.preview && opts.resume != "" {
135 return fmt.Errorf("--preview and --resume cannot be used together")
136 }
137 if err := validateAudience(opts.audience); err != nil {
138 return err
139 }
140 normalizedFormat, err := validateOutputFormat(opts.outputFormat)
141 if err != nil {
142 return err
143 }
144 opts.outputFormat = normalizedFormat
145 if err := validateAnalysisOptions(*opts); err != nil {
146 return err
147 }
148 const minMaxTools = 50
149 if opts.maxTools < 0 {
150 return fmt.Errorf("--max-tools must be a non-negative integer (0 means use template default)")
151 }
152 if opts.maxTools > 0 && opts.maxTools < minMaxTools {
153 fmt.Fprintf(os.Stderr, "[ocr] --max-tools %d is below minimum %d, using %d\n", opts.maxTools, minMaxTools, minMaxTools)
154 opts.maxTools = minMaxTools
155 }
156 if opts.maxGitProcs < 0 {
157 return fmt.Errorf("--max-git-procs must be a non-negative integer (0 means use default 16)")
158 }
159 if opts.maxTokens < 0 {
160 return fmt.Errorf("--max-tokens must be a non-negative integer (0 means use configured or template default)")
161 }
162 if opts.maxTokensBudget < 0 {
163 return fmt.Errorf("--max-tokens-budget must be a non-negative integer (0 means unlimited)")
164 }
165 if opts.effort != "" {
166 if _, err := template.ParseEffort(opts.effort); err != nil {
167 return fmt.Errorf("--effort: %w", err)
168 }
169 }
170 return nil
171}
172
173func validateScanOptions(opts *scanOptions) error {
174 if err := validateAudience(opts.audience); err != nil {

Callers 3

parseReviewFlagsFunction · 0.85
TestAnalysisFlagsFunction · 0.85
review_cmd.goFile · 0.85

Calls 6

ParseEffortFunction · 0.92
normalizeDiffTargetFunction · 0.85
validateDiffModeFunction · 0.85
validateAudienceFunction · 0.85
validateOutputFormatFunction · 0.85
validateAnalysisOptionsFunction · 0.85

Tested by 2

parseReviewFlagsFunction · 0.68
TestAnalysisFlagsFunction · 0.68