Skip to content

Commit

Permalink
fix: linting errors (robertkrimen#441)
Browse files Browse the repository at this point in the history
Disable new linters which aren't compatible with this code module.

Upgrade github actions to fix caching issues.

Run go mod to bring in new styling.

Remove space on nolint declarations.

Apply all changes to whitespace as required to pass goimports linter.

Only trigger checks on pull_request which works for pulls from other
forks, where as push only works from the same repo.
  • Loading branch information
stevenh authored Oct 7, 2022
1 parent 201ab5b commit 7009038
Show file tree
Hide file tree
Showing 20 changed files with 292 additions and 273 deletions.
59 changes: 47 additions & 12 deletions .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,59 @@
name: Go test and lint

on:
push:
branches: '**'
pull_request:
branches: 'master'

jobs:
go-test-lint:
runs-on: ubuntu-latest
strategy:
matrix:
go: [1.18]
golangcli: [v1.50.0]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: ${{ matrix.go }}

- name: Checkout
uses: actions/checkout@v3

- name: Test
run: go test -v ./...
- name: Go Cache Paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
- name: Go Build Cache
uses: actions/cache@v3
with:
version: latest
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

- name: Validate go mod
run: |
go mod tidy
git --no-pager diff && [[ 0 -eq $(git status --porcelain | wc -l) ]]
- name: Go Lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ matrix.golangci }}
args: "--out-${NO_FUTURE}format colored-line-number"
skip-pkg-cache: true
skip-build-cache: true

- name: Go Build
run: go build ./...

- name: Go Test
run: go test -race -v ./...
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ linters:
- gocyclo
- misspell
- cyclop
- varnamelen
- nonamedreturns
- maintidx
- ireturn
- exhaustruct
- nosnakecase
- deadcode
- dupword
- gci

issues:
exclude:
Expand Down
3 changes: 1 addition & 2 deletions ast/node.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
Package ast declares types representing a JavaScript AST.
Warning
# Warning
The parser and AST interfaces are still works-in-progress (particularly where
node types are concerned) and may change in the future.
*/
package ast

Expand Down
4 changes: 2 additions & 2 deletions documentation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
)

func ExampleSynopsis() { // nolint: govet
func ExampleSynopsis() { //nolint: govet
vm := New()
vm.Run(`
abc = 2 + 2;
Expand Down Expand Up @@ -69,7 +69,7 @@ func ExampleSynopsis() { // nolint: govet
// 4
}

func ExampleConsole() { // nolint: govet
func ExampleConsole() { //nolint: govet
vm := New()
console := map[string]interface{}{
"log": func(call FunctionCall) Value {
Expand Down
10 changes: 4 additions & 6 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,17 @@ type Error struct {

// Error returns a description of the error
//
// TypeError: 'def' is not a function
//
// TypeError: 'def' is not a function
func (err Error) Error() string {
return err.format()
}

// String returns a description of the error and a trace of where the
// error occurred.
//
// TypeError: 'def' is not a function
// at xyz (<anonymous>:3:9)
// at <anonymous>:7:1/
//
// TypeError: 'def' is not a function
// at xyz (<anonymous>:3:9)
// at <anonymous>:7:1/
func (err Error) String() string {
return err.formatWithStack()
}
Expand Down
2 changes: 0 additions & 2 deletions file/file.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Package file encapsulates the file abstractions used by the ast & parser.
//
package file

import (
Expand Down Expand Up @@ -36,7 +35,6 @@ func (self *Position) isValid() bool {
// line:column A valid position without filename
// file An invalid position with filename
// - An invalid position without filename
//
func (self *Position) String() string {
str := self.Filename
if self.isValid() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
github.com/chzyer/logex v1.1.10 // indirect
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/stretchr/testify v1.7.0
gopkg.in/readline.v1 v1.0.0-20160726135117-62c6fe619375
gopkg.in/sourcemap.v1 v1.0.5
)
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/readline.v1 v1.0.0-20160726135117-62c6fe619375 h1:hPki/oSSWOLiI9Gc9jyIoj33O3j29fUc9PlLha2yDj0=
gopkg.in/readline.v1 v1.0.0-20160726135117-62c6fe619375/go.mod h1:lNEQeAhU009zbRxng+XOj5ITVgY24WcbNnQopyfKoYQ=
Expand Down
Loading

0 comments on commit 7009038

Please sign in to comment.