Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noverify: updated go from 1.16 -> 1.21 #1229

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
- name: Fetch Sources
uses: actions/checkout@v4

- name: Set up Go 1.16
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.16
go-version: 1.21

- name: Run Linter
run: make lint
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
- name: Fetch Sources
uses: actions/checkout@v4

- name: Set up Go 1.16
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.16
go-version: 1.21

- name: Run Tests
run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ src/cmd/stubs/phpstorm-stubs/
y.output
.idea
vendor
dev
4 changes: 2 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ noverify version

You're done! Proceed to the [Getting started](/docs/getting_started.md) page.

## With `go get`
## With `go install`

Make sure you have [Go](https://golang.org/dl/) version 1.16 or higher installed.
Run the following command:

```shell
$ go get github.com/VKCOM/noverify
$ go install github.com/VKCOM/noverify@latest
```

NoVerify will be installed to `$GOPATH/bin/noverify`, which usually expands to `$HOME/go/bin/noverify`.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/VKCOM/noverify

go 1.16
go 1.21

require (
github.com/VKCOM/php-parser v0.8.0-rc.2.0.20210802093708-d85f5a481602
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/php-guru/dupcode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package dupcode
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
"runtime"
"sync"
Expand Down Expand Up @@ -100,7 +100,7 @@ func Main(ctx *guru.Context) (int, error) {
irConverter := irconv.NewConverter(nil)
workerResult := make(funcSet)
for f := range filenamesCh {
data, err := ioutil.ReadFile(f.Name)
data, err := os.ReadFile(f.Name)
if err != nil {
log.Printf("read %s file: %v", f.Name, err)
}
Expand Down
5 changes: 2 additions & 3 deletions src/cmd/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"bytes"
"embed"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -70,7 +69,7 @@ func ParseExternalRules(externalRules string) ([]*rules.Set, error) {

if stat.IsDir() {
dir := filename
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -99,7 +98,7 @@ func ParseExternalRules(externalRules string) ([]*rules.Set, error) {
func readAndParseRuleFile(filename string, ruleSets []*rules.Set) ([]*rules.Set, error) {
p := rules.NewParser()

data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/stat/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module stat

go 1.16
go 1.21

require (
github.com/VKCOM/noverify v0.4.0
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/stat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"sort"
"strings"

Expand All @@ -32,7 +32,7 @@ type ReportDiff struct {
}

func loadReportsFile(filename string) *linterOutput {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
log.Fatalf("read reports file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/test_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -233,7 +233,7 @@ func (s *RulesTestSuite) handleFileContents(file string) (lines []string, report
return nil, nil, fmt.Errorf("runner init fail: %v", err)
}

data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
return nil, nil, fmt.Errorf("error read file '%s': %v", file, err)
}
Expand Down
3 changes: 1 addition & 2 deletions src/inputs/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
)

Expand Down Expand Up @@ -61,7 +60,7 @@ func (defaultSourceInput) NewReader(filename string) (ReadCloseSizer, error) {
}

func (defaultSourceInput) NewBytesReader(filename string, data []byte) (ReadCloseSizer, error) {
return NewReadCloseSizer(ioutil.NopCloser(bytes.NewReader(data)), len(data)), nil
return NewReadCloseSizer(io.NopCloser(bytes.NewReader(data)), len(data)), nil
}

type readCloserSizer struct {
Expand Down
4 changes: 2 additions & 2 deletions src/ir/codegen/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"go/format"
"go/token"
"go/types"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -93,7 +93,7 @@ func (ctx *context) WriteGoFile(f codegenFile) error {
return fmt.Errorf("gofmt: %v", err)
}

if err := ioutil.WriteFile(fullFilename, prettySrc, 0666); err != nil {
if err := os.WriteFile(fullFilename, prettySrc, 0666); err != nil {
return fmt.Errorf("write file: %v", err)
}

Expand Down
71 changes: 36 additions & 35 deletions src/linter/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,42 @@ import (
//
// Version log:
//
// 27 - added Static field to meta.FuncInfo
// 28 - array type parsed as mixed[]
// 29 - updated type inference for ClassConstFetch
// 30 - resolve ClassConstFetch to a wrapped type string
// 31 - fixed plus operator type inference for arrays
// 32 - replaced Static:bool with Flags:uint8 in meta.FuncInfo
// 33 - support parsing of array<k,v> and list<type>
// 34 - support parsing of ?ClassName as "ClassName|null"
// 35 - added Flags:uint8 to meta.ClassInfo
// 36 - added FuncAbstract bit to FuncFlags
// added FuncFinal bit to FuncFlags
// added ClassFinal bit to ClassFlags
// FuncInfo now stores original function name
// ClassInfo now stores original class name
// 37 - added ClassShape bit to ClassFlags
// changed meta.scopeVar bool fields representation
// 38 - replaced TypesMap.immutable:bool with flags:uint8.
// added mapPrecise flag to mark precise type maps.
// 39 - added new field Value in ConstantInfo
// 40 - changed string const value storage (no quotes)
// 41 - const-folding affected const definition values
// 42 - bool-typed consts are now stored in meta info
// 43 - define'd const values stored in cache
// 44 - rename ConstantInfo => ConstInfo
// 45 - added Mixins field to meta.ClassInfo
// 46 - changed the way of inferring the return type of functions and methods
// 47 - forced cache version invalidation due to the #921
// 48 - renamed meta.TypesMap to types.Map; this affects gob encoding
// 49 - for shape, names are now generated using the keys that make up this shape
// 50 - added Flags field for meta.PropertyInfo
// 51 - added anonymous classes
// 52 - renamed all PhpDoc and Phpdoc with PHPDoc
// 53 - added DeprecationInfo for functions and methods and support for some attributes
// 54 - forced cache version invalidation due to the #1165
const cacheVersion = 54
// 27 - added Static field to meta.FuncInfo
// 28 - array type parsed as mixed[]
// 29 - updated type inference for ClassConstFetch
// 30 - resolve ClassConstFetch to a wrapped type string
// 31 - fixed plus operator type inference for arrays
// 32 - replaced Static:bool with Flags:uint8 in meta.FuncInfo
// 33 - support parsing of array<k,v> and list<type>
// 34 - support parsing of ?ClassName as "ClassName|null"
// 35 - added Flags:uint8 to meta.ClassInfo
// 36 - added FuncAbstract bit to FuncFlags
// added FuncFinal bit to FuncFlags
// added ClassFinal bit to ClassFlags
// FuncInfo now stores original function name
// ClassInfo now stores original class name
// 37 - added ClassShape bit to ClassFlags
// changed meta.scopeVar bool fields representation
// 38 - replaced TypesMap.immutable:bool with flags:uint8.
// added mapPrecise flag to mark precise type maps.
// 39 - added new field Value in ConstantInfo
// 40 - changed string const value storage (no quotes)
// 41 - const-folding affected const definition values
// 42 - bool-typed consts are now stored in meta info
// 43 - define'd const values stored in cache
// 44 - rename ConstantInfo => ConstInfo
// 45 - added Mixins field to meta.ClassInfo
// 46 - changed the way of inferring the return type of functions and methods
// 47 - forced cache version invalidation due to the #921
// 48 - renamed meta.TypesMap to types.Map; this affects gob encoding
// 49 - for shape, names are now generated using the keys that make up this shape
// 50 - added Flags field for meta.PropertyInfo
// 51 - added anonymous classes
// 52 - renamed all PhpDoc and Phpdoc with PHPDoc
// 53 - added DeprecationInfo for functions and methods and support for some attributes
// 54 - forced cache version invalidation due to the #1165
// 55 - updated go version 1.16 -> 1.21
const cacheVersion = 55

var (
errWrongVersion = errors.New("Wrong cache version")
Expand Down
6 changes: 3 additions & 3 deletions src/linter/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ main();
// 1. Check cache contents length.
//
// If cache encoding changes, there is a very high chance that
// encoded data lengh will change as well.
wantLen := 5953
// encoded data length will change as well.
wantLen := 5952
haveLen := buf.Len()
if haveLen != wantLen {
t.Errorf("cache len mismatch:\nhave: %d\nwant: %d", haveLen, wantLen)
Expand All @@ -158,7 +158,7 @@ main();
// 2. Check cache "strings" hash.
//
// It catches new fields in cached types, field renames and encoding of additional named attributes.
wantStrings := "df69cfe531807fe5e317e5f894ac1ad2a68020edf03a053a30b25c70488b741b6d992d37e7a76ac4b8a760756631ee9ae309ba57e29253ffae896c3492b90939"
wantStrings := "690e77c94ecdd7878de0bf6f6881d786cf1fafa4588f7905f54d700646c4952aad359008ae2dcddb1c7f29163ecee62355d525672090ac30257bc414f690006f"
haveStrings := collectCacheStrings(buf.String())
if haveStrings != wantStrings {
t.Errorf("cache strings mismatch:\nhave: %q\nwant: %q", haveStrings, wantStrings)
Expand Down
5 changes: 2 additions & 3 deletions src/linttest/golden_linttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package linttest
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -130,7 +129,7 @@ func runGoldenTest(s *GoldenTestSuite) {

func (s *GoldenTestSuite) loadGoldenFile() {
path := filepath.Join(s.BaseDir, s.Name, s.GoldenFileName)
want, err := ioutil.ReadFile(path)
want, err := os.ReadFile(path)
if err != nil {
s.suite.t.Fatalf("read golden file: %v", err)
}
Expand All @@ -146,7 +145,7 @@ type linterOutput struct {
}

func (s *GoldenTestSuite) loadReportsFile(filename string) {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
s.suite.t.Fatalf("read reports file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions src/linttest/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package linttest

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -136,7 +136,7 @@ func (s *inlineTestSuite) handleFileContents(file string) (lines []string, repor
return nil, nil, err
}

data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
return nil, nil, fmt.Errorf("error read file '%s': %v", file, err)
}
Expand Down
6 changes: 2 additions & 4 deletions src/linttest/linttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package linttest

import (
"fmt"
"io/ioutil"
"log"
"math/rand"
"os"
Expand All @@ -30,8 +29,7 @@ func init() {
}
testSeed = v
}

rand.Seed(testSeed)
rand.New(rand.NewSource(testSeed))
log.Printf("TEST_SEED: %d", testSeed)
}

Expand Down Expand Up @@ -139,7 +137,7 @@ func (s *Suite) AddNamedFile(name, contents string) {
// ReadAndAddFiles read and adds a files to a suite file list.
func (s *Suite) ReadAndAddFiles(files []string) {
for _, f := range files {
code, err := ioutil.ReadFile(f)
code, err := os.ReadFile(f)
if err != nil {
s.t.Fatalf("read PHP file: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion src/phpgrep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ See also: ["phpgrep: syntax aware code search"](https://speakerdeck.com/quasilyt
To install `phpgrep` binary under your `$(go env GOPATH)/bin`:

```bash
go get -v github.com/quasilyte/phpgrep/cmd/phpgrep
go install -v github.com/quasilyte/phpgrep/cmd/phpgrep@latest
```

If `$GOPATH/bin` is under your system `$PATH`, `phpgrep` command should be available after that.<br>
Expand Down
3 changes: 1 addition & 2 deletions src/rules/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package rules
import (
"fmt"
"io"
"io/ioutil"
"regexp"
"sort"
"strings"
Expand Down Expand Up @@ -61,7 +60,7 @@ func (p *parser) parse(filename string, r io.Reader) (*Set, error) {
//
// TODO: make phpgrep.compile accepting AST and stop
// slurping sources here + don't parse it twice.
sources, err := ioutil.ReadAll(r)
sources, err := io.ReadAll(r)
if err != nil {
return res, err
}
Expand Down
Loading