fix: resolve wsl_v5, lll, noinlineerr, and gosec lint issues
This commit is contained in:
@@ -114,7 +114,7 @@ func (c *Client) PollMessages(afterID string, timeout int) ([]Message, error) {
|
||||
|
||||
req.Header.Set("Authorization", "Bearer "+c.Token)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
resp, err := client.Do(req) //nolint:gosec // G704: BaseURL is set by user at connect time, not tainted input
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -88,7 +88,8 @@ func NewTest(dsn string) (*Database, error) {
|
||||
}
|
||||
|
||||
// Item 9: Enable foreign keys
|
||||
if _, err := d.ExecContext(context.Background(), "PRAGMA foreign_keys = ON"); err != nil {
|
||||
_, err = d.ExecContext(context.Background(), "PRAGMA foreign_keys = ON")
|
||||
if err != nil {
|
||||
_ = d.Close()
|
||||
|
||||
return nil, fmt.Errorf("enable foreign keys: %w", err)
|
||||
@@ -434,6 +435,7 @@ func (s *Database) AckMessages(
|
||||
args[i] = id
|
||||
}
|
||||
|
||||
//nolint:gosec // G201: placeholders are all "?" literals, not user input
|
||||
query := fmt.Sprintf(
|
||||
"DELETE FROM message_queue WHERE id IN (%s)",
|
||||
strings.Join(placeholders, ","),
|
||||
|
||||
@@ -64,6 +64,7 @@ func (s *Handlers) HandleCreateSession() http.HandlerFunc {
|
||||
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req request
|
||||
|
||||
err := json.NewDecoder(r.Body).Decode(&req)
|
||||
if err != nil {
|
||||
s.respondJSON(w, r, map[string]string{"error": "invalid request"}, http.StatusBadRequest)
|
||||
@@ -166,6 +167,7 @@ func (s *Handlers) HandleChannelMembers() http.HandlerFunc {
|
||||
|
||||
var chID string
|
||||
|
||||
//nolint:gosec // G701: parameterized query with ? placeholder, not injection
|
||||
err := s.params.Database.GetDB().QueryRowContext(r.Context(),
|
||||
"SELECT id FROM channels WHERE name = ?", name).Scan(&chID)
|
||||
if err != nil {
|
||||
@@ -304,6 +306,7 @@ func (s *Handlers) handlePrivmsg(w http.ResponseWriter, r *http.Request, uid, ni
|
||||
// Channel message.
|
||||
var chID string
|
||||
|
||||
//nolint:gosec // G701: parameterized query, not injection
|
||||
err := s.params.Database.GetDB().QueryRowContext(r.Context(),
|
||||
"SELECT id FROM channels WHERE name = ?", to).Scan(&chID)
|
||||
if err != nil {
|
||||
@@ -387,6 +390,7 @@ func (s *Handlers) handlePart(w http.ResponseWriter, r *http.Request, uid, to st
|
||||
|
||||
var chID string
|
||||
|
||||
//nolint:gosec // G701: parameterized query, not injection
|
||||
err := s.params.Database.GetDB().QueryRowContext(r.Context(),
|
||||
"SELECT id FROM channels WHERE name = ?", channel).Scan(&chID)
|
||||
if err != nil {
|
||||
@@ -494,6 +498,7 @@ func (s *Handlers) HandleGetHistory() http.HandlerFunc {
|
||||
// Channel history — look up channel by name to get its ID for target matching.
|
||||
var chID string
|
||||
|
||||
//nolint:gosec // G701: parameterized query, not injection
|
||||
err := s.params.Database.GetDB().QueryRowContext(r.Context(),
|
||||
"SELECT id FROM channels WHERE name = ?", target).Scan(&chID)
|
||||
if err != nil {
|
||||
|
||||
@@ -56,8 +56,11 @@ func (b *Base) GetUserLookup() UserLookup { //nolint:ireturn // intentional inte
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetChannelLookup returns the DB as a ChannelLookup if it implements the interface.
|
||||
func (b *Base) GetChannelLookup() ChannelLookup { //nolint:ireturn // intentional interface return for dependency inversion
|
||||
// GetChannelLookup returns the DB as a ChannelLookup
|
||||
// if it implements the interface.
|
||||
//
|
||||
//nolint:ireturn // intentional interface return for dependency inversion
|
||||
func (b *Base) GetChannelLookup() ChannelLookup {
|
||||
if cl, ok := b.db.(ChannelLookup); ok {
|
||||
return cl
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user