( pathToExternalPath map[string]string, annotation *annotation, )
| 56 | } |
| 57 | |
| 58 | func annotationToFileAnnotation( |
| 59 | pathToExternalPath map[string]string, |
| 60 | annotation *annotation, |
| 61 | ) bufanalysis.FileAnnotation { |
| 62 | fileLocation := annotation.FileLocation() |
| 63 | if fileLocation == nil { |
| 64 | // We have to do this or we get a weird fileInfo != nil but it is nil thing. |
| 65 | return bufanalysis.NewFileAnnotation( |
| 66 | nil, |
| 67 | 0, |
| 68 | 0, |
| 69 | 0, |
| 70 | 0, |
| 71 | annotation.RuleID(), |
| 72 | annotation.Message(), |
| 73 | annotation.PluginName(), |
| 74 | annotation.PolicyName(), |
| 75 | ) |
| 76 | } |
| 77 | path := fileLocation.FileDescriptor().ProtoreflectFileDescriptor().Path() |
| 78 | // While it never should, it is OK if pathToExternalPath returns "" for a given path. |
| 79 | // We handle this in fileInfo. |
| 80 | fileInfo := newFileInfo(path, pathToExternalPath[path]) |
| 81 | startLine := fileLocation.StartLine() + 1 |
| 82 | startColumn := fileLocation.StartColumn() + 1 |
| 83 | endLine := fileLocation.EndLine() + 1 |
| 84 | endColumn := fileLocation.EndColumn() + 1 |
| 85 | return bufanalysis.NewFileAnnotation( |
| 86 | fileInfo, |
| 87 | startLine, |
| 88 | startColumn, |
| 89 | endLine, |
| 90 | endColumn, |
| 91 | annotation.RuleID(), |
| 92 | annotation.Message(), |
| 93 | annotation.PluginName(), |
| 94 | annotation.PolicyName(), |
| 95 | ) |
| 96 | } |
no test coverage detected
searching dependent graphs…