Skip to content

Commit 673908d

Browse files
committed
fixed lint errors
1 parent 4187e76 commit 673908d

10 files changed

Lines changed: 18 additions & 16 deletions

File tree

acr_controller/application/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func NewHttpApplicationClient(token string, address string, rootpath string) App
5454
}
5555

5656
func (c *httpApplicationClient) execute(ctx context.Context, url string, result interface{}) error {
57-
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
57+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
5858
if err != nil {
5959
return err
6060
}

acr_controller/service/acr_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func getCurrentRevisionFromOperation(a *application.Application) string {
180180
}
181181

182182
func (c *acrService) getRevisions(_ context.Context, a *application.Application) (string, string) {
183-
if a.Status.History == nil || len(a.Status.History) == 0 {
183+
if len(a.Status.History) == 0 {
184184
// it is first sync operation, and we have only current revision
185185
return getCurrentRevisionFromOperation(a), ""
186186
}

cmd/argocd-repo-server/commands/argocd_repo_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func NewCommand() *cobra.Command {
8181
helmRegistryMaxIndexSize string
8282
disableManifestMaxExtractedSize bool
8383
includeHiddenDirectories bool
84-
cmpUseManifestGeneratePaths bool
84+
cmpUseManifestGeneratePaths bool
8585
)
8686
command := cobra.Command{
8787
Use: cliName,

event_reporter/application/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func NewHttpApplicationClient(token string, address string, rootpath string) App
6161
}
6262

6363
func (c *httpApplicationClient) execute(ctx context.Context, url string, result interface{}) error {
64-
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
64+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
6565
if err != nil {
6666
return err
6767
}
@@ -124,12 +124,12 @@ func (c *httpApplicationClient) GetManifests(ctx context.Context, in *appclient.
124124
if in.Revision != nil {
125125
params = fmt.Sprintf("%s&revision=%s", params, *in.Revision)
126126
}
127-
if in.SourcePositions != nil && len(in.SourcePositions) > 0 {
127+
if len(in.SourcePositions) > 0 {
128128
for _, sourcePosition := range in.SourcePositions {
129129
params = fmt.Sprintf("%s&sourcePositions=%d", params, sourcePosition)
130130
}
131131
}
132-
if in.Revisions != nil && len(in.Revisions) > 0 {
132+
if len(in.Revisions) > 0 {
133133
for _, revision := range in.Revisions {
134134
params = fmt.Sprintf("%s&revisions=%s", params, revision)
135135
}

event_reporter/reporter/app_revision.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
// treats multi-sourced apps as single source and gets first revision details
1414
func getApplicationLegacyRevisionDetails(a *v1alpha1.Application, revisionsWithMetadata *utils.AppSyncRevisionsMetadata) *v1alpha1.RevisionMetadata {
15-
if revisionsWithMetadata.SyncRevisions == nil || len(revisionsWithMetadata.SyncRevisions) == 0 {
15+
if len(revisionsWithMetadata.SyncRevisions) == 0 {
1616
return nil
1717
}
1818

@@ -66,7 +66,7 @@ func (s *applicationEventReporter) getRevisionsDetails(ctx context.Context, a *v
6666
func (s *applicationEventReporter) getApplicationRevisionsMetadata(ctx context.Context, logCtx *log.Entry, a *v1alpha1.Application) (*utils.AppSyncRevisionsMetadata, error) { //nolint:golint,unparam
6767
result := &utils.AppSyncRevisionsMetadata{}
6868

69-
if a.Status.Sync.Revision != "" || a.Status.Sync.Revisions != nil || (a.Status.History != nil && len(a.Status.History) > 0) {
69+
if a.Status.Sync.Revision != "" || a.Status.Sync.Revisions != nil || len(a.Status.History) > 0 {
7070
// can be the latest revision of repository
7171
operationSyncRevisionsMetadata, err := s.getRevisionsDetails(ctx, a, utils.GetOperationSyncRevisions(a))
7272
if err != nil {

event_reporter/reporter/event_payload_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func TestGetResourceEventPayload(t *testing.T) {
7878
err = json.Unmarshal(event.Payload, &eventPayload)
7979
require.NoError(t, err)
8080

81-
assert.Equal(t, "{ \"key\" : \"manifest\" }", eventPayload.Source.DesiredManifest)
82-
assert.Equal(t, "{ \"key\" : \"manifest\" }", eventPayload.Source.ActualManifest)
81+
assert.JSONEq(t, "{ \"key\" : \"manifest\" }", eventPayload.Source.DesiredManifest)
82+
assert.JSONEq(t, "{ \"key\" : \"manifest\" }", eventPayload.Source.ActualManifest)
8383
})
8484

8585
t.Run("Deleting timestamp not empty", func(t *testing.T) {

event_reporter/utils/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func revisionsToCheck(obj RevisionsData, fieldToCheck *AppRevisionsFieldNames) b
5959
}
6060

6161
if *fieldToCheck == AppRevisionsFieldName {
62-
return obj.Revisions != nil && len(obj.Revisions) > 0
62+
return len(obj.Revisions) > 0
6363
}
6464
return true
6565
}

event_reporter/utils/app_revision.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func GetLatestAppHistoryId(a *appv1.Application) int64 {
4141
}
4242

4343
func getLatestAppHistoryItem(a *appv1.Application) *appv1.RevisionHistory {
44-
if a.Status.History != nil && len(a.Status.History) > 0 {
44+
if len(a.Status.History) > 0 {
4545
return &a.Status.History[len(a.Status.History)-1]
4646
}
4747

pkg/codefresh/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (c *CodefreshClient) SendEvent(ctx context.Context, appName string, event *
7777
return err
7878
}
7979

80-
req, err := http.NewRequestWithContext(ctx, "POST", url, io.NopCloser(&buf))
80+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, io.NopCloser(&buf))
8181
if err != nil {
8282
return err
8383
}
@@ -111,7 +111,7 @@ func (c *CodefreshClient) SendGraphQL(query GraphQLQuery) (*json.RawMessage, err
111111
return nil, err
112112
}
113113

114-
req, err := http.NewRequest("POST", c.cfConfig.BaseURL+"/2.0/api/graphql", bytes.NewBuffer(queryJSON))
114+
req, err := http.NewRequest(http.MethodPost, c.cfConfig.BaseURL+"/2.0/api/graphql", bytes.NewBuffer(queryJSON))
115115
if err != nil {
116116
return nil, err
117117
}

pkg/codefresh/client_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func TestCodefreshClient_SendEvent(t *testing.T) {
4444
authToken: "some-token",
4545
payload: []byte(`{"key": "value"}`),
4646
beforeFn: func(t *testing.T, rt *MockRoundTripper) {
47+
t.Helper()
4748
rt.On("RoundTrip", mock.Anything).Run(func(args mock.Arguments) {
4849
req := args.Get(0).(*http.Request)
4950
assert.Equal(t, "POST", req.Method, "invalid request method")
@@ -57,7 +58,7 @@ func TestCodefreshClient_SendEvent(t *testing.T) {
5758
require.NoError(t, err, "failed to read request body")
5859
assert.JSONEq(t, `{"data":{"key":"value"}}`, string(body), "invalid request body")
5960
}).Return(&http.Response{
60-
StatusCode: 200,
61+
StatusCode: http.StatusOK,
6162
}, nil)
6263
},
6364
},
@@ -67,11 +68,12 @@ func TestCodefreshClient_SendEvent(t *testing.T) {
6768
authToken: "some-token",
6869
payload: []byte(`{"key": "value"}`),
6970
beforeFn: func(t *testing.T, rt *MockRoundTripper) {
71+
t.Helper()
7072
rt.On("RoundTrip", mock.Anything).Run(func(args mock.Arguments) {
7173
req := args.Get(0).(*http.Request)
7274
assert.Equal(t, "http://some.host/2.0/api/events", req.URL.String(), "invalid request URL")
7375
}).Return(&http.Response{
74-
StatusCode: 200,
76+
StatusCode: http.StatusOK,
7577
}, nil)
7678
},
7779
},

0 commit comments

Comments
 (0)