File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -206,18 +206,21 @@ type EmitIssueRequest struct {
206
206
// Note that the passed rule need to be converted to generic objects
207
207
// because the custom structure defined in the plugin cannot be sent via RPC.
208
208
func (c * Client ) EmitIssue (rule Rule , message string , location hcl.Range , meta Metadata ) error {
209
- src , err := ioutil .ReadFile (meta .Expr .Range ().Filename )
210
- if err != nil {
211
- return err
209
+ req := & EmitIssueRequest {
210
+ Rule : newObjectFromRule (rule ),
211
+ Message : message ,
212
+ Location : location ,
212
213
}
213
214
214
- req := & EmitIssueRequest {
215
- Rule : newObjectFromRule (rule ),
216
- Message : message ,
217
- Location : location ,
218
- Expr : meta .Expr .Range ().SliceBytes (src ),
219
- ExprRange : meta .Expr .Range (),
215
+ if meta .Expr != nil {
216
+ src , err := ioutil .ReadFile (meta .Expr .Range ().Filename )
217
+ if err != nil {
218
+ return err
219
+ }
220
+ req .Expr = meta .Expr .Range ().SliceBytes (src )
221
+ req .ExprRange = meta .Expr .Range ()
220
222
}
223
+
221
224
if err := c .rpcClient .Call ("Plugin.EmitIssue" , & req , new (interface {})); err != nil {
222
225
return err
223
226
}
You can’t perform that action at this time.
0 commit comments