Skip to content

Commit 471f47a

Browse files
author
Kostas Petrakis
committed
chore(golang): fix linting errors after upgrade
1 parent d1da8b2 commit 471f47a

File tree

6 files changed

+36
-36
lines changed

6 files changed

+36
-36
lines changed

backend/core/migration/linter/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func firstLineFromFile(path string) string {
5151
for scanner.Scan() {
5252
return scanner.Text()
5353
}
54-
panic(fmt.Errorf("empty file: " + path))
54+
panic(fmt.Errorf("empty file: %s", path))
5555
}
5656

5757
const (

backend/helpers/srvhelper/scope_service_helper.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -268,39 +268,39 @@ func (scopeSrv *ScopeSrvHelper[C, S, SC]) getAffectedTables() ([]string, errors.
268268
if err != nil {
269269
return nil, err
270270
}
271-
if pluginModel, ok := meta.(plugin.PluginModel); !ok {
271+
pluginModel, ok := meta.(plugin.PluginModel)
272+
if !ok {
272273
panic(errors.Default.New(fmt.Sprintf("plugin \"%s\" does not implement listing its tables", scopeSrv.pluginName)))
273-
} else {
274-
// Unfortunately, can't cache the tables because Python creates some tables on a per-demand basis, so such a cache would possibly get outdated.
275-
// It's a rare scenario in practice, but might as well play it safe and sacrifice some performance here
276-
var allTables []string
277-
if allTables, err = scopeSrv.db.AllTables(); err != nil {
278-
return nil, err
279-
}
280-
// collect raw tables
281-
for _, table := range allTables {
282-
if strings.HasPrefix(table, "_raw_"+scopeSrv.pluginName) {
283-
tables = append(tables, table)
284-
}
274+
}
275+
// Unfortunately, can't cache the tables because Python creates some tables on a per-demand basis, so such a cache would possibly get outdated.
276+
// It's a rare scenario in practice, but might as well play it safe and sacrifice some performance here
277+
var allTables []string
278+
if allTables, err = scopeSrv.db.AllTables(); err != nil {
279+
return nil, err
280+
}
281+
// collect raw tables
282+
for _, table := range allTables {
283+
if strings.HasPrefix(table, "_raw_"+scopeSrv.pluginName) {
284+
tables = append(tables, table)
285285
}
286-
// collect tool tables
287-
toolModels := pluginModel.GetTablesInfo()
288-
for _, toolModel := range toolModels {
289-
if !isScopeModel(toolModel) && hasField(toolModel, "RawDataParams") {
290-
tables = append(tables, toolModel.TableName())
291-
}
286+
}
287+
// collect tool tables
288+
toolModels := pluginModel.GetTablesInfo()
289+
for _, toolModel := range toolModels {
290+
if !isScopeModel(toolModel) && hasField(toolModel, "RawDataParams") {
291+
tables = append(tables, toolModel.TableName())
292292
}
293-
// collect domain tables
294-
for _, domainModel := range domaininfo.GetDomainTablesInfo() {
295-
// we only care about tables with RawOrigin
296-
ok = hasField(domainModel, "RawDataParams")
297-
if ok {
298-
tables = append(tables, domainModel.TableName())
299-
}
293+
}
294+
// collect domain tables
295+
for _, domainModel := range domaininfo.GetDomainTablesInfo() {
296+
// we only care about tables with RawOrigin
297+
ok = hasField(domainModel, "RawDataParams")
298+
if ok {
299+
tables = append(tables, domainModel.TableName())
300300
}
301-
// additional tables
302-
tables = append(tables, models.CollectorLatestState{}.TableName())
303301
}
302+
// additional tables
303+
tables = append(tables, models.CollectorLatestState{}.TableName())
304304
scopeSrv.log.Debug("Discovered %d tables used by plugin \"%s\": %v", len(tables), scopeSrv.pluginName, tables)
305305
return tables, nil
306306
}

backend/impls/logruslog/init.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ func init() {
7070
if basePath == "" {
7171
basePath = "./logs"
7272
}
73-
if abs, err := filepath.Abs(basePath); err != nil {
73+
abs, err := filepath.Abs(basePath)
74+
if err != nil {
7475
panic(err)
75-
} else {
76-
basePath = filepath.Join(abs, "devlake.log")
7776
}
77+
basePath = filepath.Join(abs, "devlake.log")
7878
var err errors.Error
7979
Global, err = NewDefaultLogger(inner)
8080
if err != nil {

backend/impls/logruslog/logger.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ func (l *DefaultLogger) Info(format string, a ...interface{}) {
7272
}
7373

7474
func (l *DefaultLogger) Warn(err error, format string, a ...interface{}) {
75-
l.Log(log.LOG_WARN, formatMessage(err, format, a...))
75+
l.Log(log.LOG_WARN, "%s", formatMessage(err, format, a...))
7676
}
7777

7878
func (l *DefaultLogger) Error(err error, format string, a ...interface{}) {
79-
l.Log(log.LOG_ERROR, formatMessage(err, format, a...))
79+
l.Log(log.LOG_ERROR, "%s", formatMessage(err, format, a...))
8080
}
8181

8282
func (l *DefaultLogger) SetStream(config *log.LoggerStreamConfig) {

backend/plugins/github_graphql/tasks/issue_extractor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func convertGithubIssue(milestoneMap map[int]int, issue *GraphqlQueryIssue, conn
143143
GithubCreatedAt: issue.CreatedAt,
144144
GithubUpdatedAt: issue.UpdatedAt,
145145
}
146-
if issue.AssigneeList.Assignees != nil && len(issue.AssigneeList.Assignees) > 0 {
146+
if len(issue.AssigneeList.Assignees) > 0 {
147147
githubIssue.AssigneeId = issue.AssigneeList.Assignees[0].Id
148148
githubIssue.AssigneeName = issue.AssigneeList.Assignees[0].Login
149149
}

backend/server/api/shared/api_output.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func ApiOutputSuccess(c *gin.Context, body interface{}, status int) {
124124
func ApiOutputAbort(c *gin.Context, err error) {
125125
if e, ok := err.(errors.Error); ok {
126126
logruslog.Global.Error(err, "HTTP %d abort-error", e.GetType().GetHttpCode())
127-
_ = c.AbortWithError(e.GetType().GetHttpCode(), fmt.Errorf(e.Messages().Format()))
127+
_ = c.AbortWithError(e.GetType().GetHttpCode(), fmt.Errorf("%s", e.Messages().Format()))
128128
} else {
129129
logruslog.Global.Error(err, "HTTP %d abort-error (native)", http.StatusInternalServerError)
130130
_ = c.AbortWithError(http.StatusInternalServerError, err)

0 commit comments

Comments
 (0)