Skip to content

Commit

Permalink
.gometalinter.json: enable gofmt
Browse files Browse the repository at this point in the history
The part that we want from gofmt is simplify (-s).
Fix all code that needs fixing.

Update #538
  • Loading branch information
dvyukov committed Jul 31, 2018
1 parent b8bd991 commit f5d67fb
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gometalinter.json
Expand Up @@ -19,6 +19,7 @@
"sys/test/gen"
],
"enable": [
"gofmt",
"golint",
"structcheck",
"megacheck",
Expand Down
10 changes: 5 additions & 5 deletions dashboard/app/app_test.go
Expand Up @@ -30,7 +30,7 @@ var testConfig = &GlobalConfig{
"\"Bar\" <BlackListed@Domain.com>",
},
Namespaces: map[string]*Config{
"test1": &Config{
"test1": {
AccessLevel: AccessAdmin,
Key: "test1keytest1keytest1key",
Clients: map[string]string{
Expand Down Expand Up @@ -60,7 +60,7 @@ var testConfig = &GlobalConfig{
},
},
},
"test2": &Config{
"test2": {
AccessLevel: AccessAdmin,
Key: "test2keytest2keytest2key",
Clients: map[string]string{
Expand Down Expand Up @@ -93,7 +93,7 @@ var testConfig = &GlobalConfig{
},
},
// Namespaces for access level testing.
"access-admin": &Config{
"access-admin": {
AccessLevel: AccessAdmin,
Key: "adminkeyadminkeyadminkey",
Clients: map[string]string{
Expand All @@ -110,7 +110,7 @@ var testConfig = &GlobalConfig{
},
},
},
"access-user": &Config{
"access-user": {
AccessLevel: AccessUser,
Key: "userkeyuserkeyuserkey",
Clients: map[string]string{
Expand All @@ -128,7 +128,7 @@ var testConfig = &GlobalConfig{
},
},
},
"access-public": &Config{
"access-public": {
AccessLevel: AccessPublic,
Key: "publickeypublickeypublickey",
Clients: map[string]string{
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config_test.go
Expand Up @@ -116,11 +116,11 @@ func TestLoad(t *testing.T) {
Config{
Foo: 1,
Arr: []Nested{
Nested{
{
Aaa: 12,
Bbb: "bbb",
},
Nested{
{
Aaa: 13,
Bbb: "ccc",
},
Expand Down
10 changes: 5 additions & 5 deletions pkg/csource/options_test.go
Expand Up @@ -30,7 +30,7 @@ func TestParseOptionsCanned(t *testing.T) {
`{"threaded":true,"collide":true,"repeat":true,"procs":10,"sandbox":"namespace",
"fault":true,"fault_call":1,"fault_nth":2,"tun":true,"tmpdir":true,"cgroups":true,
"netdev":true,"resetnet":true,
"segv":true,"waitrepeat":true,"debug":true,"repro":true}`: Options{
"segv":true,"waitrepeat":true,"debug":true,"repro":true}`: {
Threaded: true,
Collide: true,
Repeat: true,
Expand All @@ -47,7 +47,7 @@ func TestParseOptionsCanned(t *testing.T) {
HandleSegv: true,
Repro: true,
},
"{Threaded:true Collide:true Repeat:true Procs:1 Sandbox:none Fault:false FaultCall:-1 FaultNth:0 EnableTun:true UseTmpDir:true HandleSegv:true WaitRepeat:true Debug:false Repro:false}": Options{
"{Threaded:true Collide:true Repeat:true Procs:1 Sandbox:none Fault:false FaultCall:-1 FaultNth:0 EnableTun:true UseTmpDir:true HandleSegv:true WaitRepeat:true Debug:false Repro:false}": {
Threaded: true,
Collide: true,
Repeat: true,
Expand All @@ -62,7 +62,7 @@ func TestParseOptionsCanned(t *testing.T) {
HandleSegv: true,
Repro: false,
},
"{Threaded:true Collide:true Repeat:true Procs:1 Sandbox: Fault:false FaultCall:-1 FaultNth:0 EnableTun:true UseTmpDir:true HandleSegv:true WaitRepeat:true Debug:false Repro:false}": Options{
"{Threaded:true Collide:true Repeat:true Procs:1 Sandbox: Fault:false FaultCall:-1 FaultNth:0 EnableTun:true UseTmpDir:true HandleSegv:true WaitRepeat:true Debug:false Repro:false}": {
Threaded: true,
Collide: true,
Repeat: true,
Expand All @@ -77,7 +77,7 @@ func TestParseOptionsCanned(t *testing.T) {
HandleSegv: true,
Repro: false,
},
"{Threaded:false Collide:true Repeat:true Procs:1 Sandbox:namespace Fault:false FaultCall:-1 FaultNth:0 EnableTun:true UseTmpDir:true EnableCgroups:true HandleSegv:true WaitRepeat:true Debug:false Repro:false}": Options{
"{Threaded:false Collide:true Repeat:true Procs:1 Sandbox:namespace Fault:false FaultCall:-1 FaultNth:0 EnableTun:true UseTmpDir:true EnableCgroups:true HandleSegv:true WaitRepeat:true Debug:false Repro:false}": {
Threaded: false,
Collide: true,
Repeat: true,
Expand Down Expand Up @@ -122,7 +122,7 @@ func allOptionsSingle(OS string) []Options {
}

func allOptionsPermutations(OS string) []Options {
opts := []Options{Options{}}
opts := []Options{{}}
fields := reflect.TypeOf(Options{}).NumField()
for i := 0; i < fields; i++ {
var newOpts []Options
Expand Down
2 changes: 1 addition & 1 deletion pkg/gce/gce.go
Expand Up @@ -125,7 +125,7 @@ func (ctx *Context) CreateInstance(name, machineType, image, sshkey string) (str
},
},
NetworkInterfaces: []*compute.NetworkInterface{
&compute.NetworkInterface{
{
Network: ctx.Network,
Subnetwork: ctx.Subnetwork,
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/ifuzz/pseudo.go
Expand Up @@ -550,9 +550,9 @@ func pciAddrPort(r *rand.Rand) (addr uint32, port uint16, size int) {

var controlRegisters = []uint8{0, 3, 4, 8}
var controlRegistersBits = map[uint8][]uint8{
0: []uint8{0, 1, 2, 3, 4, 5, 16, 18, 29, 30, 31},
3: []uint8{3, 5},
4: []uint8{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 16, 17, 18, 20, 21, 22},
0: {0, 1, 2, 3, 4, 5, 16, 18, 29, 30, 31},
3: {3, 5},
4: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 16, 17, 18, 20, 21, 22},
}

const eferMSR = 0xC0000080
Expand Down
4 changes: 2 additions & 2 deletions pkg/report/akaros.go
Expand Up @@ -155,7 +155,7 @@ var akarosStackParams = &stackParams{
}

var akarosOopses = []*oops{
&oops{
{
[]byte("kernel panic"),
[]oopsFormat{
{
Expand Down Expand Up @@ -187,7 +187,7 @@ var akarosOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("kernel warning"),
[]oopsFormat{
{
Expand Down
4 changes: 2 additions & 2 deletions pkg/report/freebsd.go
Expand Up @@ -80,7 +80,7 @@ func (ctx *freebsd) Symbolize(rep *Report) error {
var freebsdStackParams = &stackParams{}

var freebsdOopses = []*oops{
&oops{
{
[]byte("Fatal trap"),
[]oopsFormat{
{
Expand All @@ -94,7 +94,7 @@ var freebsdOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("panic:"),
[]oopsFormat{
{
Expand Down
18 changes: 9 additions & 9 deletions pkg/report/gvisor.go
Expand Up @@ -110,7 +110,7 @@ var gvisorTitleReplacement = []replacement{
}

var gvisorOopses = []*oops{
&oops{
{
[]byte("panic:"),
[]oopsFormat{
{
Expand All @@ -121,7 +121,7 @@ var gvisorOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("Panic:"),
[]oopsFormat{
{
Expand All @@ -132,7 +132,7 @@ var gvisorOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("fatal error:"),
[]oopsFormat{
{
Expand All @@ -143,7 +143,7 @@ var gvisorOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("runtime error:"),
[]oopsFormat{
{
Expand All @@ -154,7 +154,7 @@ var gvisorOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("SIGSEGV:"),
[]oopsFormat{
{
Expand All @@ -165,7 +165,7 @@ var gvisorOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("SIGBUS:"),
[]oopsFormat{
{
Expand All @@ -176,7 +176,7 @@ var gvisorOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("FATAL ERROR:"),
[]oopsFormat{
{
Expand All @@ -187,7 +187,7 @@ var gvisorOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("WARNING: DATA RACE"),
[]oopsFormat{
{
Expand All @@ -199,7 +199,7 @@ var gvisorOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("Invalid request partialResult"),
[]oopsFormat{
{
Expand Down
28 changes: 14 additions & 14 deletions pkg/report/linux.go
Expand Up @@ -591,7 +591,7 @@ func warningStackFmt(skip ...string) *stackFmt {
}

var linuxOopses = []*oops{
&oops{
{
[]byte("BUG:"),
[]oopsFormat{
{
Expand Down Expand Up @@ -785,7 +785,7 @@ var linuxOopses = []*oops{
compile("BUG: no syscalls can create resource"),
},
},
&oops{
{
[]byte("WARNING:"),
[]oopsFormat{
{
Expand Down Expand Up @@ -909,7 +909,7 @@ var linuxOopses = []*oops{
compile("WARNING: /etc/ssh/moduli does not exist, using fixed modulus"), // printed by sshd
},
},
&oops{
{
[]byte("INFO:"),
[]oopsFormat{
{
Expand Down Expand Up @@ -1012,7 +1012,7 @@ var linuxOopses = []*oops{
compile("INFO: no syscalls can create resource"), // pkg/host output in debug mode
},
},
&oops{
{
[]byte("Unable to handle kernel paging request"),
[]oopsFormat{
{
Expand All @@ -1023,7 +1023,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("general protection fault:"),
[]oopsFormat{
{
Expand All @@ -1040,7 +1040,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("Kernel panic"),
[]oopsFormat{
{
Expand Down Expand Up @@ -1078,7 +1078,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("kernel BUG"),
[]oopsFormat{
{
Expand All @@ -1104,7 +1104,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("Kernel BUG"),
[]oopsFormat{
{
Expand All @@ -1114,7 +1114,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("BUG kmalloc-"),
[]oopsFormat{
{
Expand All @@ -1124,7 +1124,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("divide error:"),
[]oopsFormat{
{
Expand All @@ -1135,7 +1135,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("invalid opcode:"),
[]oopsFormat{
{
Expand All @@ -1146,7 +1146,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("UBSAN:"),
[]oopsFormat{
{
Expand All @@ -1156,7 +1156,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("Booting the kernel."),
[]oopsFormat{
{
Expand All @@ -1167,7 +1167,7 @@ var linuxOopses = []*oops{
},
[]*regexp.Regexp{},
},
&oops{
{
[]byte("unregister_netdevice: waiting for"),
[]oopsFormat{
{
Expand Down
6 changes: 3 additions & 3 deletions pkg/report/linux_test.go
Expand Up @@ -136,13 +136,13 @@ func TestLinuxSymbolizeLine(t *testing.T) {
},
}
symbols := map[string][]symbolizer.Symbol{
"foo": []symbolizer.Symbol{
"foo": {
{Addr: 0x1000000, Size: 0x190},
},
"do_ipv6_setsockopt.isra.7.part.3": []symbolizer.Symbol{
"do_ipv6_setsockopt.isra.7.part.3": {
{Addr: 0x2000000, Size: 0x2830},
},
"baz": []symbolizer.Symbol{
"baz": {
{Addr: 0x3000000, Size: 0x100},
{Addr: 0x4000000, Size: 0x200},
{Addr: 0x5000000, Size: 0x300},
Expand Down

0 comments on commit f5d67fb

Please sign in to comment.