Skip to content

Commit

Permalink
Run gofmt -s on all our code
Browse files Browse the repository at this point in the history
Summary:
Realized that goimports doesn't run the simplify option on gofmt.
So I ran it manually and enabled it as part of golangci-lint.

Test Plan: Ran gofmt -s

Reviewers: zasgar, michelle

Reviewed By: michelle

Signed-off-by: Vihang Mehta <vihang@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D12423

GitOrigin-RevId: b4a35637a14938e2ceed9ddc150603a3df7184c2
  • Loading branch information
vihangm authored and copybaranaut committed Oct 18, 2022
1 parent 138c673 commit f3b6359
Show file tree
Hide file tree
Showing 20 changed files with 224 additions and 223 deletions.
5 changes: 3 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ linters:
- asciicheck
- deadcode
- errcheck
# Although goimports includes gofmt, it doesn't support the simplify option.
# So we include gofmt here.
- gofmt
- gosimple
- ineffassign
- makezero
Expand All @@ -37,8 +40,6 @@ linters:
# - wastedassign
- whitespace
disable:
# We run goimports which includes gofmt.
- gofmt
# The following linters are run separately by arcanist at the moment.
# This is because we have autofix hooks for these linters.
- goimports
Expand Down
2 changes: 1 addition & 1 deletion src/cloud/api/controllers/auth_grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestAuthServer_LoginAPIKey(t *testing.T) {
_, mockClients, cleanup := testutils.CreateTestAPIEnv(t)
defer cleanup()
md := map[string][]string{
"pixie-api-key": []string{"test-token"},
"pixie-api-key": {"test-token"},
}

ctx := metadata.NewIncomingContext(context.Background(), md)
Expand Down
4 changes: 2 additions & 2 deletions src/cloud/api/controllers/org_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@ func TestOrgSettingsResolver_IDEConfigs(t *testing.T) {
}).
Return(&cloudpb.GetOrgIDEConfigsResponse{
Configs: []*cloudpb.IDEConfig{
&cloudpb.IDEConfig{
{
IDEName: "test",
Path: "subl://{{symbol}}",
},
&cloudpb.IDEConfig{
{
IDEName: "anothertest",
Path: "test://{{symbol}}",
},
Expand Down
8 changes: 4 additions & 4 deletions src/cloud/api/controllers/org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,11 @@ func TestOrganizationServiceServer_GetOrgIDEConfigs(t *testing.T) {
OrgID: utils.ProtoFromUUIDStrOrNil("6ba7b810-9dad-11d1-80b4-00c04fd430c8"),
}).Return(&profilepb.GetOrgIDEConfigsResponse{
Configs: []*profilepb.IDEConfig{
&profilepb.IDEConfig{
{
IDEName: "test",
Path: "test://{{symbol}}",
},
&profilepb.IDEConfig{
{
IDEName: "another-test",
Path: "sublime://{{symbol}}",
},
Expand All @@ -461,11 +461,11 @@ func TestOrganizationServiceServer_GetOrgIDEConfigs(t *testing.T) {

require.NoError(t, err)
assert.Equal(t, []*cloudpb.IDEConfig{
&cloudpb.IDEConfig{
{
IDEName: "test",
Path: "test://{{symbol}}",
},
&cloudpb.IDEConfig{
{
IDEName: "another-test",
Path: "sublime://{{symbol}}",
},
Expand Down
8 changes: 4 additions & 4 deletions src/cloud/api/controllers/plugin_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestPluginResolver_Plugins(t *testing.T) {
Kind: cloudpb.PK_RETENTION,
}).Return(&cloudpb.GetPluginsResponse{
Plugins: []*cloudpb.Plugin{
&cloudpb.Plugin{
{
Name: "Test Plugin",
Id: "test-plugin",
Description: "Here is a plugin that is used for this test",
Expand All @@ -50,7 +50,7 @@ func TestPluginResolver_Plugins(t *testing.T) {
RetentionEnabled: false,
EnabledVersion: "",
},
&cloudpb.Plugin{
{
Name: "Another Plugin",
Id: "another-plugin",
Description: "Here is a another plugin that is used for this test",
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestPluginResolver_RetentionScripts(t *testing.T) {

mockClients.MockPlugin.EXPECT().GetRetentionScripts(gomock.Any(), &cloudpb.GetRetentionScriptsRequest{}).Return(&cloudpb.GetRetentionScriptsResponse{
Scripts: []*cloudpb.RetentionScript{
&cloudpb.RetentionScript{
{
ScriptID: utils.ProtoFromUUIDStrOrNil("1ba7b810-9dad-11d1-80b4-00c04fd430c8"),
ScriptName: "Test Script",
Description: "This is a script",
Expand All @@ -332,7 +332,7 @@ func TestPluginResolver_RetentionScripts(t *testing.T) {
Enabled: true,
IsPreset: false,
},
&cloudpb.RetentionScript{
{
ScriptID: utils.ProtoFromUUIDStrOrNil("1ba7b810-9dad-11d1-80b4-00c04fd430c1"),
ScriptName: "Another Script",
Description: "This is another script",
Expand Down
28 changes: 14 additions & 14 deletions src/cloud/api/controllers/plugins_grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ func TestGetPlugins(t *testing.T) {
name: "regular user",
ctx: CreateTestContext(),
allPlugins: []*pluginpb.Plugin{
&pluginpb.Plugin{
{
Name: "Test Plugin",
ID: "test-plugin",
Description: "Here is a plugin that is used for this test",
Logo: "",
LatestVersion: "2.0.0",
RetentionEnabled: true,
},
&pluginpb.Plugin{
{
Name: "Another Plugin",
ID: "another-plugin",
Description: "Here is a another plugin that is used for this test",
Expand All @@ -65,7 +65,7 @@ func TestGetPlugins(t *testing.T) {
},
},
orgRetentionPlugins: []*pluginpb.GetRetentionPluginsForOrgResponse_PluginState{
&pluginpb.GetRetentionPluginsForOrgResponse_PluginState{
{
Plugin: &pluginpb.Plugin{
Name: "Another Plugin",
ID: "another-plugin",
Expand All @@ -78,7 +78,7 @@ func TestGetPlugins(t *testing.T) {
},
},
expectedPlugins: []*cloudpb.Plugin{
&cloudpb.Plugin{
{
Name: "Test Plugin",
Id: "test-plugin",
Description: "Here is a plugin that is used for this test",
Expand All @@ -88,7 +88,7 @@ func TestGetPlugins(t *testing.T) {
RetentionEnabled: false,
EnabledVersion: "",
},
&cloudpb.Plugin{
{
Name: "Another Plugin",
Id: "another-plugin",
Description: "Here is a another plugin that is used for this test",
Expand All @@ -104,15 +104,15 @@ func TestGetPlugins(t *testing.T) {
name: "API user",
ctx: CreateAPIUserTestContext(),
allPlugins: []*pluginpb.Plugin{
&pluginpb.Plugin{
{
Name: "Test Plugin",
ID: "test-plugin",
Description: "Here is a plugin that is used for this test",
Logo: "",
LatestVersion: "2.0.0",
RetentionEnabled: true,
},
&pluginpb.Plugin{
{
Name: "Another Plugin",
ID: "another-plugin",
Description: "Here is a another plugin that is used for this test",
Expand All @@ -122,7 +122,7 @@ func TestGetPlugins(t *testing.T) {
},
},
orgRetentionPlugins: []*pluginpb.GetRetentionPluginsForOrgResponse_PluginState{
&pluginpb.GetRetentionPluginsForOrgResponse_PluginState{
{
Plugin: &pluginpb.Plugin{
Name: "Another Plugin",
ID: "another-plugin",
Expand All @@ -135,7 +135,7 @@ func TestGetPlugins(t *testing.T) {
},
},
expectedPlugins: []*cloudpb.Plugin{
&cloudpb.Plugin{
{
Name: "Test Plugin",
Id: "test-plugin",
Description: "Here is a plugin that is used for this test",
Expand All @@ -145,7 +145,7 @@ func TestGetPlugins(t *testing.T) {
RetentionEnabled: false,
EnabledVersion: "",
},
&cloudpb.Plugin{
{
Name: "Another Plugin",
Id: "another-plugin",
Description: "Here is a another plugin that is used for this test",
Expand Down Expand Up @@ -342,7 +342,7 @@ func TestGetRetentionScripts(t *testing.T) {
mockClients.MockDataRetentionPlugin.EXPECT().GetRetentionScripts(gomock.Any(), mockReq).
Return(&pluginpb.GetRetentionScriptsResponse{
Scripts: []*pluginpb.RetentionScript{
&pluginpb.RetentionScript{
{
ScriptID: utils.ProtoFromUUIDStrOrNil("1ba7b810-9dad-11d1-80b4-00c04fd430c8"),
ScriptName: "Test Script",
Description: "This is a script",
Expand All @@ -355,7 +355,7 @@ func TestGetRetentionScripts(t *testing.T) {
Enabled: true,
IsPreset: false,
},
&pluginpb.RetentionScript{
{
ScriptID: utils.ProtoFromUUIDStrOrNil("1ba7b810-9dad-11d1-80b4-00c04fd430c1"),
ScriptName: "Another Script",
Description: "This is another script",
Expand All @@ -379,7 +379,7 @@ func TestGetRetentionScripts(t *testing.T) {

assert.Equal(t, &cloudpb.GetRetentionScriptsResponse{
Scripts: []*cloudpb.RetentionScript{
&cloudpb.RetentionScript{
{
ScriptID: utils.ProtoFromUUIDStrOrNil("1ba7b810-9dad-11d1-80b4-00c04fd430c8"),
ScriptName: "Test Script",
Description: "This is a script",
Expand All @@ -392,7 +392,7 @@ func TestGetRetentionScripts(t *testing.T) {
Enabled: true,
IsPreset: false,
},
&cloudpb.RetentionScript{
{
ScriptID: utils.ProtoFromUUIDStrOrNil("1ba7b810-9dad-11d1-80b4-00c04fd430c1"),
ScriptName: "Another Script",
Description: "This is another script",
Expand Down
20 changes: 10 additions & 10 deletions src/cloud/cron_script/controllers/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestServer_GetScripts(t *testing.T) {

assert.Equal(t, &cronscriptpb.GetScriptsResponse{
Scripts: []*cronscriptpb.CronScript{
&cronscriptpb.CronScript{
{
ID: utils.ProtoFromUUIDStrOrNil("123e4567-e89b-12d3-a456-426655440000"),
OrgID: utils.ProtoFromUUIDStrOrNil("223e4567-e89b-12d3-a456-426655440000"),
Script: "px.display()",
Expand All @@ -165,7 +165,7 @@ func TestServer_GetScripts(t *testing.T) {
Enabled: true,
FrequencyS: 5,
},
&cronscriptpb.CronScript{
{
ID: utils.ProtoFromUUIDStrOrNil("123e4567-e89b-12d3-a456-426655440002"),
OrgID: utils.ProtoFromUUIDStrOrNil("223e4567-e89b-12d3-a456-426655440000"),
Script: "px()",
Expand Down Expand Up @@ -201,11 +201,11 @@ func TestServer_CreateScript(t *testing.T) {
VizierIDs: clusterIDs,
}).Return(&vzmgrpb.GetVizierInfosResponse{
VizierInfos: []*cvmsgspb.VizierInfo{
&cvmsgspb.VizierInfo{
{
VizierID: utils.ProtoFromUUIDStrOrNil(vz1ID),
Status: cvmsgspb.VZ_ST_HEALTHY,
},
&cvmsgspb.VizierInfo{
{
VizierID: utils.ProtoFromUUIDStrOrNil(vz2ID),
Status: cvmsgspb.VZ_ST_HEALTHY,
},
Expand Down Expand Up @@ -431,11 +431,11 @@ func TestServer_UpdateScript(t *testing.T) {
VizierIDs: clusterIDs,
}).Return(&vzmgrpb.GetVizierInfosResponse{
VizierInfos: []*cvmsgspb.VizierInfo{
&cvmsgspb.VizierInfo{
{
VizierID: utils.ProtoFromUUIDStrOrNil("323e4567-e89b-12d3-a456-426655440003"),
Status: cvmsgspb.VZ_ST_HEALTHY,
},
&cvmsgspb.VizierInfo{
{
VizierID: utils.ProtoFromUUIDStrOrNil("323e4567-e89b-12d3-a456-426655440002"),
Status: cvmsgspb.VZ_ST_HEALTHY,
},
Expand All @@ -448,7 +448,7 @@ func TestServer_UpdateScript(t *testing.T) {
},
}).Return(&vzmgrpb.GetVizierInfosResponse{
VizierInfos: []*cvmsgspb.VizierInfo{
&cvmsgspb.VizierInfo{
{
VizierID: utils.ProtoFromUUIDStrOrNil("323e4567-e89b-12d3-a456-426655440000"),
Status: cvmsgspb.VZ_ST_HEALTHY,
},
Expand Down Expand Up @@ -516,7 +516,7 @@ func TestServer_DeleteScript(t *testing.T) {
},
}).Return(&vzmgrpb.GetVizierInfosResponse{
VizierInfos: []*cvmsgspb.VizierInfo{
&cvmsgspb.VizierInfo{
{
VizierID: vzIDpb,
Status: cvmsgspb.VZ_ST_HEALTHY,
},
Expand Down Expand Up @@ -595,7 +595,7 @@ func TestServer_HandleChecksumRequest(t *testing.T) {
wg.Add(1)

csMap := map[string]*cvmsgspb.CronScript{
"123e4567-e89b-12d3-a456-426655440001": &cvmsgspb.CronScript{
"123e4567-e89b-12d3-a456-426655440001": {
ID: utils.ProtoFromUUIDStrOrNil("123e4567-e89b-12d3-a456-426655440001"),
Script: "px.stream()",
FrequencyS: 10,
Expand Down Expand Up @@ -654,7 +654,7 @@ func TestServer_HandleGetScriptsRequest(t *testing.T) {
wg.Add(1)

csMap := map[string]*cvmsgspb.CronScript{
"123e4567-e89b-12d3-a456-426655440001": &cvmsgspb.CronScript{
"123e4567-e89b-12d3-a456-426655440001": {
ID: utils.ProtoFromUUIDStrOrNil("123e4567-e89b-12d3-a456-426655440001"),
Script: "px.stream()",
FrequencyS: 10,
Expand Down
Loading

0 comments on commit f3b6359

Please sign in to comment.