@@ -42,6 +42,7 @@ func cleanDir(targetDir string, files []os.DirEntry) (rerr error) {
4242 continue
4343 }
4444 // Do not return error if file does not exist.
45+ //#nosec G703
4546 if err := os .Remove (filepath .Join (targetDir , name )); err != nil && ! os .IsNotExist (err ) {
4647 // Do not stop on first error, try to remove all files.
4748 rerr = errors .Join (rerr , err )
@@ -75,6 +76,7 @@ func generate(data []byte, packageName, targetDir string, clean bool, opts gen.O
7576 // Clean target dir only after flag parsing, spec parsing and IR building.
7677 switch files , err := os .ReadDir (targetDir ); {
7778 case os .IsNotExist (err ):
79+ //#nosec G703
7880 if err := os .MkdirAll (targetDir , 0o750 ); err != nil {
7981 return err
8082 }
@@ -116,6 +118,7 @@ func handleGenerateError(w io.Writer, color bool, err error) (r bool) {
116118 }
117119
118120 if msg , feature , ok := handleNotImplementedError (err ); ok {
121+ //#nosec 6705
119122 _ , _ = fmt .Fprintf (w , `
120123%s
121124Try to create ogen.yml with:
@@ -160,12 +163,15 @@ func handleNotImplementedError(err error) (msg, feature string, _ bool) {
160163 if inferErr , ok := errors.Into [* gen.ErrFieldsDiscriminatorInference ](err ); ok {
161164 printTyp := func (sb * strings.Builder , typ * ir.Type ) {
162165 if typ .Schema == nil {
166+ //#nosec G705
163167 fmt .Fprintf (sb , "%q" , typ .Name )
164168 return
165169 }
166170 if ref := typ .Schema .Ref ; ref .IsZero () {
171+ //#nosec G705
167172 fmt .Fprintf (sb , "%q" , typ .Name )
168173 } else {
174+ //#nosec G705
169175 fmt .Fprintf (sb , "%q" , ref .Ptr )
170176 }
171177 ptr := typ .Schema .Pointer
@@ -205,11 +211,13 @@ func handleNotImplementedError(err error) (msg, feature string, _ bool) {
205211 })
206212 for _ , field := range properties {
207213 if printedProperties >= propertyLimit {
214+ //#nosec G705
208215 fmt .Fprintf (& sb , "\t \t ...%d more properties...\n " , len (properties ))
209216 break
210217 }
211218 printedProperties ++
212219
220+ //#nosec G705
213221 fmt .Fprintf (& sb , "\t \t property %q also used by\n " , field )
214222
215223 var (
@@ -218,6 +226,7 @@ func handleNotImplementedError(err error) (msg, feature string, _ bool) {
218226 )
219227 for _ , typ := range alsoUsedBy {
220228 if printedUsedBy >= usedByLimit {
229+ //#nosec G705
221230 fmt .Fprintf (& sb , "\t \t \t ...%d more variants...\n " , len (alsoUsedBy ))
222231 break
223232 }
@@ -257,6 +266,7 @@ func loadConfig(cfgPath string, log *zap.Logger) (opts gen.Options, _ error) {
257266 }
258267read:
259268 log .Debug ("Reading config file" , zap .String ("path" , cfgPath ))
269+ //#nosec G703
260270 data , err := os .ReadFile (cfgPath )
261271 if err != nil {
262272 return opts , err
@@ -276,6 +286,7 @@ func run() error {
276286 set := flag .NewFlagSet (os .Args [0 ], flag .ExitOnError )
277287 set .Usage = func () {
278288 _ , toolName := filepath .Split (os .Args [0 ])
289+ //#nosec G705
279290 _ , _ = fmt .Fprintf (set .Output (), "Usage: %s [options] <spec>\n " , toolName )
280291 set .PrintDefaults ()
281292 }
@@ -330,6 +341,7 @@ func run() error {
330341 }()
331342
332343 if f := * cpuProfile ; f != "" {
344+ //#nosec G703
333345 f , err := os .Create (f )
334346 if err != nil {
335347 return errors .Wrap (err , "create cpu profile" )
@@ -345,6 +357,7 @@ func run() error {
345357 }
346358 }
347359 if f := * memProfile ; f != "" {
360+ //#nosec G703
348361 f , err := os .Create (f )
349362 if err != nil {
350363 return errors .Wrap (err , "create memory profile" )
0 commit comments