Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: upgrade golangci-lint to v1.46.0#1373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
coadler merged 2 commits intomainfromcolin/lint-v160
May 10, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion.github/workflows/coder.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,7 +42,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.1.0
with:
version: v1.45.2
version: v1.46.0

style-lint-typescript:
name: "style/lint/typescript"
Expand Down
11 changes: 9 additions & 2 deletions.golangci.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ linters-settings:
# - sloppyReassign
- sloppyTypeAssert
- sortSlice
#- sprintfQuotedString
- sprintfQuotedString
- sqlQuery
# - stringConcatSimplify
# - stringXbytes
Expand DownExpand Up@@ -105,6 +105,13 @@ linters-settings:
failOn: all
rules: rules.go

staticcheck:
# https://staticcheck.io/docs/options#checks
# We disable SA1019 because it gets angry about our usage of xerrors. We
# intentionally xerrors because stack frame support didn't make it into the
# stdlib port.
checks: ["all", "-SA1019"]

goimports:
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder

Expand DownExpand Up@@ -235,7 +242,7 @@ linters:
# without testing any exported functions. This is enabled to promote
# decomposing a package before testing it's internals. A function caller
# should be able to test most of the functionality from exported functions.
#
#
# There are edge-cases to this rule, but they should be carefully considered
# to avoid structural inconsistency.
- testpackage
Expand Down
2 changes: 1 addition & 1 deletioncli/gitssh_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,7 @@ func TestGitSSH(t *testing.T) {

// start workspace agent
cmd, root := clitest.New(t, "agent", "--agent-token", agentToken, "--agent-url", client.URL.String())
agentClient :=&*client
agentClient := client
clitest.SetupConfig(t, agentClient, root)
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
Expand Down
31 changes: 0 additions & 31 deletionscli/ssh.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,10 +3,8 @@ package cli
import (
"context"
"io"
"net"
"os"
"strings"
"time"

"github.com/google/uuid"
"github.com/mattn/go-isatty"
Expand DownExpand Up@@ -181,32 +179,3 @@ func ssh() *cobra.Command {

return cmd
}

type stdioConn struct {
io.Reader
io.Writer
}

func (*stdioConn) Close() (err error) {
return nil
}

func (*stdioConn) LocalAddr() net.Addr {
return nil
}

func (*stdioConn) RemoteAddr() net.Addr {
return nil
}

func (*stdioConn) SetDeadline(_ time.Time) error {
return nil
}

func (*stdioConn) SetReadDeadline(_ time.Time) error {
return nil
}

func (*stdioConn) SetWriteDeadline(_ time.Time) error {
return nil
}
15 changes: 1 addition & 14 deletionscoderd/audit/backends/postgres.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,20 +31,7 @@ func (b *postgresBackend) Decision() audit.FilterDecision {
}

func (b *postgresBackend) Export(ctx context.Context, alog database.AuditLog) error {
_, err := b.db.InsertAuditLog(ctx, database.InsertAuditLogParams{
ID: alog.ID,
Time: alog.Time,
UserID: alog.UserID,
OrganizationID: alog.OrganizationID,
Ip: alog.Ip,
UserAgent: alog.UserAgent,
ResourceType: alog.ResourceType,
ResourceID: alog.ResourceID,
ResourceTarget: alog.ResourceTarget,
Action: alog.Action,
Diff: alog.Diff,
StatusCode: alog.StatusCode,
})
_, err := b.db.InsertAuditLog(ctx, database.InsertAuditLogParams(alog))
if err != nil {
return xerrors.Errorf("insert audit log: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletionscoderd/coderdtest/coderdtest.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,9 +77,9 @@ func New(t *testing.T, options *Options) *codersdk.Client {
db := databasefake.New()
pubsub := database.NewPubsubInMemory()
if os.Getenv("DB") != "" {
connectionURL,close, err := postgres.Open()
connectionURL,closePg, err := postgres.Open()
require.NoError(t, err)
t.Cleanup(close)
t.Cleanup(closePg)
sqlDB, err := sql.Open("postgres", connectionURL)
require.NoError(t, err)
t.Cleanup(func() {
Expand Down
15 changes: 1 addition & 14 deletionscoderd/database/databasefake/databasefake.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1733,20 +1733,7 @@ func (q *fakeQuerier) InsertAuditLog(_ context.Context, arg database.InsertAudit
q.mutex.Lock()
defer q.mutex.Unlock()

alog := database.AuditLog{
ID: arg.ID,
Time: arg.Time,
UserID: arg.UserID,
OrganizationID: arg.OrganizationID,
Ip: arg.Ip,
UserAgent: arg.UserAgent,
ResourceType: arg.ResourceType,
ResourceID: arg.ResourceID,
ResourceTarget: arg.ResourceTarget,
Action: arg.Action,
Diff: arg.Diff,
StatusCode: arg.StatusCode,
}
alog := database.AuditLog(arg)

q.auditLogs = append(q.auditLogs, alog)
slices.SortFunc(q.auditLogs, func(a, b database.AuditLog) bool {
Expand Down
7 changes: 3 additions & 4 deletionscoderd/database/postgres/postgres_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,12 +6,11 @@ import (
"database/sql"
"testing"

_ "github.com/lib/pq"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"

"github.com/coder/coder/coderd/database/postgres"

_ "github.com/lib/pq"
)

func TestMain(m *testing.M) {
Expand All@@ -26,9 +25,9 @@ func TestPostgres(t *testing.T) {
return
}

connect,close, err := postgres.Open()
connect,closePg, err := postgres.Open()
require.NoError(t, err)
deferclose()
deferclosePg()
db, err := sql.Open("postgres", connect)
require.NoError(t, err)
err = db.Ping()
Expand Down
8 changes: 4 additions & 4 deletionscoderd/database/pubsub_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,9 +27,9 @@ func TestPubsub(t *testing.T) {
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()

connectionURL,close, err := postgres.Open()
connectionURL,closePg, err := postgres.Open()
require.NoError(t, err)
deferclose()
deferclosePg()
db, err := sql.Open("postgres", connectionURL)
require.NoError(t, err)
defer db.Close()
Expand All@@ -56,9 +56,9 @@ func TestPubsub(t *testing.T) {
t.Parallel()
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
connectionURL,close, err := postgres.Open()
connectionURL,closePg, err := postgres.Open()
require.NoError(t, err)
deferclose()
deferclosePg()
db, err := sql.Open("postgres", connectionURL)
require.NoError(t, err)
defer db.Close()
Expand Down
2 changes: 1 addition & 1 deletioncoderd/httpmw/oauth2.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,7 +48,7 @@ func ExtractOAuth2(config OAuth2Config) func(http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
if config == nil {
httpapi.Write(rw, http.StatusPreconditionRequired, httpapi.Response{
Message:fmt.Sprintf("The oauth2 method requested is not configured!"),
Message: "The oauth2 method requested is not configured!",
})
return
}
Expand Down
3 changes: 1 addition & 2 deletionscoderd/members.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@ package coderd

import (
"context"
"fmt"
"net/http"

"github.com/google/uuid"
Expand All@@ -29,7 +28,7 @@ func (api *api) putMemberRoles(rw http.ResponseWriter, r *http.Request) {
//the selected organization. Until then, allow anarchy
if apiKey.UserID != user.ID {
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
Message:fmt.Sprintf("modifying other users is not supported at this time"),
Message: "modifying other users is not supported at this time",
})
return
}
Expand Down
2 changes: 1 addition & 1 deletioncoderd/rbac/authz.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ func (a RegoAuthorizer) Authorize(ctx context.Context, subjectID string, roles [

results, err := a.query.Eval(ctx, rego.EvalInput(input))
if err != nil {
return ForbiddenWithInternal(xerrors.Errorf("eval rego: %w, err"), input, results)
return ForbiddenWithInternal(xerrors.Errorf("eval rego: %w", err), input, results)
}

if len(results) != 1 {
Expand Down
2 changes: 1 addition & 1 deletioncoderd/userauth.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,7 +58,7 @@ func (api *api) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
}
if selectedMembership == nil {
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
Message:fmt.Sprintf("You aren't a member of the authorized Github organizations!"),
Message: "You aren't a member of the authorized Github organizations!",
})
return
}
Expand Down
4 changes: 2 additions & 2 deletionscoderd/users.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,7 +266,7 @@ func (api *api) putUserProfile(rw http.ResponseWriter, r *http.Request) {
})
}
httpapi.Write(rw, http.StatusConflict, httpapi.Response{
Message:fmt.Sprintf("user already exists"),
Message: "user already exists",
Errors: responseErrors,
})
return
Expand DownExpand Up@@ -391,7 +391,7 @@ func (api *api) putUserRoles(rw http.ResponseWriter, r *http.Request) {
apiKey := httpmw.APIKey(r)
if apiKey.UserID != user.ID {
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
Message:fmt.Sprintf("modifying other users is not supported at this time"),
Message: "modifying other users is not supported at this time",
})
return
}
Expand Down
2 changes: 1 addition & 1 deletioncoderd/workspaces.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -213,7 +213,7 @@ func (api *api) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
return xerrors.Errorf("insert provisioner job: %w", err)
}
state := createBuild.ProvisionerState
ifstate == nil ||len(state) == 0 {
if len(state) == 0 {
state = priorHistory.ProvisionerState
}

Expand Down
2 changes: 1 addition & 1 deletioncodersdk/users.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -307,7 +307,7 @@ func (c *Client) userByIdentifier(ctx context.Context, ident string) (User, erro
// Users returns all users according to the request parameters. If no parameters are set,
// the default behavior is to return all users in a single page.
func (c *Client) Users(ctx context.Context, req UsersRequest) ([]User, error) {
res, err := c.request(ctx, http.MethodGet,fmt.Sprintf("/api/v2/users"), nil,
res, err := c.request(ctx, http.MethodGet, "/api/v2/users", nil,
req.Pagination.asRequestOption(),
func(r *http.Request) {
q := r.URL.Query()
Expand Down
2 changes: 1 addition & 1 deletionscripts/apitypings/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -176,7 +176,7 @@ func (g *Generator) generateAll() (*TypescriptTypes, error) {
st, _ := obj.Type().Underlying().(*types.Struct)
codeBlock, err := g.buildStruct(obj, st)
if err != nil {
return nil, xerrors.Errorf("generate %q: %w", obj.Name())
return nil, xerrors.Errorf("generate %q: %w", obj.Name(), err)
}
structs[obj.Name()] = codeBlock
case *types.Basic:
Expand Down
2 changes: 1 addition & 1 deletionscripts/datadog-cireport/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,7 +75,7 @@ func main() {
"service": "coder",
"_dd.cireport_version": "2",

"test.traits": fmt.Sprintf(`{"database":["%s"], "category":["%s"]}`,
"test.traits": fmt.Sprintf(`{"database":[%q], "category":[%q]}`,
os.Getenv("DD_DATABASE"), os.Getenv("DD_CATEGORY")),

// Additional tags found in DataDog docs. See:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp