@@ -854,36 +854,33 @@ func (f *file) RunChecks(ctx context.Context) {
854854 f .cancelChecks = cancel
855855
856856 go func () {
857- image , diagnostics := buildImage (ctx , path , f .lsp .logger , opener )
858- if image == nil {
859- f .lsp .logger .DebugContext (ctx , "checks cancelled on image build" , slog .String ("uri" , f .uri .Filename ()))
860- return
861- }
862-
863- f .lsp .logger .DebugContext (ctx , "checks running lint" , slog .String ("uri" , f .uri .Filename ()), slog .String ("module" , module .OpaqueID ()))
864857 var annotations []bufanalysis.FileAnnotation
865- if err := checkClient .Lint (
866- ctx ,
867- workspace .GetLintConfigForOpaqueID (module .OpaqueID ()),
868- image ,
869- bufcheck .WithPluginConfigs (workspace .PluginConfigs ()... ),
870- bufcheck .WithPolicyConfigs (workspace .PolicyConfigs ()... ),
871- ); err != nil {
872- var fileAnnotationSet bufanalysis.FileAnnotationSet
873- if ! errors .As (err , & fileAnnotationSet ) {
874- if errors .Is (err , context .Canceled ) {
875- f .lsp .logger .DebugContext (ctx , "checks cancelled" , slog .String ("uri" , f .uri .Filename ()), xslog .ErrorAttr (err ))
876- } else if errors .Is (err , context .DeadlineExceeded ) {
877- f .lsp .logger .WarnContext (ctx , "checks deadline exceeded" , slog .String ("uri" , f .uri .Filename ()), xslog .ErrorAttr (err ))
858+ image , diagnostics := buildImage (ctx , path , f .lsp .logger , opener )
859+ if image != nil {
860+ f .lsp .logger .DebugContext (ctx , "checks running lint" , slog .String ("uri" , f .uri .Filename ()), slog .String ("module" , module .OpaqueID ()))
861+ if err := checkClient .Lint (
862+ ctx ,
863+ workspace .GetLintConfigForOpaqueID (module .OpaqueID ()),
864+ image ,
865+ bufcheck .WithPluginConfigs (workspace .PluginConfigs ()... ),
866+ bufcheck .WithPolicyConfigs (workspace .PolicyConfigs ()... ),
867+ ); err != nil {
868+ var fileAnnotationSet bufanalysis.FileAnnotationSet
869+ if ! errors .As (err , & fileAnnotationSet ) {
870+ if errors .Is (err , context .Canceled ) {
871+ f .lsp .logger .DebugContext (ctx , "checks cancelled" , slog .String ("uri" , f .uri .Filename ()), xslog .ErrorAttr (err ))
872+ } else if errors .Is (err , context .DeadlineExceeded ) {
873+ f .lsp .logger .WarnContext (ctx , "checks deadline exceeded" , slog .String ("uri" , f .uri .Filename ()), xslog .ErrorAttr (err ))
874+ } else {
875+ f .lsp .logger .WarnContext (ctx , "checks failed" , slog .String ("uri" , f .uri .Filename ()), xslog .ErrorAttr (err ))
876+ }
877+ return
878+ }
879+ if len (fileAnnotationSet .FileAnnotations ()) == 0 {
880+ f .lsp .logger .DebugContext (ctx , "checks lint passed" , slog .String ("uri" , f .uri .Filename ()))
878881 } else {
879- f . lsp . logger . WarnContext ( ctx , "checks failed" , slog . String ( "uri" , f . uri . Filename ()), xslog . ErrorAttr ( err ) )
882+ annotations = append ( annotations , fileAnnotationSet . FileAnnotations () ... )
880883 }
881- return
882- }
883- if len (fileAnnotationSet .FileAnnotations ()) == 0 {
884- f .lsp .logger .DebugContext (ctx , "checks lint passed" , slog .String ("uri" , f .uri .Filename ()))
885- } else {
886- annotations = append (annotations , fileAnnotationSet .FileAnnotations ()... )
887884 }
888885 }
889886
0 commit comments