diff --git a/.travis.yml b/.travis.yml index 583c83f..d807a66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ go: before_install: - go get -t -v ./... script: + - make lint - bash coverage.sh after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index d189eee..fd76bca 100644 --- a/Makefile +++ b/Makefile @@ -112,3 +112,29 @@ endif clean: @test -d $(BUILD_DIR) && rm -rf $(BUILD_DIR) || true + +lint: lint-check-deps + @echo "[gometalinter] linting sources" + @gometalinter.v1 \ + --disable-all \ + --enable=deadcode \ + --enable=errcheck \ + --enable=gosimple \ + --enable=ineffassign \ + --enable=misspell \ + --enable=staticcheck \ + --enable=vet \ + --enable=vetshadow \ + --enable=unconvert \ + --enable=varcheck \ + --enable=golint \ + --deadline 300s \ + --exclude 'return value not checked' \ + --exclude 'possible misuse of unsafe.Pointer' \ + ./... + +lint-check-deps: + @go get -u gopkg.in/alecthomas/gometalinter.v1 + @gometalinter.v1 --install >/dev/null + +test: diff --git a/coverage.sh b/coverage.sh index 767dc9e..e8285da 100644 --- a/coverage.sh +++ b/coverage.sh @@ -1,14 +1,10 @@ #!/usr/bin/env bash set -e -go test -v -race ./... - echo "" > coverage.txt for d in $(go list ./... | grep -v vendor); do - # Running with -race and -covermode=atomic generates false positives so - # we run the -race bit separately - go test -coverprofile=profile.out -covermode=atomic $d + go test -race -coverprofile=profile.out -covermode=atomic $d if [ -f profile.out ]; then cat profile.out >> coverage.txt rm profile.out diff --git a/kernel/driver/tty/vt.go b/kernel/driver/tty/vt.go index d831bc1..1c19a5e 100644 --- a/kernel/driver/tty/vt.go +++ b/kernel/driver/tty/vt.go @@ -67,7 +67,7 @@ func (t *Vt) Write(data []byte) (int, error) { return len(data), nil } -// Write implements io.ByteWriter. +// WriteByte implements io.ByteWriter. func (t *Vt) WriteByte(b byte) error { switch b { case '\r': diff --git a/kernel/hal/hal.go b/kernel/hal/hal.go index 61bdc9e..0b211f9 100644 --- a/kernel/hal/hal.go +++ b/kernel/hal/hal.go @@ -7,7 +7,9 @@ import ( ) var ( - egaConsole = &console.Ega{} + egaConsole = &console.Ega{} + + // ActiveTerminal points to the currently active terminal. ActiveTerminal = &tty.Vt{} ) diff --git a/kernel/hal/multiboot/multiboot.go b/kernel/hal/multiboot/multiboot.go index a7336fb..1dd6e9f 100644 --- a/kernel/hal/multiboot/multiboot.go +++ b/kernel/hal/multiboot/multiboot.go @@ -4,6 +4,7 @@ import "unsafe" type tagType uint32 +// nolint const ( tagMbSectionEnd tagType = iota tagBootCmdLine @@ -100,7 +101,7 @@ const ( memUnknown ) -/// MemoryMapEntry describes a memory region entry, namely its physical address, +// MemoryMapEntry describes a memory region entry, namely its physical address, // its length and its type. type MemoryMapEntry struct { // The physical address for this memory region. diff --git a/kernel/kmain.go b/kernel/kmain.go index 534dda9..2c21fda 100644 --- a/kernel/kmain.go +++ b/kernel/kmain.go @@ -26,8 +26,4 @@ func Kmain(multibootInfoPtr uintptr) { hal.InitTerminal() hal.ActiveTerminal.Clear() early.Printf("Starting gopher-os\n") - - // Prevent Kmain from returning - for { - } }