Skip to content

Commit 405256c

Browse files
author
Kai Mast
authored
Enabled unused-parameters and unused-receivers lints (#214)
1 parent 4353c84 commit 405256c

17 files changed

Lines changed: 42 additions & 41 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Install pylint
5151
run: pip3 install pylint==2.15.0
5252
- name: Install revive (go linter)
53-
run: go install github.com/mgechev/revive@latest
53+
run: go install github.com/mgechev/revive@v1.3.4
5454
- name: Install cross
5555
run: cargo install cross
5656
- name: Build OpenLambda

golint.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
enableAllRules = true
2+
errorCode = 2
3+
#warningCode = 1
24

35
#TODO we should eventually comment all public methods
46
[rule.package-comments]
@@ -28,10 +30,6 @@ enableAllRules = true
2830
Disabled = true
2931
[rule.import-shadowing]
3032
Disabled = true
31-
[rule.unused-parameter]
32-
Disabled = true
33-
[rule.unused-receiver]
34-
Disabled = true
3533
[rule.receiver-naming]
3634
Disabled = true
3735
[rule.error-strings]

src/bench/bench.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Call struct {
1919
name string
2020
}
2121

22-
func task(task int, reqQ chan Call, errQ chan error) {
22+
func task(_ int, reqQ chan Call, errQ chan error) {
2323
for {
2424
call, ok := <-reqQ
2525
if !ok {

src/boss/boss.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (b *Boss) BossStatus(w http.ResponseWriter, r *http.Request) {
4444
}
4545
}
4646

47-
func (b *Boss) Close(w http.ResponseWriter, r *http.Request) {
47+
func (b *Boss) Close(_ http.ResponseWriter, _ *http.Request) {
4848
b.workerPool.Close()
4949
if Conf.Scaling == "threshold-scaler" {
5050
b.autoScaler.Close()

src/boss/cloudvm/gcp_worker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func NewGcpWorkerPool() *WorkerPool {
7979
}
8080
}
8181

82-
func (pool *GcpWorkerPool) NewWorker(workerId string) *Worker {
82+
func (_ *GcpWorkerPool) NewWorker(workerId string) *Worker {
8383
return &Worker{
8484
workerId: workerId,
8585
workerIp: "",
@@ -113,6 +113,6 @@ func (pool *GcpWorkerPool) DeleteInstance(worker *Worker) {
113113
pool.client.Wait(pool.client.deleteGcpInstance(worker.workerId)) //wait until instance is completely deleted
114114
}
115115

116-
func (pool *GcpWorkerPool) ForwardTask(w http.ResponseWriter, r *http.Request, worker *Worker) {
116+
func (_ *GcpWorkerPool) ForwardTask(w http.ResponseWriter, r *http.Request, worker *Worker) {
117117
forwardTaskHelper(w, r, worker.workerIp)
118118
}

src/boss/cloudvm/mock_worker.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ func NewMockWorkerPool() *WorkerPool {
2121
}
2222
}
2323

24-
func (pool *MockWorkerPool) NewWorker(workerId string) *Worker {
24+
func (_ *MockWorkerPool) NewWorker(workerId string) *Worker {
2525
return &Worker{
2626
workerId: workerId,
2727
workerIp: "",
2828
}
2929
}
3030

31-
func (pool *MockWorkerPool) CreateInstance(worker *Worker) {
31+
func (_ *MockWorkerPool) CreateInstance(worker *Worker) {
3232
log.Printf("created new mock worker: %s\n", worker.workerId)
3333
}
3434

35-
func (pool *MockWorkerPool) DeleteInstance(worker *Worker) {
35+
func (_ *MockWorkerPool) DeleteInstance(worker *Worker) {
3636
log.Printf("deleted mock worker: %s\n", worker.workerId)
3737
}
3838

39-
func (pool *MockWorkerPool) ForwardTask(w http.ResponseWriter, r *http.Request, worker *Worker) {
39+
func (_ *MockWorkerPool) ForwardTask(w http.ResponseWriter, _ *http.Request, worker *Worker) {
4040
s := fmt.Sprintf("hello from %s\n", worker.workerId)
4141
w.WriteHeader(http.StatusOK)
4242
_, err := w.Write([]byte(s))

src/worker/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func initOLDir(olPath string, dockerBaseImage string, newBase bool) (err error)
170170
// main error scenarios:
171171
// 1. PID exists, but process cannot be killed (worker probably died unexpectedly)
172172
// 2. The cleanup is taking too long (maybe the timeout is insufficient, or there is a deadlock)
173-
func stopOL(olPath string) error {
173+
func stopOL(_ string) error {
174174
// locate worker.pid, use it to get worker's PID
175175
pidPath := filepath.Join(common.Conf.Worker_dir, "worker.pid")
176176
data, err := ioutil.ReadFile(pidPath)

src/worker/lambda/lambdaManager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (mgr *LambdaMgr) Debug() string {
131131
return mgr.sbPool.DebugString() + "\n"
132132
}
133133

134-
func (mgr *LambdaMgr) DumpStatsToLog() {
134+
func (_ *LambdaMgr) DumpStatsToLog() {
135135
snapshot := common.SnapshotStats()
136136

137137
sec := func(name string) float64 {

src/worker/sandbox/cgroups/pool.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,15 @@ func (pool *CgroupPool) GetCg(memLimitMB int, moveMemCharge bool, cpuPercent int
164164
cg.SetMemLimitMB(memLimitMB)
165165
cg.SetCPUPercent(cpuPercent)
166166

167-
/* FIXME not supported in CG2?
168-
if moveMemCharge {
169-
cg.WriteInt("memory.move_charge_at_immigrate", 1)
170-
} else {
171-
cg.WriteInt("memory.move_charge_at_immigrate", 0)
172-
}*/
167+
// FIXME not supported in CG2?
168+
var _ = moveMemCharge
169+
170+
/*
171+
if moveMemCharge {
172+
cg.WriteInt("memory.move_charge_at_immigrate", 1)
173+
} else {
174+
cg.WriteInt("memory.move_charge_at_immigrate", 0)
175+
}*/
173176

174177
return cg
175178
}

src/worker/sandbox/docker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (container *DockerContainer) Unpause() error {
169169
}
170170

171171
// Destroy shuts down this container
172-
func (container *DockerContainer) Destroy(reason string) {
172+
func (container *DockerContainer) Destroy(_ string) {
173173
if err := container.internalDestroy(); err != nil {
174174
panic(fmt.Sprintf("Failed to cleanup container %v: %v", container.container.ID, err))
175175
}
@@ -296,11 +296,11 @@ func (container *DockerContainer) DebugString() string {
296296
return fmt.Sprintf("SANDBOX %s (DOCKER)\n", container.ID())
297297
}
298298

299-
func (*DockerContainer) fork(dst Sandbox) (err error) {
299+
func (*DockerContainer) fork(_ Sandbox) (err error) {
300300
panic("DockerContainer does not implement cross-container forks")
301301
}
302302

303-
func (*DockerContainer) childExit(child Sandbox) {
303+
func (*DockerContainer) childExit(_ Sandbox) {
304304
panic("DockerContainers should not have children because fork is unsupported")
305305
}
306306

0 commit comments

Comments
 (0)