@@ -490,7 +490,7 @@ func makeDescMap(pgVersion semver.Version, metricMaps map[string]map[string]Colu
490490 log .Debugln (columnName , "is being forced to discard due to version incompatibility." )
491491 thisMap [columnName ] = MetricMap {
492492 discard : true ,
493- conversion : func (in interface {}) (float64 , bool ) {
493+ conversion : func (_ interface {}) (float64 , bool ) {
494494 return math .NaN (), true
495495 },
496496 }
@@ -499,11 +499,12 @@ func makeDescMap(pgVersion semver.Version, metricMaps map[string]map[string]Colu
499499 }
500500
501501 // Determine how to convert the column based on its usage.
502+ // nolint: dupl
502503 switch columnMapping .usage {
503504 case DISCARD , LABEL :
504505 thisMap [columnName ] = MetricMap {
505506 discard : true ,
506- conversion : func (in interface {}) (float64 , bool ) {
507+ conversion : func (_ interface {}) (float64 , bool ) {
507508 return math .NaN (), true
508509 },
509510 }
@@ -578,7 +579,9 @@ func makeDescMap(pgVersion semver.Version, metricMaps map[string]map[string]Colu
578579}
579580
580581// convert a string to the corresponding ColumnUsage
581- func stringToColumnUsage (s string ) (u ColumnUsage , err error ) {
582+ func stringToColumnUsage (s string ) (ColumnUsage , error ) {
583+ var u ColumnUsage
584+ var err error
582585 switch s {
583586 case "DISCARD" :
584587 u = DISCARD
@@ -602,7 +605,7 @@ func stringToColumnUsage(s string) (u ColumnUsage, err error) {
602605 err = fmt .Errorf ("wrong ColumnUsage given : %s" , s )
603606 }
604607
605- return
608+ return u , err
606609}
607610
608611// Convert database.sql types to float64s for Prometheus consumption. Null types are mapped to NaN. string and []byte
@@ -794,10 +797,9 @@ func queryNamespaceMapping(ch chan<- prometheus.Metric, db *sql.DB, namespace st
794797 if ! found {
795798 // I've no idea how to avoid this properly at the moment, but this is
796799 // an admin tool so you're not injecting SQL right?
797- // nolint: gas
798- rows , err = db .Query (fmt .Sprintf ("SELECT * FROM %s;" , namespace ))
800+ rows , err = db .Query (fmt .Sprintf ("SELECT * FROM %s;" , namespace )) // nolint: gas, safesql
799801 } else {
800- rows , err = db .Query (query )
802+ rows , err = db .Query (query ) // nolint: safesql
801803 }
802804 if err != nil {
803805 return []error {}, errors .New (fmt .Sprintln ("Error running query on database: " , namespace , err ))
@@ -882,7 +884,7 @@ func queryNamespaceMappings(ch chan<- prometheus.Metric, db *sql.DB, metricMap m
882884 for namespace , mapping := range metricMap {
883885 log .Debugln ("Querying namespace: " , namespace )
884886 nonFatalErrors , err := queryNamespaceMapping (ch , db , namespace , mapping , queryOverrides )
885- // Serious error - a namespace disappeard
887+ // Serious error - a namespace disappeared
886888 if err != nil {
887889 namespaceErrors [namespace ] = err
888890 log .Infoln (err )
0 commit comments