Skip to content

Commit 7bedafb

Browse files
committed
refactor: remove bool output for detectAttribute
1 parent 9b5d8ce commit 7bedafb

File tree

1 file changed

+6
-6
lines changed
  • pkg/fanal/analyzer/language/c/conan

1 file changed

+6
-6
lines changed

pkg/fanal/analyzer/language/c/conan/conan.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ func licensesFromCache() (map[string]string, error) {
109109
line := strings.TrimSpace(scanner.Text())
110110

111111
// cf. https://docs.conan.io/1/reference/conanfile/attributes.html#name
112-
if n, ok := detectAttribute("name", line); ok {
112+
if n := detectAttribute("name", line); n != "" {
113113
name = n
114114
// Check that the license is already found
115115
if license != "" {
116116
break
117117
}
118118
}
119119
// cf. https://docs.conan.io/1/reference/conanfile/attributes.html#license
120-
if l, ok := detectAttribute("license", line); ok {
120+
if l := detectAttribute("license", line); l != "" {
121121
license = l
122122
// Check that the name is already found
123123
if name != "" {
@@ -141,18 +141,18 @@ func licensesFromCache() (map[string]string, error) {
141141

142142
// detectAttribute detects conan attribute (name, license, etc.) from line
143143
// cf. https://docs.conan.io/1/reference/conanfile/attributes.html
144-
func detectAttribute(attributeName, line string) (string, bool) {
144+
func detectAttribute(attributeName, line string) string {
145145
if !strings.HasPrefix(line, attributeName) {
146-
return "", false
146+
return ""
147147
}
148148

149149
// e.g. `license = "Apache or MIT"` -> ` "Apache or MIT"` -> `"Apache or MIT"` -> `Apache or MIT`
150150
if name, v, ok := strings.Cut(line, "="); ok && strings.TrimSpace(name) == attributeName {
151151
attr := strings.TrimSpace(v)
152-
return strings.TrimPrefix(strings.TrimSuffix(attr, "\""), "\""), true
152+
return strings.TrimPrefix(strings.TrimSuffix(attr, "\""), "\"")
153153
}
154154

155-
return "", false
155+
return ""
156156
}
157157

158158
func (a conanLockAnalyzer) Required(filePath string, _ os.FileInfo) bool {

0 commit comments

Comments
 (0)