MCPcopy Create free account
hub / github.com/bufbuild/buf / String

Method String

private/bufpkg/bufanalysis/file_annotation.go:94–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92}
93
94func (f *fileAnnotation) String() string {
95 if f == nil {
96 return ""
97 }
98 path := "<input>"
99 line := atLeast1(f.startLine)
100 column := atLeast1(f.startColumn)
101 message := f.message
102 if f.fileInfo != nil {
103 path = f.fileInfo.ExternalPath()
104 }
105 if message == "" {
106 message = f.typeString
107 // should never happen but just in case
108 if message == "" {
109 message = "FAILURE"
110 }
111 }
112 buffer := bytes.NewBuffer(nil)
113 _, _ = buffer.WriteString(path)
114 _, _ = buffer.WriteRune(':')
115 _, _ = buffer.WriteString(strconv.Itoa(line))
116 _, _ = buffer.WriteRune(':')
117 _, _ = buffer.WriteString(strconv.Itoa(column))
118 _, _ = buffer.WriteRune(':')
119 _, _ = buffer.WriteString(message)
120 if f.pluginName != "" || f.policyName != "" {
121 _, _ = buffer.WriteString(" (")
122 if f.pluginName != "" {
123 _, _ = buffer.WriteString(f.pluginName)
124 }
125 if f.pluginName != "" && f.policyName != "" {
126 _, _ = buffer.WriteString(", ")
127 }
128 if f.policyName != "" {
129 _, _ = buffer.WriteString(f.policyName)
130 }
131 _, _ = buffer.WriteRune(')')
132 }
133 return buffer.String()
134}
135
136func (*fileAnnotation) isFileAnnotation() {}

Callers

nothing calls this directly

Calls 3

atLeast1Function · 0.85
ExternalPathMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected