├── vendor ├── golang.org │ └── x │ │ ├── sys │ │ ├── unix │ │ │ ├── .gitignore │ │ │ ├── endian_big.go │ │ │ ├── endian_little.go │ │ │ ├── constants.go │ │ │ ├── syscall_linux_amd64_gc.go │ │ │ ├── aliases.go │ │ │ ├── pagesize_unix.go │ │ │ ├── fcntl_linux_32bit.go │ │ │ ├── asm_solaris_amd64.s │ │ │ ├── gccgo_linux_amd64.go │ │ │ ├── syscall_linux_gc.go │ │ │ ├── race0.go │ │ │ ├── syscall_solaris_amd64.go │ │ │ ├── syscall_linux_gc_386.go │ │ │ ├── syscall_unix_gc.go │ │ │ ├── dirent.go │ │ │ ├── syscall_linux_gccgo_arm.go │ │ │ ├── str.go │ │ │ ├── race.go │ │ │ ├── env_unix.go │ │ │ ├── asm_freebsd_arm.s │ │ │ ├── asm_netbsd_arm.s │ │ │ ├── asm_openbsd_arm.s │ │ │ ├── asm_darwin_386.s │ │ │ ├── asm_freebsd_386.s │ │ │ ├── asm_netbsd_386.s │ │ │ ├── asm_openbsd_386.s │ │ │ ├── asm_darwin_amd64.s │ │ │ ├── asm_freebsd_amd64.s │ │ │ ├── asm_netbsd_amd64.s │ │ │ ├── asm_openbsd_amd64.s │ │ │ ├── asm_dragonfly_amd64.s │ │ │ ├── asm_darwin_arm.s │ │ │ ├── bluetooth_linux.go │ │ │ ├── asm_darwin_arm64.s │ │ │ ├── dev_darwin.go │ │ │ ├── syscall_netbsd_amd64.go │ │ │ ├── syscall_netbsd_386.go │ │ │ ├── syscall_netbsd_arm.go │ │ │ ├── syscall_openbsd_386.go │ │ │ ├── syscall_openbsd_arm.go │ │ │ ├── mksysnum_darwin.pl │ │ │ ├── dev_netbsd.go │ │ │ ├── dev_openbsd.go │ │ │ ├── ioctl.go │ │ │ ├── syscall_openbsd_amd64.go │ │ │ ├── syscall_aix_ppc64.go │ │ │ ├── syscall_aix_ppc.go │ │ │ ├── fcntl.go │ │ │ ├── syscall_linux_gccgo_386.go │ │ │ ├── dev_freebsd.go │ │ │ ├── dev_dragonfly.go │ │ │ ├── sockcmsg_linux.go │ │ │ ├── gccgo_c.c │ │ │ ├── mksysnum_dragonfly.pl │ │ │ ├── mksysnum_openbsd.pl │ │ │ ├── mksysnum_freebsd.pl │ │ │ ├── asm_linux_arm64.s │ │ │ ├── asm_linux_arm.s │ │ │ ├── asm_linux_s390x.s │ │ │ ├── zptracearm_linux.go │ │ │ ├── asm_linux_mipsx.s │ │ │ ├── asm_linux_mips64x.s │ │ │ ├── asm_linux_ppc64x.s │ │ │ ├── syscall_dragonfly_amd64.go │ │ │ ├── syscall_freebsd_amd64.go │ │ │ ├── asm_linux_amd64.s │ │ │ ├── dev_aix_ppc.go │ │ │ ├── syscall_freebsd_arm.go │ │ │ ├── syscall_freebsd_386.go │ │ │ ├── mksysnum_netbsd.pl │ │ │ ├── dev_aix_ppc64.go │ │ │ ├── zptracemips_linux.go │ │ │ └── zptracemipsle_linux.go │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── PATENTS │ │ └── LICENSE │ │ └── tools │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── go │ │ └── internal │ │ │ └── gcimporter │ │ │ ├── isAlias19.go │ │ │ ├── isAlias18.go │ │ │ ├── newInterface11.go │ │ │ └── newInterface10.go │ │ ├── PATENTS │ │ └── LICENSE ├── github.com │ ├── mgechev │ │ └── dots │ │ │ └── .travis.yml │ ├── fatih │ │ ├── color │ │ │ ├── .travis.yml │ │ │ ├── Gopkg.toml │ │ │ ├── Gopkg.lock │ │ │ └── LICENSE.md │ │ └── structtag │ │ │ └── .travis.yml │ ├── BurntSushi │ │ └── toml │ │ │ ├── session.vim │ │ │ ├── .gitignore │ │ │ ├── COMPATIBLE │ │ │ ├── .travis.yml │ │ │ ├── Makefile │ │ │ ├── COPYING │ │ │ ├── encoding_types_1.1.go │ │ │ ├── encoding_types.go │ │ │ └── doc.go │ ├── mattn │ │ ├── go-isatty │ │ │ ├── doc.go │ │ │ ├── .travis.yml │ │ │ ├── isatty_others.go │ │ │ ├── isatty_solaris.go │ │ │ ├── isatty_linux.go │ │ │ ├── isatty_appengine.go │ │ │ ├── isatty_bsd.go │ │ │ ├── isatty_linux_ppc64x.go │ │ │ ├── LICENSE │ │ │ └── README.md │ │ ├── go-runewidth │ │ │ ├── runewidth_js.go │ │ │ ├── .travis.yml │ │ │ ├── runewidth_windows.go │ │ │ ├── README.mkd │ │ │ └── LICENSE │ │ └── go-colorable │ │ │ ├── .travis.yml │ │ │ ├── colorable_appengine.go │ │ │ ├── colorable_others.go │ │ │ ├── LICENSE │ │ │ ├── noncolorable.go │ │ │ └── README.md │ ├── olekukonko │ │ └── tablewriter │ │ │ ├── .travis.yml │ │ │ ├── .gitignore │ │ │ ├── LICENCE.md │ │ │ └── csv.go │ └── pkg │ │ └── errors │ │ ├── .travis.yml │ │ ├── .gitignore │ │ ├── appveyor.yml │ │ └── LICENSE └── modules.txt ├── fixtures ├── lint-file-header4.go ├── lint-file-header1.go ├── lint-file-header2.go ├── lint-file-header5.go ├── golint │ ├── package-doc3.go │ ├── package-main.go │ ├── package-doc1.go │ ├── import-dot.go │ ├── package-doc4.go │ ├── package-doc2.go │ ├── package-doc5.go │ ├── docs_test.go │ ├── increment-decrement.go │ ├── exported.go │ ├── time-naming.go │ ├── sort.go │ ├── error-naming.go │ ├── context-as-argument.go │ ├── range.go │ ├── stutter.go │ ├── error-strings.go │ ├── errorf.go │ ├── indent-error-flow.go │ ├── const-block.go │ ├── receiver-naming.go │ ├── blank-import-lib.go │ ├── value-spec.go │ ├── error-return.go │ └── unexported-return.go ├── lint-file-header3.go ├── var-naming.go ├── confusing-naming2.go ├── max-public-structs.go ├── duplicated-imports.go ├── flag-param.go ├── imports-blacklist.go ├── call-to-gc.go ├── modifies-value-receiver.go ├── argument-limit.go ├── function-result-limit.go ├── cyclomatic-2.go ├── modifies-param.go ├── disable-annotations.go ├── confusing-results.go ├── cyclomatic.go ├── add-constant.go ├── waitgroup-by-value.go ├── line-length-limit.go ├── redefines-builtin-id.go ├── get-return.go ├── deep-exit.go ├── disable-annotations2.go ├── import-shadowing.go ├── unreachable-code.go ├── empty-block.go ├── unnecessary-stmt.go ├── range-val-in-closure.go ├── constant-logical-expr.go ├── confusing-naming1.go ├── atomic.go └── bool-literal-in-expr.go ├── assets ├── logo.png ├── revive.png ├── readwrite.png ├── globalstate.png ├── goroutines.png ├── performance.PNG ├── phantomread.png ├── formatter-unix.png ├── rangeovermap.png ├── formatter-plain.png ├── blacklistedimports.png ├── formatter-default.png ├── formatter-friendly.png └── formatter-stylish.png ├── Makefile ├── test ├── deep-exit_test.go ├── flag-param_test.go ├── get-return_test.go ├── atomic_test.go ├── unused-param_test.go ├── import-shadowing_test.go ├── unreachable-code_test.go ├── confusing-results_test.go ├── waitgroup-by-value_test.go ├── duplicated-import_test.go ├── empty-block_test.go ├── empty-lines_test.go ├── call-to-gc_test.go ├── modifies-value-receiver_test.go ├── struct-tag_test.go ├── bool-literal-in-expr_test.go ├── modifies-param_test.go ├── confusing-naming_test.go ├── superfluous-else_test.go ├── unnecessary-stmt_test.go ├── constant-logical-expr_test.go ├── redefines-builtin-id_test.go ├── range-val-in-closure_test.go ├── argument-limit_test.go ├── line-length-limit_test.go ├── max-public-structs_test.go ├── var-naming_test.go ├── function-result-limit_test.go ├── import-blacklist_test.go ├── disable-annotations_test.go ├── cyclomatic_test.go ├── add-constant_test.go └── file-header_test.go ├── defaults.toml ├── formatter ├── severity.go ├── default.go ├── plain.go ├── unix.go ├── ndjson.go └── json.go ├── lint ├── formatter.go ├── config.go ├── rule.go └── failure.go ├── untyped.toml ├── go.mod ├── PULL_REQUEST_TEMPLATE.md ├── rule ├── duplicated-imports.go ├── dot-imports.go ├── go-routines.go ├── divide-by-zero.go ├── restrict-global-variables.go ├── confusing-results.go ├── context-as-argument.go ├── get-return.go ├── argument-limit.go ├── max-public-structs.go ├── error-return.go ├── waitgroup-by-value.go └── empty-block.go ├── DEVELOPING.md └── main.go /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /fixtures/lint-file-header4.go: -------------------------------------------------------------------------------- 1 | // foobar 2 | 3 | package fixtures 4 | -------------------------------------------------------------------------------- /vendor/github.com/mgechev/dots/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: master 3 | -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/logo.png -------------------------------------------------------------------------------- /fixtures/lint-file-header1.go: -------------------------------------------------------------------------------- 1 | // baz baz qux 2 | // foobar 3 | 4 | package fixtures 5 | -------------------------------------------------------------------------------- /fixtures/lint-file-header2.go: -------------------------------------------------------------------------------- 1 | /* baz baz qux 2 | foobar */ 3 | 4 | package fixtures 5 | -------------------------------------------------------------------------------- /fixtures/lint-file-header5.go: -------------------------------------------------------------------------------- 1 | // foobaz qux 2 | // bar 3 | 4 | package fixtures 5 | -------------------------------------------------------------------------------- /assets/revive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/revive.png -------------------------------------------------------------------------------- /assets/readwrite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/readwrite.png -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.8.x 4 | - tip 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/structtag/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.7.x 4 | - tip 5 | -------------------------------------------------------------------------------- /assets/globalstate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/globalstate.png -------------------------------------------------------------------------------- /assets/goroutines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/goroutines.png -------------------------------------------------------------------------------- /assets/performance.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/performance.PNG -------------------------------------------------------------------------------- /assets/phantomread.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/phantomread.png -------------------------------------------------------------------------------- /assets/formatter-unix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/formatter-unix.png -------------------------------------------------------------------------------- /assets/rangeovermap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/rangeovermap.png -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/session.vim: -------------------------------------------------------------------------------- 1 | au BufWritePost *.go silent!make tags > /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /assets/formatter-plain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/formatter-plain.png -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/.gitignore: -------------------------------------------------------------------------------- 1 | TAGS 2 | tags 3 | .*.swp 4 | tomlcheck/tomlcheck 5 | toml.test 6 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /assets/blacklistedimports.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/blacklistedimports.png -------------------------------------------------------------------------------- /assets/formatter-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/formatter-default.png -------------------------------------------------------------------------------- /assets/formatter-friendly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/formatter-friendly.png -------------------------------------------------------------------------------- /assets/formatter-stylish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivachokkapu/revive-cc/HEAD/assets/formatter-stylish.png -------------------------------------------------------------------------------- /fixtures/golint/package-doc3.go: -------------------------------------------------------------------------------- 1 | // Test of block package comment. 2 | // OK 3 | 4 | /* 5 | Package foo is pretty sweet. 6 | */ 7 | package foo 8 | -------------------------------------------------------------------------------- /fixtures/lint-file-header3.go: -------------------------------------------------------------------------------- 1 | // baz baz qux 2 | // qux foo 3 | 4 | package fixtures // MATCH /the file doesn't have an appropriate header/ 5 | -------------------------------------------------------------------------------- /fixtures/golint/package-main.go: -------------------------------------------------------------------------------- 1 | // Test of package comment for package main. 2 | // OK 3 | 4 | // This binary does something awesome. 5 | package main 6 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/COMPATIBLE: -------------------------------------------------------------------------------- 1 | Compatible with TOML version 2 | [v0.4.0](https://github.com/toml-lang/toml/blob/v0.4.0/versions/en/toml-v0.4.0.md) 3 | 4 | -------------------------------------------------------------------------------- /fixtures/golint/package-doc1.go: -------------------------------------------------------------------------------- 1 | // Test of missing package comment. 2 | 3 | package foo // MATCH /should have a package comment, unless it's in another file for this package/ 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: test 2 | 3 | export GO111MODULE=on 4 | 5 | install: 6 | @go mod vendor 7 | 8 | build: 9 | @go build 10 | 11 | test: 12 | @go test -v ./test/... 13 | 14 | -------------------------------------------------------------------------------- /fixtures/var-naming.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func foo() string { 4 | customId := "result" 5 | customVm := "result" // MATCH /var customVm should be customVM/ 6 | return customId 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/golint/import-dot.go: -------------------------------------------------------------------------------- 1 | // Test that dot imports are flagged. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | import . "fmt" // MATCH /should not use dot imports/ 7 | 8 | var _ Stringer // from "fmt" 9 | -------------------------------------------------------------------------------- /fixtures/golint/package-doc4.go: -------------------------------------------------------------------------------- 1 | // Test of block package comment with leading space. 2 | 3 | /* 4 | Package foo is pretty sweet. 5 | MATCH /package comment should not have leading space/ 6 | */ 7 | package foo 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - 1.4 8 | - 1.5 9 | - 1.6 10 | - 1.7 11 | - 1.8 12 | - 1.9 13 | - "1.10" 14 | - tip 15 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go_import_path: github.com/pkg/errors 3 | go: 4 | - 1.4.3 5 | - 1.5.4 6 | - 1.6.2 7 | - 1.7.1 8 | - tip 9 | 10 | script: 11 | - go test -v ./... 12 | -------------------------------------------------------------------------------- /test/deep-exit_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestDeepExit(t *testing.T) { 10 | testRule(t, "deep-exit", &rule.DeepExitRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /test/flag-param_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestFlagParam(t *testing.T) { 10 | testRule(t, "flag-param", &rule.FlagParamRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /test/get-return_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestGetReturn(t *testing.T) { 10 | testRule(t, "get-return", &rule.GetReturnRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /fixtures/confusing-naming2.go: -------------------------------------------------------------------------------- 1 | // Test of confusing-naming rule. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | func aglobal() { // MATCH /Function 'aglobal' differs only by capitalization to other function in the same package/ 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/golint/package-doc2.go: -------------------------------------------------------------------------------- 1 | // Test of package comment in an incorrect form. 2 | 3 | // Some random package doc that isn't in the right form. 4 | // MATCH /package comment should be of the form "Package testdata ..."/ 5 | package testdata 6 | -------------------------------------------------------------------------------- /test/atomic_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // Atomic rule. 10 | func TestAtomic(t *testing.T) { 11 | testRule(t, "atomic", &rule.AtomicRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /test/unused-param_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestUnusedParam(t *testing.T) { 10 | testRule(t, "unused-param", &rule.UnusedParamRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_js.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package runewidth 4 | 5 | func IsEastAsian() bool { 6 | // TODO: Implement this for the web. Detect east asian in a compatible way, and return true. 7 | return false 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/max-public-structs.go: -------------------------------------------------------------------------------- 1 | // Package pkg ... 2 | package pkg // MATCH /you have exceeded the maximum number of public struct declarations/ 3 | 4 | type Foo struct { 5 | } 6 | 7 | type Bar struct { 8 | } 9 | 10 | type Baz struct { 11 | } 12 | -------------------------------------------------------------------------------- /test/import-shadowing_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestImportShadowing(t *testing.T) { 10 | testRule(t, "import-shadowing", &rule.ImportShadowingRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /test/unreachable-code_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestUnreachableCode(t *testing.T) { 10 | testRule(t, "unreachable-code", &rule.UnreachableCodeRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /fixtures/duplicated-imports.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import( 4 | "crypto/md5" 5 | "strings" 6 | _ "crypto/md5" // MATCH /Package "crypto/md5" already imported/ 7 | str "strings" // MATCH /Package "strings" already imported/ 8 | ) 9 | -------------------------------------------------------------------------------- /fixtures/flag-param.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func foo(a bool, b int) { // MATCH /parameter 'a' seems to be a control flag, avoid control coupling/ 4 | if a { 5 | 6 | } 7 | } 8 | 9 | func foo(a bool, b int) { 10 | str := mystruct{a, b} 11 | } 12 | -------------------------------------------------------------------------------- /test/confusing-results_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestConfusingResults(t *testing.T) { 10 | testRule(t, "confusing-results", &rule.ConfusingResultsRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /test/waitgroup-by-value_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestWaitGroupByValue(t *testing.T) { 10 | testRule(t, "waitgroup-by-value", &rule.WaitGroupByValueRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /test/duplicated-import_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestDuplicatedImports(t *testing.T) { 10 | testRule(t, "duplicated-imports", &rule.DuplicatedImportsRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /test/empty-block_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // TestEmptyBlock rule. 10 | func TestEmptyBlock(t *testing.T) { 11 | testRule(t, "empty-block", &rule.EmptyBlockRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /test/empty-lines_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // TestEmptyLines rule. 10 | func TestEmptyLines(t *testing.T) { 11 | testRule(t, "empty-lines", &rule.EmptyLinesRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /fixtures/golint/package-doc5.go: -------------------------------------------------------------------------------- 1 | // Test of detached package comment. 2 | 3 | /* 4 | Package foo is pretty sweet. 5 | */ 6 | 7 | package foo 8 | 9 | // MATCH:6 /package comment is detached; there should be no blank lines between it and the package statement/ 10 | -------------------------------------------------------------------------------- /test/call-to-gc_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // TestCallToGC test call-to-gc rule 10 | func TestCallToGC(t *testing.T) { 11 | testRule(t, "call-to-gc", &rule.CallToGCRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /test/modifies-value-receiver_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | func TestModifiesValRec(t *testing.T) { 10 | testRule(t, "modifies-value-receiver", &rule.ModifiesValRecRule{}) 11 | } 12 | -------------------------------------------------------------------------------- /test/struct-tag_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // TestStructTag tests struct-tag rule 10 | func TestStructTag(t *testing.T) { 11 | testRule(t, "struct-tag", &rule.StructTagRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /fixtures/imports-blacklist.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import ( 4 | "crypto/md5" // MATCH /should not use the following blacklisted import: "crypto/md5"/ 5 | "crypto/sha1" // MATCH /should not use the following blacklisted import: "crypto/sha1"/ 6 | "strings" 7 | "time" 8 | ) 9 | -------------------------------------------------------------------------------- /test/bool-literal-in-expr_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // BoolLiteral rule. 10 | func TestBoolLiteral(t *testing.T) { 11 | testRule(t, "bool-literal-in-expr", &rule.BoolLiteralRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /test/modifies-param_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // TestModifiesParam rule. 10 | func TestModifiesParam(t *testing.T) { 11 | testRule(t, "modifies-param", &rule.ModifiesParamRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | before_install: 5 | - go get github.com/mattn/goveralls 6 | - go get golang.org/x/tools/cmd/cover 7 | script: 8 | - $HOME/gopath/bin/goveralls -repotoken lAKAWPzcGsD3A8yBX3BGGtRUdJ6CaGERL 9 | -------------------------------------------------------------------------------- /test/confusing-naming_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // TestConfusingNaming rule. 10 | func TestConfusingNaming(t *testing.T) { 11 | testRule(t, "confusing-naming1", &rule.ConfusingNamingRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /test/superfluous-else_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // TestSuperfluousElse rule. 10 | func TestSuperfluousElse(t *testing.T) { 11 | testRule(t, "superfluous-else", &rule.SuperfluousElseRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /test/unnecessary-stmt_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // TestUnnecessaryStmt rule. 10 | func TestUnnecessaryStmt(t *testing.T) { 11 | testRule(t, "unnecessary-stmt", &rule.UnnecessaryStmtRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | 5 | before_install: 6 | - go get github.com/mattn/goveralls 7 | - go get golang.org/x/tools/cmd/cover 8 | script: 9 | - $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw 10 | -------------------------------------------------------------------------------- /fixtures/call-to-gc.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import ( 4 | "fmt" 5 | "runtime" 6 | ) 7 | 8 | func GC() { 9 | } 10 | 11 | func foo() { 12 | fmt.Println("just testing") 13 | GC() 14 | fixtures.GC() 15 | runtime.Goexit() 16 | runtime.GC() // MATCH /explicit call to the garbage collector/ 17 | } 18 | -------------------------------------------------------------------------------- /test/constant-logical-expr_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // ConstantLogicalExpr rule. 10 | func TestConstantLogicalExpr(t *testing.T) { 11 | testRule(t, "constant-logical-expr", &rule.ConstantLogicalExprRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /test/redefines-builtin-id_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/rule" 7 | ) 8 | 9 | // Tests RedefinesBuiltinID rule. 10 | func TestRedefinesBuiltinID(t *testing.T) { 11 | testRule(t, "redefines-builtin-id", &rule.RedefinesBuiltinIDRule{}) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /test/range-val-in-closure_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestRangeValInClosure(t *testing.T) { 11 | testRule(t, "range-val-in-closure", &rule.RangeValInClosureRule{}, &lint.RuleConfig{}) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.1 4 | - 1.2 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - 1.6 9 | - tip 10 | install: 11 | - go install ./... 12 | - go get github.com/BurntSushi/toml-test 13 | script: 14 | - export PATH="$PATH:$HOME/gopath/bin" 15 | - make test 16 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | 5 | os: 6 | - linux 7 | - osx 8 | 9 | before_install: 10 | - go get github.com/mattn/goveralls 11 | - go get golang.org/x/tools/cmd/cover 12 | script: 13 | - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5 14 | -------------------------------------------------------------------------------- /defaults.toml: -------------------------------------------------------------------------------- 1 | ignoreGeneratedHeader = false 2 | severity = "warning" 3 | confidence = 0.8 4 | errorCode = 0 5 | warningCode = 0 6 | 7 | [rule.imports-blacklist] 8 | [rule.go-routines] 9 | [rule.read-after-write] 10 | [rule.blacklisted-chaincode-imports] 11 | [rule.phantom-reads] 12 | [rule.range-over-map] 13 | [rule.global-variables] 14 | -------------------------------------------------------------------------------- /fixtures/golint/docs_test.go: -------------------------------------------------------------------------------- 1 | // This file ends in _test.go, so we should not warn about doc comments. 2 | // OK 3 | 4 | package pkg 5 | 6 | import "testing" 7 | 8 | type H int 9 | 10 | func TestSomething(t *testing.T) { 11 | } 12 | 13 | func TestSomething_suffix(t *testing.T) { 14 | } 15 | 16 | func ExampleBuffer_reader() { 17 | } 18 | -------------------------------------------------------------------------------- /fixtures/modifies-value-receiver.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | type data struct { 4 | num int 5 | key *string 6 | items map[string]bool 7 | } 8 | 9 | func (this data) vmethod() { 10 | this.num = 8 // MATCH /suspicious assignment to a by-value method receiver/ 11 | *this.key = "v.key" 12 | this.items["vmethod"] = true 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 7 | // terminal. This is also always false on this environment. 8 | func IsCygwinTerminal(fd uintptr) bool { 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /fixtures/golint/increment-decrement.go: -------------------------------------------------------------------------------- 1 | // Test for use of x++ and x--. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | func addOne(x int) int { 7 | x += 1 // MATCH /should replace x += 1 with x++/ 8 | return x 9 | } 10 | 11 | func subOneInLoop(y int) { 12 | for ; y > 0; y -= 1 { // MATCH /should replace y -= 1 with y--/ 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /formatter/severity.go: -------------------------------------------------------------------------------- 1 | package formatter 2 | 3 | import "github.com/mgechev/revive/lint" 4 | 5 | func severity(config lint.RulesConfig, failure lint.Failure) lint.Severity { 6 | if config, ok := config[failure.RuleName]; ok && config.Severity == lint.SeverityError { 7 | return lint.SeverityError 8 | } 9 | return lint.SeverityWarning 10 | } 11 | -------------------------------------------------------------------------------- /test/argument-limit_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestArgumentLimit(t *testing.T) { 11 | testRule(t, "argument-limit", &rule.ArgumentsLimitRule{}, &lint.RuleConfig{ 12 | Arguments: []interface{}{int64(3)}, 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /test/line-length-limit_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestLineLengthLimit(t *testing.T) { 11 | testRule(t, "line-length-limit", &rule.LineLengthLimitRule{}, &lint.RuleConfig{ 12 | Arguments: []interface{}{int64(100)}, 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /test/max-public-structs_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestMaxPublicStructs(t *testing.T) { 11 | testRule(t, "max-public-structs", &rule.MaxPublicStructsRule{}, &lint.RuleConfig{ 12 | Arguments: []interface{}{int64(1)}, 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /test/var-naming_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestVarNaming(t *testing.T) { 11 | testRule(t, "var-naming", &rule.VarNamingRule{}, &lint.RuleConfig{ 12 | Arguments: []interface{}{[]interface{}{"ID"}, []interface{}{"VM"}}, 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Go template 3 | # Binaries for programs and plugins 4 | *.exe 5 | *.exe~ 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Test binary, build with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | 16 | -------------------------------------------------------------------------------- /test/function-result-limit_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestFunctionResultsLimit(t *testing.T) { 11 | testRule(t, "function-result-limit", &rule.FunctionResultsLimitRule{}, &lint.RuleConfig{ 12 | Arguments: []interface{}{int64(3)}, 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /lint/formatter.go: -------------------------------------------------------------------------------- 1 | package lint 2 | 3 | // FormatterMetadata configuration of a formatter 4 | type FormatterMetadata struct { 5 | Name string 6 | Description string 7 | Sample string 8 | } 9 | 10 | // Formatter defines an interface for failure formatters 11 | type Formatter interface { 12 | Format(<-chan Failure, RulesConfig) (string, error) 13 | Name() string 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/go/internal/gcimporter/isAlias19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.9 6 | 7 | package gcimporter 8 | 9 | import "go/types" 10 | 11 | func isAlias(obj *types.TypeName) bool { 12 | return obj.IsAlias() 13 | } 14 | -------------------------------------------------------------------------------- /test/import-blacklist_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestImportsBlacklist(t *testing.T) { 11 | args := []interface{}{"crypto/md5", "crypto/sha1"} 12 | 13 | testRule(t, "imports-blacklist", &rule.ImportsBlacklistRule{}, &lint.RuleConfig{ 14 | Arguments: args, 15 | }) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | go install ./... 3 | 4 | test: install 5 | go test -v 6 | toml-test toml-test-decoder 7 | toml-test -encoder toml-test-encoder 8 | 9 | fmt: 10 | gofmt -w *.go */*.go 11 | colcheck *.go */*.go 12 | 13 | tags: 14 | find ./ -name '*.go' -print0 | xargs -0 gotags > TAGS 15 | 16 | push: 17 | git push origin master 18 | git push github master 19 | 20 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /fixtures/argument-limit.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func foo(a, b, c, d int) { // MATCH /maximum number of arguments per function exceeded; max 3 but got 4/ 4 | 5 | } 6 | 7 | func bar(a, b int) { 8 | 9 | } 10 | 11 | func baz(a string, b int) { 12 | 13 | } 14 | 15 | func qux(a string, b int, c int, d string, e int64) { // MATCH /maximum number of arguments per function exceeded; max 3 but got 5/ 16 | 17 | } 18 | -------------------------------------------------------------------------------- /fixtures/golint/exported.go: -------------------------------------------------------------------------------- 1 | // Package golint comment 2 | package golint 3 | 4 | type ( 5 | // O is a shortcut (alias) for map[string]interface{}, e.g. a JSON object. 6 | O = map[string]interface{} 7 | 8 | // A is shortcut for []O. 9 | A = []O 10 | 11 | // This Person type is simple 12 | Person = map[string]interface{} 13 | ) 14 | 15 | type Foo struct{} // MATCH /exported type Foo should have comment or be unexported/ 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/go/internal/gcimporter/isAlias18.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.9 6 | 7 | package gcimporter 8 | 9 | import "go/types" 10 | 11 | func isAlias(obj *types.TypeName) bool { 12 | return false // there are no type aliases before Go 1.9 13 | } 14 | -------------------------------------------------------------------------------- /fixtures/function-result-limit.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func foo() (a, b, c, d) { // MATCH /maximum number of return results per function exceeded; max 3 but got 4/ 4 | var a, b, c, d int 5 | } 6 | 7 | func bar(a, b int) { 8 | 9 | } 10 | 11 | func baz(a string, b int) { 12 | 13 | } 14 | 15 | func qux() (string, string, int, string, int) { // MATCH /maximum number of return results per function exceeded; max 3 but got 5/ 16 | 17 | } 18 | -------------------------------------------------------------------------------- /test/disable-annotations_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestDisabledAnnotations(t *testing.T) { 11 | testRule(t, "disable-annotations", &rule.ExportedRule{}, &lint.RuleConfig{}) 12 | } 13 | 14 | func TestModifiedAnnotations(t *testing.T) { 15 | testRule(t, "disable-annotations2", &rule.VarNamingRule{}, &lint.RuleConfig{}) 16 | } 17 | -------------------------------------------------------------------------------- /test/cyclomatic_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestCyclomatic(t *testing.T) { 11 | testRule(t, "cyclomatic", &rule.CyclomaticRule{}, &lint.RuleConfig{ 12 | Arguments: []interface{}{int64(1)}, 13 | }) 14 | testRule(t, "cyclomatic-2", &rule.CyclomaticRule{}, &lint.RuleConfig{ 15 | Arguments: []interface{}{int64(3)}, 16 | }) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build go1.9 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | type Signal = syscall.Signal 13 | type Errno = syscall.Errno 14 | type SysProcAttr = syscall.SysProcAttr 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/go/internal/gcimporter/newInterface11.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.11 6 | 7 | package gcimporter 8 | 9 | import "go/types" 10 | 11 | func newInterface(methods []*types.Func, embeddeds []types.Type) *types.Interface { 12 | return types.NewInterfaceType(methods, embeddeds) 13 | } 14 | -------------------------------------------------------------------------------- /fixtures/golint/time-naming.go: -------------------------------------------------------------------------------- 1 | // Test of time suffixes. 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | import ( 7 | "flag" 8 | "time" 9 | ) 10 | 11 | var rpcTimeoutMsec = flag.Duration("rpc_timeout", 100*time.Millisecond, "some flag") // MATCH /var rpcTimeoutMsec is of type *time.Duration; don't use unit-specific suffix "Msec"/ 12 | 13 | var timeoutSecs = 5 * time.Second // MATCH /var timeoutSecs is of type time.Duration; don't use unit-specific suffix "Secs"/ 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /fixtures/cyclomatic-2.go: -------------------------------------------------------------------------------- 1 | // Test of cyclomatic complexity. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | import "log" 7 | 8 | func f(x int) bool { // MATCH /function f has cyclomatic complexity 4/ 9 | if x > 0 && true || false { 10 | return true 11 | } else { 12 | log.Printf("non-positive x: %d", x) 13 | } 14 | return false 15 | } 16 | 17 | func g(f func() bool) string { 18 | if ok := f(); ok { 19 | return "it's okay" 20 | } else { 21 | return "it's NOT okay!" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /fixtures/modifies-param.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import ( 4 | "go/ast" 5 | ) 6 | 7 | func one(a int) { 8 | a,b:= 1,2 // MATCH /parameter 'a' seems to be modified/ 9 | a++ // MATCH /parameter 'a' seems to be modified/ 10 | } 11 | 12 | func two(b, c float32) { 13 | if c>0.0 { 14 | b = 1 // MATCH /parameter 'b' seems to be modified/ 15 | } 16 | } 17 | 18 | type foo struct { 19 | a string 20 | } 21 | 22 | func three(s *foo) { 23 | s.a = "foooooo" 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /fixtures/disable-annotations.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | //revive:disable 4 | func Public1() { 5 | } 6 | 7 | //revive:enable 8 | 9 | func Public2() { // MATCH /exported function Public2 should have comment or be unexported/ 10 | } 11 | 12 | //revive:disable:exported 13 | func Public3() { 14 | } 15 | 16 | //revive:enable:exported 17 | 18 | //revive:disable:random 19 | 20 | func Public4() { // MATCH /exported function Public4 should have comment or be unexported/ 21 | } 22 | 23 | //revive:enable:random 24 | -------------------------------------------------------------------------------- /test/add-constant_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestAddConstant(t *testing.T) { 11 | args := []interface{}{map[string]interface{}{ 12 | "maxLitCount": "2", 13 | "allowStrs": "\"\"", 14 | "allowInts": "0,1,2", 15 | "allowFloats": "0.0,1.0", 16 | }} 17 | 18 | testRule(t, "add-constant", &rule.AddConstantRule{}, &lint.RuleConfig{ 19 | Arguments: args, 20 | }) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine,!ppc64,!ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /fixtures/confusing-results.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func getfoo() (int, int, error) { // MATCH /unnamed results of the same type may be confusing, consider using named results/ 4 | 5 | } 6 | 7 | func getBar(a, b int) (int, error, int) { 8 | } 9 | 10 | func Getbaz(a string, b int) (int, float32, string, string) { // MATCH /unnamed results of the same type may be confusing, consider using named results/ 11 | 12 | } 13 | 14 | func GetTaz(a string, b int) string { 15 | 16 | } 17 | 18 | func (t *t) GetTaz(a int, b int) { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /untyped.toml: -------------------------------------------------------------------------------- 1 | [rule.blank-imports] 2 | [rule.context-as-argument] 3 | [rule.dot-imports] 4 | [rule.error-return] 5 | [rule.error-strings] 6 | [rule.error-naming] 7 | [rule.exported] 8 | [rule.if-return] 9 | [rule.increment-decrement] 10 | [rule.var-naming] 11 | [rule.package-comments] 12 | [rule.range] 13 | [rule.receiver-naming] 14 | [rule.indent-error-flow] 15 | [rule.empty-block] 16 | [rule.range-val-in-closure] 17 | [rule.waitgroup-by-value] 18 | [rule.atomic] 19 | [rule.empty-lines] 20 | [rule.line-length-limit] 21 | arguments = [200] 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /fixtures/cyclomatic.go: -------------------------------------------------------------------------------- 1 | // Test of cyclomatic complexity. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | import "log" 7 | 8 | func f(x int) bool { // MATCH /function f has cyclomatic complexity 4/ 9 | if x > 0 && true || false { 10 | return true 11 | } else { 12 | log.Printf("non-positive x: %d", x) 13 | } 14 | return false 15 | } 16 | 17 | func g(f func() bool) string { // MATCH /function g has cyclomatic complexity 2/ 18 | if ok := f(); ok { 19 | return "it's okay" 20 | } else { 21 | return "it's NOT okay!" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build ppc64 ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "unsafe" 8 | 9 | syscall "golang.org/x/sys/unix" 10 | ) 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | // IsTerminal return true if the file descriptor is terminal. 15 | func IsTerminal(fd uintptr) bool { 16 | var termios syscall.Termios 17 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 18 | return err == 0 19 | } 20 | -------------------------------------------------------------------------------- /fixtures/add-constant.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func foo(a, b, c, d int) { 4 | a = 1.0 // ignore 5 | b = "ignore" 6 | c = 2 // ignore 7 | println("lit", 12) // MATCH /avoid magic numbers like '12', create a named constant for it/ 8 | if a == 12.50 { // MATCH /avoid magic numbers like '12.50', create a named constant for it/ 9 | if b == "lit" { 10 | c = "lit" // MATCH /string literal "lit" appears, at least, 3 times, create a named constant for it/ 11 | } 12 | for i := 0; i < 1; i++ { 13 | println("lit") 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_windows.go: -------------------------------------------------------------------------------- 1 | package runewidth 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | var ( 8 | kernel32 = syscall.NewLazyDLL("kernel32") 9 | procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP") 10 | ) 11 | 12 | // IsEastAsian return true if the current locale is CJK 13 | func IsEastAsian() bool { 14 | r1, _, _ := procGetConsoleOutputCP.Call() 15 | if r1 == 0 { 16 | return false 17 | } 18 | 19 | switch int(r1) { 20 | case 932, 51932, 936, 949, 950: 21 | return true 22 | } 23 | 24 | return false 25 | } 26 | -------------------------------------------------------------------------------- /fixtures/waitgroup-by-value.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | func foo(a int, b float32, c char, d sync.WaitGroup) { // MATCH /sync.WaitGroup passed by value, the function will get a copy of the original one/ 8 | 9 | } 10 | 11 | func bar(a, b sync.WaitGroup) { // MATCH /sync.WaitGroup passed by value, the function will get a copy of the original one/ 12 | 13 | } 14 | 15 | func baz(zz sync.WaitGroup) { // MATCH /sync.WaitGroup passed by value, the function will get a copy of the original one/ 16 | 17 | } 18 | 19 | func ok(zz *sync.WaitGroup) { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /fixtures/line-length-limit.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import "fmt" 4 | 5 | func foo(a, b int) { 6 | fmt.Printf("single line characters out of limit") // MATCH /line is 105 characters, out of limit 100/ 7 | } 8 | 9 | // revive:disable-next-line:line-length-limit 10 | // The length of this comment line is over 80 characters, this is bad for readability. 11 | 12 | // Warn: the testing framework does not allow to check for failures in comments 13 | 14 | func toto() { 15 | // revive:disable-next-line:line-length-limit 16 | fmt.Println("This line is way too long. In my opinion, it should be shortened.") 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/encoding_types_1.1.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package toml 4 | 5 | // These interfaces were introduced in Go 1.2, so we add them manually when 6 | // compiling for Go 1.1. 7 | 8 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 9 | // so that Go 1.1 can be supported. 10 | type TextMarshaler interface { 11 | MarshalText() (text []byte, err error) 12 | } 13 | 14 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 15 | // here so that Go 1.1 can be supported. 16 | type TextUnmarshaler interface { 17 | UnmarshalText(text []byte) error 18 | } 19 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/mgechev/revive 2 | 3 | require ( 4 | github.com/BurntSushi/toml v0.3.0 5 | github.com/fatih/color v1.7.0 6 | github.com/fatih/structtag v1.0.0 7 | github.com/mattn/go-colorable v0.0.9 // indirect 8 | github.com/mattn/go-isatty v0.0.4 // indirect 9 | github.com/mattn/go-runewidth v0.0.3 // indirect 10 | github.com/mgechev/dots v0.0.0-20180605013149-8e09d8ea2757 11 | github.com/olekukonko/tablewriter v0.0.0-20180912035003-be2c049b30cc 12 | github.com/pkg/errors v0.8.0 13 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e // indirect 14 | golang.org/x/tools v0.0.0-20180911133044-677d2ff680c1 15 | ) 16 | -------------------------------------------------------------------------------- /fixtures/redefines-builtin-id.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func (this data) vmethod() { 4 | nil := true // MATCH /assignment creates a shadow of built-in identifier nil/ 5 | iota = 1 // MATCH /assignment modifies built-in identifier iota/ 6 | } 7 | 8 | func append(i, j int) { // MATCH /redefinition of the built-in function append/ 9 | 10 | } 11 | 12 | type Type int16 // MATCH /redefinition of the built-in type Type/ 13 | 14 | func delete(set []int64, i int) (y []int64) { // MATCH /redefinition of the built-in function delete/ 15 | for j, v := range set { 16 | if j != i { 17 | y = append(y, v) 18 | } 19 | } 20 | return 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | -------------------------------------------------------------------------------- /fixtures/golint/sort.go: -------------------------------------------------------------------------------- 1 | // Test that we don't ask for comments on sort.Interface methods. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | // T is ... 7 | type T []int 8 | 9 | // Len by itself should get documented. 10 | 11 | func (t T) Len() int { return len(t) } // MATCH /exported method T.Len should have comment or be unexported/ 12 | 13 | // U is ... 14 | type U []int 15 | 16 | func (u U) Len() int { return len(u) } 17 | func (u U) Less(i, j int) bool { return u[i] < u[j] } 18 | func (u U) Swap(i, j int) { u[i], u[j] = u[j], u[i] } 19 | 20 | func (u U) Other() {} // MATCH /exported method U.Other should have comment or be unexported/ 21 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/encoding_types.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package toml 4 | 5 | // In order to support Go 1.1, we define our own TextMarshaler and 6 | // TextUnmarshaler types. For Go 1.2+, we just alias them with the 7 | // standard library interfaces. 8 | 9 | import ( 10 | "encoding" 11 | ) 12 | 13 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 14 | // so that Go 1.1 can be supported. 15 | type TextMarshaler encoding.TextMarshaler 16 | 17 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 18 | // here so that Go 1.1 can be supported. 19 | type TextUnmarshaler encoding.TextUnmarshaler 20 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /fixtures/get-return.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func getfoo() { 4 | 5 | } 6 | 7 | func getBar(a, b int) { // MATCH /function 'getBar' seems to be a getter but it does not return any result/ 8 | 9 | } 10 | 11 | func Getbaz(a string, b int) { 12 | 13 | } 14 | 15 | func GetTaz(a string, b int) string { 16 | 17 | } 18 | 19 | func (t *t) GetTaz(a string, b int) string { 20 | 21 | } 22 | 23 | func (t *t) GetSaz(a string, b int) { // MATCH /function 'GetSaz' seems to be a getter but it does not return any result/ 24 | 25 | } 26 | 27 | func GetQux(a string, b int, c int, d string, e int64) { // MATCH /function 'GetQux' seems to be a getter but it does not return any result/ 28 | 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo,386 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | 15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /fixtures/golint/error-naming.go: -------------------------------------------------------------------------------- 1 | // Test for naming errors. 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | import ( 7 | "errors" 8 | "fmt" 9 | ) 10 | 11 | var unexp = errors.New("some unexported error") // MATCH /error var unexp should have name of the form errFoo/ 12 | 13 | // Exp ... 14 | var Exp = errors.New("some exported error") // MATCH /error var Exp should have name of the form ErrFoo/ 15 | 16 | var ( 17 | e1 = fmt.Errorf("blah %d", 4) // MATCH /error var e1 should have name of the form errFoo/ 18 | // E2 ... 19 | E2 = fmt.Errorf("blah %d", 5) // MATCH /error var E2 should have name of the form ErrFoo/ 20 | ) 21 | 22 | func f() { 23 | var whatever = errors.New("ok") // ok 24 | _ = whatever 25 | } 26 | -------------------------------------------------------------------------------- /formatter/default.go: -------------------------------------------------------------------------------- 1 | package formatter 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // Default is an implementation of the Formatter interface 10 | // which formats the errors to text. 11 | type Default struct { 12 | Metadata lint.FormatterMetadata 13 | } 14 | 15 | // Name returns the name of the formatter 16 | func (f *Default) Name() string { 17 | return "default" 18 | } 19 | 20 | // Format formats the failures gotten from the lint. 21 | func (f *Default) Format(failures <-chan lint.Failure, _ lint.RulesConfig) (string, error) { 22 | for failure := range failures { 23 | fmt.Printf("%v: %s\n", failure.Position.Start, failure.Failure) 24 | } 25 | return "", nil 26 | } 27 | -------------------------------------------------------------------------------- /fixtures/deep-exit.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import ( 4 | "syscall" 5 | "log" 6 | "os" 7 | ) 8 | 9 | func foo0() { 10 | os.Exit(1) // MATCH /calls to os.Exit only in main() or init() functions/ 11 | } 12 | 13 | func init() { 14 | log.Fatal("v ...interface{}") 15 | } 16 | 17 | func foo() { 18 | log.Fatalf(1) // MATCH /calls to log.Fatalf only in main() or init() functions/ 19 | } 20 | 21 | func main() { 22 | log.Fatalln("v ...interface{}") 23 | } 24 | 25 | func bar() { 26 | log.Fatal(1) // MATCH /calls to log.Fatal only in main() or init() functions/ 27 | } 28 | 29 | func bar2() { 30 | bar() 31 | syscall.Exit(1) // MATCH /calls to syscall.Exit only in main() or init() functions/ 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,gccgo,arm 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/go/internal/gcimporter/newInterface10.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.11 6 | 7 | package gcimporter 8 | 9 | import "go/types" 10 | 11 | func newInterface(methods []*types.Func, embeddeds []types.Type) *types.Interface { 12 | named := make([]*types.Named, len(embeddeds)) 13 | for i, e := range embeddeds { 14 | var ok bool 15 | named[i], ok = e.(*types.Named) 16 | if !ok { 17 | panic("embedding of non-defined interfaces in interfaces is not supported before Go 1.11") 18 | } 19 | } 20 | return types.NewInterface(methods, named) 21 | } 22 | -------------------------------------------------------------------------------- /formatter/plain.go: -------------------------------------------------------------------------------- 1 | package formatter 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // Plain is an implementation of the Formatter interface 10 | // which formats the errors to JSON. 11 | type Plain struct { 12 | Metadata lint.FormatterMetadata 13 | } 14 | 15 | // Name returns the name of the formatter 16 | func (f *Plain) Name() string { 17 | return "plain" 18 | } 19 | 20 | // Format formats the failures gotten from the lint. 21 | func (f *Plain) Format(failures <-chan lint.Failure, _ lint.RulesConfig) (string, error) { 22 | for failure := range failures { 23 | fmt.Printf("%v: %s %s\n", failure.Position.Start, failure.Failure, "https://revive.run/r#"+failure.RuleName) 24 | } 25 | return "", nil 26 | } 27 | -------------------------------------------------------------------------------- /fixtures/golint/context-as-argument.go: -------------------------------------------------------------------------------- 1 | // Test that context.Context is the first arg to a function. 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | import ( 7 | "context" 8 | ) 9 | 10 | // A proper context.Context location 11 | func x(ctx context.Context) { // ok 12 | } 13 | 14 | // A proper context.Context location 15 | func x(ctx context.Context, s string) { // ok 16 | } 17 | 18 | // An invalid context.Context location 19 | func y(s string, ctx context.Context) { // MATCH /context.Context should be the first parameter of a function/ 20 | } 21 | 22 | // An invalid context.Context location with more than 2 args 23 | func y(s string, r int, ctx context.Context, x int) { // MATCH /context.Context should be the first parameter of a function/ 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /lint/config.go: -------------------------------------------------------------------------------- 1 | package lint 2 | 3 | // Arguments is type used for the arguments of a rule. 4 | type Arguments = []interface{} 5 | 6 | // RuleConfig is type used for the rule configuration. 7 | type RuleConfig struct { 8 | Arguments Arguments 9 | Severity Severity 10 | } 11 | 12 | // RulesConfig defines the config for all rules. 13 | type RulesConfig = map[string]RuleConfig 14 | 15 | // Config defines the config of the linter. 16 | type Config struct { 17 | IgnoreGeneratedHeader bool `toml:"ignoreGeneratedHeader"` 18 | Confidence float64 19 | Severity Severity 20 | Rules RulesConfig `toml:"rule"` 21 | ErrorCode int `toml:"errorCode"` 22 | WarningCode int `toml:"warningCode"` 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /fixtures/golint/range.go: -------------------------------------------------------------------------------- 1 | // Test for range construction. 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | func f() { 7 | var m map[string]int 8 | 9 | // with := 10 | for x, _ := range m { // MATCH /should omit 2nd value from range; this loop is equivalent to `for x := range ...`/ 11 | _ = x 12 | } 13 | // with = 14 | var y string 15 | _ = y 16 | for y, _ = range m { // MATCH /should omit 2nd value from range; this loop is equivalent to `for y = range ...`/ 17 | } 18 | 19 | // all OK: 20 | for x := range m { 21 | _ = x 22 | } 23 | for x, y := range m { 24 | _, _ = x, y 25 | } 26 | for _, y := range m { 27 | _ = y 28 | } 29 | var x int 30 | _ = x 31 | for y = range m { 32 | } 33 | for y, x = range m { 34 | } 35 | for _, x = range m { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | _ "github.com/mattn/go-isatty" 10 | ) 11 | 12 | // NewColorable return new instance of Writer which handle escape sequence. 13 | func NewColorable(file *os.File) io.Writer { 14 | if file == nil { 15 | panic("nil passed instead of *os.File to NewColorable()") 16 | } 17 | 18 | return file 19 | } 20 | 21 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 22 | func NewColorableStdout() io.Writer { 23 | return os.Stdout 24 | } 25 | 26 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 27 | func NewColorableStderr() io.Writer { 28 | return os.Stderr 29 | } 30 | -------------------------------------------------------------------------------- /lint/rule.go: -------------------------------------------------------------------------------- 1 | package lint 2 | 3 | import ( 4 | "go/token" 5 | ) 6 | 7 | // DisabledInterval contains a single disabled interval and the associated rule name. 8 | type DisabledInterval struct { 9 | From token.Position 10 | To token.Position 11 | RuleName string 12 | } 13 | 14 | // Rule defines an abstract rule interaface 15 | type Rule interface { 16 | Name() string 17 | Apply(*File, Arguments) []Failure 18 | } 19 | 20 | // AbstractRule defines an abstract rule. 21 | type AbstractRule struct { 22 | Failures []Failure 23 | } 24 | 25 | // ToFailurePosition returns the failure position. 26 | func ToFailurePosition(start token.Pos, end token.Pos, file *File) FailurePosition { 27 | return FailurePosition{ 28 | Start: file.ToPosition(start), 29 | End: file.ToPosition(end), 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: build-{build}.{branch} 2 | 3 | clone_folder: C:\gopath\src\github.com\pkg\errors 4 | shallow_clone: true # for startup speed 5 | 6 | environment: 7 | GOPATH: C:\gopath 8 | 9 | platform: 10 | - x64 11 | 12 | # http://www.appveyor.com/docs/installed-software 13 | install: 14 | # some helpful output for debugging builds 15 | - go version 16 | - go env 17 | # pre-installed MinGW at C:\MinGW is 32bit only 18 | # but MSYS2 at C:\msys64 has mingw64 19 | - set PATH=C:\msys64\mingw64\bin;%PATH% 20 | - gcc --version 21 | - g++ --version 22 | 23 | build_script: 24 | - go install -v ./... 25 | 26 | test_script: 27 | - set PATH=C:\gopath\bin;%PATH% 28 | - go test -v ./... 29 | 30 | #artifacts: 31 | # - path: '%GOPATH%\bin\*.exe' 32 | deploy: off 33 | -------------------------------------------------------------------------------- /fixtures/disable-annotations2.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func foo1() { 4 | //revive:disable-next-line:var-naming 5 | var invalid_name = 0 6 | var invalid_name2 = 1 //revive:disable-line:var-naming 7 | } 8 | 9 | func foo2() { 10 | // revive:disable-next-line:var-naming 11 | //revive:disable 12 | var invalid_name = 0 13 | var invalid_name2 = 1 14 | } 15 | 16 | func foo3() { 17 | //revive:enable 18 | // revive:disable-next-line:var-naming 19 | var invalid_name = 0 20 | // not a valid annotation revive:disable-next-line:var-naming 21 | var invalid_name2 = 1 // MATCH /don't use underscores in Go names; var invalid_name2 should be invalidName2/ 22 | /* revive:disable-next-line:var-naming */ 23 | var invalid_name3 = 0 // MATCH /don't use underscores in Go names; var invalid_name3 should be invalidName3/ 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable return new instance of Writer which handle escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /formatter/unix.go: -------------------------------------------------------------------------------- 1 | package formatter 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // Unix is an implementation of the Formatter interface 10 | // which formats the errors to a simple line based error format 11 | // main.go:24:9: [errorf] should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) 12 | type Unix struct { 13 | Metadata lint.FormatterMetadata 14 | } 15 | 16 | // Name returns the name of the formatter 17 | func (f *Unix) Name() string { 18 | return "unix" 19 | } 20 | 21 | // Format formats the failures gotten from the lint. 22 | func (f *Unix) Format(failures <-chan lint.Failure, _ lint.RulesConfig) (string, error) { 23 | for failure := range failures { 24 | fmt.Printf("%v: [%s] %s\n", failure.Position.Start, failure.RuleName, failure.Failure) 25 | } 26 | return "", nil 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | 24 | [[constraint]] 25 | name = "github.com/mattn/go-colorable" 26 | version = "0.0.9" 27 | 28 | [[constraint]] 29 | name = "github.com/mattn/go-isatty" 30 | version = "0.0.3" 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /fixtures/import-shadowing.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import ( 4 | ast "go/ast" 5 | "bytes" 6 | "crypto/md5" 7 | "fmt" 8 | _ "net/http" 9 | "strings" 10 | str "strings" 11 | ) 12 | 13 | const str = "" // MATCH /The name 'str' shadows an import name/ 14 | 15 | type myAst struct { 16 | ast *ast.GenDecl 17 | } 18 | 19 | type bytes struct {} // MATCH /The name 'bytes' shadows an import name/ 20 | 21 | type fmt interface {} // MATCH /The name 'fmt' shadows an import name/ 22 | 23 | func (ast myAst) foo() {} // MATCH /The name 'ast' shadows an import name/ 24 | 25 | func md5() {} // MATCH /The name 'md5' shadows an import name/ 26 | 27 | func bar(_ string) {} 28 | 29 | func toto() { 30 | strings := map[string]string{} // MATCH /The name 'strings' shadows an import name/ 31 | } 32 | 33 | func titi() { 34 | v := md5+bytes 35 | return ast 36 | } 37 | -------------------------------------------------------------------------------- /fixtures/unreachable-code.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | ) 8 | 9 | func foo() int { 10 | log.Fatalf("%s", "About to fail") // ignore 11 | return 0 // MATCH /unreachable code after this statement/ 12 | return 1 13 | Println("unreachable") 14 | } 15 | 16 | func f() { 17 | fmt.Println("Hello, playground") 18 | if true { 19 | return // MATCH /unreachable code after this statement/ 20 | Println("unreachable") 21 | os.Exit(2) // ignore 22 | Println("also unreachable") 23 | } 24 | return // MATCH /unreachable code after this statement/ 25 | fmt.Println("Bye, playground") 26 | } 27 | 28 | func g() { 29 | fmt.Println("Hello, playground") 30 | if true { 31 | return // ignore if next stmt is labeled 32 | label: 33 | os.Exit(2) // ignore 34 | } 35 | 36 | fmt.Println("Bye, playground") 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | name = "github.com/mattn/go-colorable" 6 | packages = ["."] 7 | revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" 8 | version = "v0.0.9" 9 | 10 | [[projects]] 11 | name = "github.com/mattn/go-isatty" 12 | packages = ["."] 13 | revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" 14 | version = "v0.0.3" 15 | 16 | [[projects]] 17 | branch = "master" 18 | name = "golang.org/x/sys" 19 | packages = ["unix"] 20 | revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd" 21 | 22 | [solve-meta] 23 | analyzer-name = "dep" 24 | analyzer-version = 1 25 | inputs-digest = "e8a50671c3cb93ea935bf210b1cd20702876b9d9226129be581ef646d1565cdc" 26 | solver-name = "gps-cdcl" 27 | solver-version = 1 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /formatter/ndjson.go: -------------------------------------------------------------------------------- 1 | package formatter 2 | 3 | import ( 4 | "encoding/json" 5 | "os" 6 | 7 | "github.com/mgechev/revive/lint" 8 | ) 9 | 10 | // NDJSON is an implementation of the Formatter interface 11 | // which formats the errors to NDJSON stream. 12 | type NDJSON struct { 13 | Metadata lint.FormatterMetadata 14 | } 15 | 16 | // Name returns the name of the formatter 17 | func (f *NDJSON) Name() string { 18 | return "ndjson" 19 | } 20 | 21 | // Format formats the failures gotten from the lint. 22 | func (f *NDJSON) Format(failures <-chan lint.Failure, config lint.RulesConfig) (string, error) { 23 | enc := json.NewEncoder(os.Stdout) 24 | for failure := range failures { 25 | obj := jsonObject{} 26 | obj.Severity = severity(config, failure) 27 | obj.Failure = failure 28 | err := enc.Encode(obj) 29 | if err != nil { 30 | return "", err 31 | } 32 | } 33 | return "", nil 34 | } 35 | -------------------------------------------------------------------------------- /test/file-header_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mgechev/revive/lint" 7 | "github.com/mgechev/revive/rule" 8 | ) 9 | 10 | func TestLintFileHeader(t *testing.T) { 11 | testRule(t, "lint-file-header1", &rule.FileHeaderRule{}, &lint.RuleConfig{ 12 | Arguments: []interface{}{"foobar"}, 13 | }) 14 | 15 | testRule(t, "lint-file-header2", &rule.FileHeaderRule{}, &lint.RuleConfig{ 16 | Arguments: []interface{}{"foobar"}, 17 | }) 18 | 19 | testRule(t, "lint-file-header3", &rule.FileHeaderRule{}, &lint.RuleConfig{ 20 | Arguments: []interface{}{"foobar"}, 21 | }) 22 | 23 | testRule(t, "lint-file-header4", &rule.FileHeaderRule{}, &lint.RuleConfig{ 24 | Arguments: []interface{}{"^\\sfoobar$"}, 25 | }) 26 | 27 | testRule(t, "lint-file-header5", &rule.FileHeaderRule{}, &lint.RuleConfig{ 28 | Arguments: []interface{}{"^\\sfoo.*bar$"}, 29 | }) 30 | } 31 | -------------------------------------------------------------------------------- /fixtures/empty-block.go: -------------------------------------------------------------------------------- 1 | // Test of empty-blocks. 2 | 3 | package fixtures 4 | 5 | func f(x int) bool {} // Must not match 6 | 7 | type foo struct {} 8 | 9 | func (f foo) f(x *int) string {} // Must not match 10 | func (f *foo) g(y *int) string {} // Must not match 11 | 12 | func g(f func() bool) string { 13 | { // MATCH /this block is empty, you can remove it/ 14 | } 15 | 16 | a := func(e error){} // Must not match 17 | 18 | if ok := f(); ok { // MATCH /this block is empty, you can remove it/ 19 | // only a comment 20 | } else { 21 | println("it's NOT empty!") 22 | } 23 | 24 | if ok := f(); ok { 25 | println("it's NOT empty!") 26 | } else { // MATCH /this block is empty, you can remove it/ 27 | 28 | } 29 | 30 | for i := 0; i < 10; i++ { // MATCH /this block is empty, you can remove it/ 31 | 32 | } 33 | 34 | for { // MATCH /this block is empty, you can remove it/ 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /fixtures/golint/stutter.go: -------------------------------------------------------------------------------- 1 | // Test of stuttery names. 2 | 3 | // Package donut ... 4 | package donut 5 | 6 | // DonutMaker makes donuts. 7 | type DonutMaker struct{} // MATCH /type name will be used as donut.DonutMaker by other packages, and that stutters; consider calling this Maker/ 8 | 9 | // DonutRank computes the ranking of a donut. 10 | func DonutRank(d Donut) int { // MATCH /func name will be used as donut.DonutRank by other packages, and that stutters; consider calling this Rank/ 11 | return 0 12 | } 13 | 14 | // Donut is a delicious treat. 15 | type Donut struct{} // ok because it is the whole name 16 | 17 | // Donuts are great, aren't they? 18 | type Donuts []Donut // ok because it didn't start a new word 19 | 20 | type donutGlaze int // ok because it is unexported 21 | 22 | // DonutMass reports the mass of a donut. 23 | func (d *Donut) DonutMass() (grams int) { // okay because it is a method 24 | return 38 25 | } 26 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/BurntSushi/toml v0.3.0 2 | github.com/BurntSushi/toml 3 | # github.com/fatih/color v1.7.0 4 | github.com/fatih/color 5 | # github.com/fatih/structtag v1.0.0 6 | github.com/fatih/structtag 7 | # github.com/mattn/go-colorable v0.0.9 8 | github.com/mattn/go-colorable 9 | # github.com/mattn/go-isatty v0.0.4 10 | github.com/mattn/go-isatty 11 | # github.com/mattn/go-runewidth v0.0.3 12 | github.com/mattn/go-runewidth 13 | # github.com/mgechev/dots v0.0.0-20180605013149-8e09d8ea2757 14 | github.com/mgechev/dots 15 | # github.com/olekukonko/tablewriter v0.0.0-20180912035003-be2c049b30cc 16 | github.com/olekukonko/tablewriter 17 | # github.com/pkg/errors v0.8.0 18 | github.com/pkg/errors 19 | # golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e 20 | golang.org/x/sys/unix 21 | # golang.org/x/tools v0.0.0-20180911133044-677d2ff680c1 22 | golang.org/x/tools/go/gcexportdata 23 | golang.org/x/tools/go/internal/gcimporter 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/README.mkd: -------------------------------------------------------------------------------- 1 | go-runewidth 2 | ============ 3 | 4 | [![Build Status](https://travis-ci.org/mattn/go-runewidth.png?branch=master)](https://travis-ci.org/mattn/go-runewidth) 5 | [![Coverage Status](https://coveralls.io/repos/mattn/go-runewidth/badge.png?branch=HEAD)](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD) 6 | [![GoDoc](https://godoc.org/github.com/mattn/go-runewidth?status.svg)](http://godoc.org/github.com/mattn/go-runewidth) 7 | [![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-runewidth)](https://goreportcard.com/report/github.com/mattn/go-runewidth) 8 | 9 | Provides functions to get fixed width of the character or string. 10 | 11 | Usage 12 | ----- 13 | 14 | ```go 15 | runewidth.StringWidth("つのだ☆HIRO") == 12 16 | ``` 17 | 18 | 19 | Author 20 | ------ 21 | 22 | Yasuhiro Matsumoto 23 | 24 | License 25 | ------- 26 | 27 | under the MIT License: http://mattn.mit-license.org/2013 28 | -------------------------------------------------------------------------------- /lint/failure.go: -------------------------------------------------------------------------------- 1 | package lint 2 | 3 | import ( 4 | "go/ast" 5 | "go/token" 6 | ) 7 | 8 | const ( 9 | // SeverityWarning declares failures of type warning 10 | SeverityWarning = "warning" 11 | // SeverityError declares failures of type error. 12 | SeverityError = "error" 13 | ) 14 | 15 | // Severity is the type for the failure types. 16 | type Severity string 17 | 18 | // FailurePosition returns the failure position 19 | type FailurePosition struct { 20 | Start token.Position 21 | End token.Position 22 | } 23 | 24 | // Failure defines a struct for a linting failure. 25 | type Failure struct { 26 | Failure string 27 | RuleName string 28 | Category string 29 | Position FailurePosition 30 | Node ast.Node `json:"-"` 31 | Confidence float64 32 | // For future use 33 | ReplacementLine string 34 | } 35 | 36 | // GetFilename returns the filename. 37 | func (f *Failure) GetFilename() string { 38 | return f.Position.Start.Filename 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print < 10 { 14 | return errors.New(fmt.Sprintf("something %d", x)) // MATCH /should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...)/ -> return fmt.Errorf("something %d", x)` 15 | } 16 | if x > 5 { 17 | return errors.New(g("blah")) // ok 18 | } 19 | if x > 4 { 20 | return errors.New("something else") // ok 21 | } 22 | return nil 23 | } 24 | 25 | // TestF is a dummy test 26 | func TestF(t *testing.T) error { 27 | x := 1 28 | if x > 10 { 29 | return t.Error(fmt.Sprintf("something %d", x)) // MATCH /should replace t.Error(fmt.Sprintf(...)) with t.Errorf(...)/ 30 | } 31 | if x > 5 { 32 | return t.Error(g("blah")) // ok 33 | } 34 | if x > 4 { 35 | return t.Error("something else") // ok 36 | } 37 | return nil 38 | } 39 | 40 | func g(s string) string { return "prefix: " + s } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /formatter/json.go: -------------------------------------------------------------------------------- 1 | package formatter 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // JSON is an implementation of the Formatter interface 10 | // which formats the errors to JSON. 11 | type JSON struct { 12 | Metadata lint.FormatterMetadata 13 | } 14 | 15 | // Name returns the name of the formatter 16 | func (f *JSON) Name() string { 17 | return "json" 18 | } 19 | 20 | // jsonObject defines a JSON object of an failure 21 | type jsonObject struct { 22 | Severity lint.Severity 23 | lint.Failure `json:",inline"` 24 | } 25 | 26 | // Format formats the failures gotten from the lint. 27 | func (f *JSON) Format(failures <-chan lint.Failure, config lint.RulesConfig) (string, error) { 28 | var slice []jsonObject 29 | for failure := range failures { 30 | obj := jsonObject{} 31 | obj.Severity = severity(config, failure) 32 | obj.Failure = failure 33 | slice = append(slice, obj) 34 | } 35 | result, err := json.Marshal(slice) 36 | if err != nil { 37 | return "", err 38 | } 39 | return string(result), err 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "runtime" 10 | 11 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 12 | // 13 | // To change fd's window size, the req argument should be TIOCSWINSZ. 14 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 15 | // TODO: if we get the chance, remove the req parameter and 16 | // hardcode TIOCSWINSZ. 17 | err := ioctlSetWinsize(fd, req, value) 18 | runtime.KeepAlive(value) 19 | return err 20 | } 21 | 22 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 23 | // 24 | // The req value will usually be TCSETA or TIOCSETA. 25 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 26 | // TODO: if we get the chance, remove the req parameter. 27 | err := ioctlSetTermios(fd, req, value) 28 | runtime.KeepAlive(value) 29 | return err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc64 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: sec, Nsec: nsec} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /fixtures/unnecessary-stmt.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func foo(a, b, c, d int) { 4 | switch n := node.(type) { // MATCH /switch with only one case can be replaced by an if-then/ 5 | case *ast.SwitchStmt: 6 | caseSelector := func(n ast.Node) bool { 7 | _, ok := n.(*ast.CaseClause) 8 | return ok 9 | } 10 | cases := pick(n.Body, caseSelector, nil) 11 | if len(cases) == 1 { 12 | cs, ok := cases[0].(*ast.CaseClause) 13 | if ok && len(cs.List) == 1 { 14 | w.onFailure(lint.Failure{ 15 | Confidence: 1, 16 | Node: n, 17 | Category: "style", 18 | Failure: "switch can be replaced by an if-then", 19 | }) 20 | } 21 | } 22 | } 23 | } 24 | 25 | func bar() { 26 | a := 1 27 | 28 | switch a { 29 | case 1, 2: 30 | a++ 31 | } 32 | 33 | loop: 34 | for { 35 | switch a { 36 | case 1: 37 | a++ 38 | println("one") 39 | break // MATCH /omit unnecessary break at the end of case clause/ 40 | case 2: 41 | println("two") 42 | break loop 43 | default: 44 | println("default") 45 | } 46 | } 47 | 48 | return // MATCH /omit unnecessary return statement/ 49 | } 50 | -------------------------------------------------------------------------------- /fixtures/range-val-in-closure.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import "fmt" 4 | 5 | func foo() { 6 | mySlice := []string{"A", "B", "C"} 7 | for index, value := range mySlice { 8 | go func() { 9 | fmt.Printf("Index: %d\n", index) // MATCH /loop variable index captured by func literal/ 10 | fmt.Printf("Value: %s\n", value) // MATCH /loop variable value captured by func literal/ 11 | }() 12 | } 13 | 14 | myDict := make(map[string]int) 15 | myDict["A"] = 1 16 | myDict["B"] = 2 17 | myDict["C"] = 3 18 | for key, value := range myDict { 19 | defer func() { 20 | fmt.Printf("Index: %d\n", key) // MATCH /loop variable key captured by func literal/ 21 | fmt.Printf("Value: %s\n", value) // MATCH /loop variable value captured by func literal/ 22 | }() 23 | } 24 | 25 | for i, newg := range groups { 26 | go func(newg int) { 27 | newg.run(m.opts.Context,i) // MATCH /loop variable i captured by func literal/ 28 | }(newg) 29 | } 30 | 31 | for i, newg := range groups { 32 | newg := newg 33 | go func() { 34 | newg.run(m.opts.Context,i) // MATCH /loop variable i captured by func literal/ 35 | }() 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 16 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 17 | valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg)) 18 | var err error 19 | if errno != 0 { 20 | err = errno 21 | } 22 | return int(valptr), err 23 | } 24 | 25 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 26 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 27 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 28 | if errno == 0 { 29 | return nil 30 | } 31 | return errno 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,gccgo,386 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | 22 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 23 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 24 | return int(fd), err 25 | } 26 | 27 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 28 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 29 | return int(fd), err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/LICENCE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 by Oleku Konko 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Fatih Arslan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /fixtures/golint/indent-error-flow.go: -------------------------------------------------------------------------------- 1 | // Test of return+else warning. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | import "log" 7 | 8 | func f(x int) bool { 9 | if x > 0 { 10 | return true 11 | } else { // MATCH /if block ends with a return statement, so drop this else and outdent its block/ 12 | log.Printf("non-positive x: %d", x) 13 | } 14 | return false 15 | } 16 | 17 | func g(f func() bool) string { 18 | if ok := f(); ok { 19 | return "it's okay" 20 | } else { // MATCH /if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)/ 21 | return "it's NOT okay!" 22 | } 23 | } 24 | 25 | func h(f func() bool, x int) string { 26 | if err == author.ErrCourseNotFound { 27 | return 28 | } else if err == author.ErrCourseAccess { 29 | // side effect 30 | } else if err == author.AnotherError { 31 | return "okay" 32 | } else { 33 | if ok := f(); ok { 34 | return "it's okay" 35 | } else { // MATCH /if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)/ 36 | return "it's NOT okay!" 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /fixtures/golint/const-block.go: -------------------------------------------------------------------------------- 1 | // Test for docs in const blocks 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | const ( 7 | // Prefix for something. 8 | // MATCH /comment on exported const InlineWhatever should be of the form "InlineWhatever ..."/ 9 | InlineWhatever = "blah" 10 | 11 | Whatsit = "missing_comment" // MATCH /exported const Whatsit should have comment (or a comment on this block) or be unexported/ 12 | 13 | // We should only warn once per block for missing comments, 14 | // but always complain about malformed comments. 15 | 16 | WhosYourDaddy = "another_missing_one" 17 | 18 | // Something 19 | // MATCH /comment on exported const WhatDoesHeDo should be of the form "WhatDoesHeDo ..."/ 20 | WhatDoesHeDo = "it's not a tumor!" 21 | ) 22 | 23 | // These shouldn't need doc comments. 24 | const ( 25 | Alpha = "a" 26 | Beta = "b" 27 | Gamma = "g" 28 | ) 29 | 30 | // The comment on the previous const block shouldn't flow through to here. 31 | 32 | const UndocAgain = 6 // MATCH /exported const UndocAgain should have comment or be unexported/ 33 | 34 | const ( 35 | SomeUndocumented = 7 // MATCH /exported const SomeUndocumented should have comment (or a comment on this block) or be unexported/ 36 | ) 37 | -------------------------------------------------------------------------------- /fixtures/golint/receiver-naming.go: -------------------------------------------------------------------------------- 1 | // Test for bad receiver names. 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | type foo struct{} 7 | 8 | func (this foo) f1() { // MATCH /receiver name should be a reflection of its identity; don't use generic names such as "this" or "self"/ 9 | } 10 | 11 | func (self foo) f2() { // MATCH /receiver name should be a reflection of its identity; don't use generic names such as "this" or "self"/ 12 | } 13 | 14 | func (f foo) f3() { 15 | } 16 | 17 | func (foo) f4() { 18 | } 19 | 20 | type bar struct{} 21 | 22 | func (b bar) f1() { 23 | } 24 | 25 | func (b bar) f2() { 26 | } 27 | 28 | func (a bar) f3() { // MATCH /receiver name a should be consistent with previous receiver name b for bar/ 29 | } 30 | 31 | func (a *bar) f4() { // MATCH /receiver name a should be consistent with previous receiver name b for bar/ 32 | } 33 | 34 | func (b *bar) f5() { 35 | } 36 | 37 | func (bar) f6() { 38 | } 39 | 40 | func (_ *bar) f7() { // MATCH /receiver name should not be an underscore, omit the name if it is unused/ 41 | } 42 | 43 | type multiError struct{} 44 | 45 | func (me multiError) f8() { 46 | } 47 | 48 | // Regression test for a panic caused by ill-formed receiver type. 49 | func (recv []*x.y) f() 50 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // NonColorable hold writer but remove escape sequence. 9 | type NonColorable struct { 10 | out io.Writer 11 | } 12 | 13 | // NewNonColorable return new instance of Writer which remove escape sequence from Writer. 14 | func NewNonColorable(w io.Writer) io.Writer { 15 | return &NonColorable{out: w} 16 | } 17 | 18 | // Write write data on console 19 | func (w *NonColorable) Write(data []byte) (n int, err error) { 20 | er := bytes.NewReader(data) 21 | var bw [1]byte 22 | loop: 23 | for { 24 | c1, err := er.ReadByte() 25 | if err != nil { 26 | break loop 27 | } 28 | if c1 != 0x1b { 29 | bw[0] = c1 30 | w.out.Write(bw[:]) 31 | continue 32 | } 33 | c2, err := er.ReadByte() 34 | if err != nil { 35 | break loop 36 | } 37 | if c2 != 0x5b { 38 | continue 39 | } 40 | 41 | var buf bytes.Buffer 42 | for { 43 | c, err := er.ReadByte() 44 | if err != nil { 45 | break loop 46 | } 47 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 48 | break 49 | } 50 | buf.Write([]byte(string(c))) 51 | } 52 | } 53 | 54 | return len(data), nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package toml provides facilities for decoding and encoding TOML configuration 3 | files via reflection. There is also support for delaying decoding with 4 | the Primitive type, and querying the set of keys in a TOML document with the 5 | MetaData type. 6 | 7 | The specification implemented: https://github.com/toml-lang/toml 8 | 9 | The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify 10 | whether a file is a valid TOML document. It can also be used to print the 11 | type of each key in a TOML document. 12 | 13 | Testing 14 | 15 | There are two important types of tests used for this package. The first is 16 | contained inside '*_test.go' files and uses the standard Go unit testing 17 | framework. These tests are primarily devoted to holistically testing the 18 | decoder and encoder. 19 | 20 | The second type of testing is used to verify the implementation's adherence 21 | to the TOML specification. These tests have been factored into their own 22 | project: https://github.com/BurntSushi/toml-test 23 | 24 | The reason the tests are in a separate project is so that they can be used by 25 | any implementation of TOML. Namely, it is language agnostic. 26 | */ 27 | package toml 28 | -------------------------------------------------------------------------------- /fixtures/golint/blank-import-lib.go: -------------------------------------------------------------------------------- 1 | // Test that blank imports in library packages are flagged. 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | // The instructions need to go before the imports below so they will not be 7 | // mistaken for documentation. 8 | 9 | import _ "encoding/json" 10 | 11 | /* MATCH:9 /a blank import should be only in a main or test package, or have a comment justifying it/ */ 12 | 13 | import ( 14 | "fmt" 15 | 16 | _ "os" 17 | /* MATCH:16 /a blank import should be only in a main or test package, or have a comment justifying it/ */ 18 | 19 | _ "net/http" 20 | /* MATCH:19 /a blank import should be only in a main or test package, or have a comment justifying it/ */ 21 | _ "path" 22 | ) 23 | 24 | import _ "encoding/base64" // Don't gripe about this 25 | 26 | import ( 27 | // Don't gripe about these next two lines. 28 | _ "compress/zlib" 29 | 30 | _ "syscall" 31 | /* MATCH:30 /a blank import should be only in a main or test package, or have a comment justifying it/ */ 32 | _ "path/filepath" 33 | ) 34 | 35 | import ( 36 | "go/ast" 37 | _ "go/scanner" // Don't gripe about this or the following line. 38 | _ "go/token" 39 | ) 40 | 41 | var ( 42 | _ fmt.Stringer // for "fmt" 43 | _ ast.Node // for "go/ast" 44 | ) 45 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | // +build !aix 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define _STRINGIFY2_(x) #x 13 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 14 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 15 | 16 | // Call syscall from C code because the gccgo support for calling from 17 | // Go to C does not support varargs functions. 18 | 19 | struct ret { 20 | uintptr_t r; 21 | uintptr_t err; 22 | }; 23 | 24 | struct ret 25 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 26 | { 27 | struct ret r; 28 | 29 | errno = 0; 30 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 31 | r.err = errno; 32 | return r; 33 | } 34 | 35 | uintptr_t 36 | gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 37 | { 38 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for DragonFly from master list 7 | # (for example, /usr/src/sys/kern/syscalls.master). 8 | 9 | use strict; 10 | 11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 12 | print STDERR "GOARCH or GOOS not defined in environment\n"; 13 | exit 1; 14 | } 15 | 16 | my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV); 17 | 18 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+(?:NO)?STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print < foo2(2.) } // MATCH /expression always evaluates to false/ 9 | 10 | func foo2(f float64) bool { return f < f } // MATCH /expression always evaluates to false/ 11 | 12 | func foo3(f float64) bool { return f <= f } // MATCH /expression always evaluates to false/ 13 | 14 | func foo4(f float64) bool { return f >= f } // MATCH /expression always evaluates to false/ 15 | 16 | func foo5(f float64) bool { return f == f } // MATCH /expression always evaluates to true/ 17 | 18 | func foo6(f float64) bool { return fmt.Sprintf("%s", buf1.Bytes()) == fmt.Sprintf("%s", buf1.Bytes()) } // MATCH /expression always evaluates to true/ 19 | 20 | func foo7(f float64) bool { 21 | return fFoo(fBar(isNaN(10.), bpar), 10000) || fFoo(fBar(isNaN(10.), bpar), 10000) // MATCH /left and right hand-side sub-expressions are the same/ 22 | } 23 | 24 | func foo8(f float64) bool { 25 | return fFoo(fBar(isNaN(10.), bpar), 10000) && fFoo(fBar(isNaN(10.), bpar), 10000) // MATCH /left and right hand-side sub-expressions are the same/ 26 | } 27 | -------------------------------------------------------------------------------- /rule/go-routines.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "go/ast" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // Goroutines Rule detects the use of goroutines 10 | type GoRoutinesRule struct{} 11 | 12 | // Apply applies the rule to given file. 13 | func (r *GoRoutinesRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { 14 | var failures []lint.Failure 15 | 16 | fileAst := file.AST 17 | walker := lintGoRoutines{ 18 | file: file, 19 | fileAst: fileAst, 20 | onFailure: func(failure lint.Failure) { 21 | failures = append(failures, failure) 22 | }, 23 | } 24 | 25 | ast.Walk(walker, fileAst) 26 | 27 | return failures 28 | } 29 | 30 | // Name returns the rule name. 31 | func (r *GoRoutinesRule) Name() string { 32 | return "go-routines" 33 | } 34 | 35 | type lintGoRoutines struct { 36 | file *lint.File 37 | fileAst *ast.File 38 | onFailure func(lint.Failure) 39 | } 40 | 41 | //AST Traversal 42 | func (w lintGoRoutines) Visit(node ast.Node) ast.Visitor { 43 | switch n := node.(type) { 44 | case *ast.GoStmt: 45 | w.onFailure(lint.Failure{ 46 | Confidence: 1, 47 | Failure: "should not use goroutines, will lead to non-deterministic behaviour", 48 | Node: n, 49 | Category: "goroutines", 50 | }) 51 | return w 52 | } 53 | return w 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/README.md: -------------------------------------------------------------------------------- 1 | # go-isatty 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty) 4 | [![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty) 7 | 8 | isatty for golang 9 | 10 | ## Usage 11 | 12 | ```go 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "github.com/mattn/go-isatty" 18 | "os" 19 | ) 20 | 21 | func main() { 22 | if isatty.IsTerminal(os.Stdout.Fd()) { 23 | fmt.Println("Is Terminal") 24 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { 25 | fmt.Println("Is Cygwin/MSYS2 Terminal") 26 | } else { 27 | fmt.Println("Is Not Terminal") 28 | } 29 | } 30 | ``` 31 | 32 | ## Installation 33 | 34 | ``` 35 | $ go get github.com/mattn/go-isatty 36 | ``` 37 | 38 | ## License 39 | 40 | MIT 41 | 42 | ## Author 43 | 44 | Yasuhiro Matsumoto (a.k.a mattn) 45 | 46 | ## Thanks 47 | 48 | * k-takata: base idea for IsCygwinTerminal 49 | 50 | https://github.com/k-takata/go-iscygpty 51 | -------------------------------------------------------------------------------- /fixtures/golint/value-spec.go: -------------------------------------------------------------------------------- 1 | // Test that exported names have correct comments. 2 | 3 | // Package pkg does something. 4 | package pkg 5 | 6 | import "time" 7 | 8 | type T int // MATCH /exported type T should have comment or be unexported/ 9 | 10 | func (T) F() {} // MATCH /exported method T.F should have comment or be unexported/ 11 | 12 | // this is a nice type. 13 | // MATCH /comment on exported type U should be of the form "U ..." (with optional leading article)/ 14 | type U string 15 | 16 | // this is a neat function. 17 | // MATCH /comment on exported method U.G should be of the form "G ..."/ 18 | func (U) G() {} 19 | 20 | // A V is a string. 21 | type V string 22 | 23 | // V.H has a pointer receiver 24 | 25 | func (*V) H() {} // MATCH /exported method V.H should have comment or be unexported/ 26 | 27 | var W = "foo" // MATCH /exported var W should have comment or be unexported/ 28 | 29 | const X = "bar" // MATCH /exported const X should have comment or be unexported/ 30 | 31 | var Y, Z int // MATCH /exported var Z should have its own declaration/ 32 | 33 | // Location should be okay, since the other var name is an underscore. 34 | var Location, _ = time.LoadLocation("Europe/Istanbul") // not Constantinople 35 | 36 | // this is improperly documented 37 | // MATCH /comment on exported const Thing should be of the form "Thing ..."/ 38 | const Thing = "wonderful" 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 21 | BL runtime·entersyscall(SB) 22 | MOVD a1+8(FP), R0 23 | MOVD a2+16(FP), R1 24 | MOVD a3+24(FP), R2 25 | MOVD $0, R3 26 | MOVD $0, R4 27 | MOVD $0, R5 28 | MOVD trap+0(FP), R8 // syscall entry 29 | SVC 30 | MOVD R0, r1+32(FP) // r1 31 | MOVD R1, r2+40(FP) // r2 32 | BL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | B syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | B syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOVD a1+8(FP), R0 43 | MOVD a2+16(FP), R1 44 | MOVD a3+24(FP), R2 45 | MOVD $0, R3 46 | MOVD $0, R4 47 | MOVD $0, R5 48 | MOVD trap+0(FP), R8 // syscall entry 49 | SVC 50 | MOVD R0, r1+32(FP) 51 | MOVD R1, r2+40(FP) 52 | RET 53 | -------------------------------------------------------------------------------- /rule/divide-by-zero.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "go/ast" 5 | "go/token" 6 | "go/types" 7 | 8 | "github.com/mgechev/revive/lint" 9 | ) 10 | 11 | type DivideByZeroRule struct{} 12 | 13 | // Apply applies the rule to given file. 14 | func (r *DivideByZeroRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { 15 | var failures []lint.Failure 16 | 17 | fileAst := file.AST 18 | walker := lintDivideByZero{ 19 | file: file, 20 | fileAst: fileAst, 21 | onFailure: func(failure lint.Failure) { 22 | failures = append(failures, failure) 23 | }, 24 | } 25 | 26 | ast.Walk(walker, fileAst) 27 | 28 | return failures 29 | } 30 | 31 | // Name returns the rule name. 32 | func (r *DivideByZeroRule) Name() string { 33 | return "divide-by-zero" 34 | } 35 | 36 | type lintDivideByZero struct { 37 | file *lint.File 38 | fileAst *ast.File 39 | onFailure func(lint.Failure) 40 | } 41 | 42 | func (w lintDivideByZero) Visit(n ast.Node) ast.Visitor { 43 | be, ok := n.(*ast.BinaryExpr) 44 | if !ok { 45 | return w 46 | } 47 | operator := be.Op 48 | leftVal := types.ExprString(be.Y) 49 | 50 | if operator == token.QUO && leftVal == "0" { 51 | w.onFailure(lint.Failure{ 52 | Confidence: 1, 53 | Failure: "should not divide by zero", 54 | Node: be, 55 | Category: "logic", 56 | }) 57 | return w 58 | } 59 | return w 60 | } 61 | -------------------------------------------------------------------------------- /fixtures/confusing-naming1.go: -------------------------------------------------------------------------------- 1 | // Test of confusing-naming rule. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | type foo struct{} 7 | 8 | func (t foo) aFoo() { 9 | return 10 | } 11 | 12 | func (t *foo) AFoo() { // MATCH /Method 'AFoo' differs only by capitalization to method 'aFoo' in the same source file/ 13 | return 14 | } 15 | 16 | type bar struct{} 17 | 18 | func (t *bar) aBar() { 19 | return 20 | } 21 | 22 | func (t *bar) aFoo() { // Should not warn 23 | return 24 | } 25 | 26 | func aGlobal() { 27 | 28 | } 29 | 30 | func AGlobal() { // MATCH /Method 'AGlobal' differs only by capitalization to function 'aGlobal' in the same source file/ 31 | } 32 | 33 | func ABar() { // Should not warn 34 | 35 | } 36 | 37 | func aFoo() { // Should not warn 38 | 39 | } 40 | 41 | func (t foo) ABar() { // Should not warn 42 | return 43 | } 44 | 45 | func (t bar) ABar() { // MATCH /Method 'ABar' differs only by capitalization to method 'aBar' in the same source file/ 46 | return 47 | } 48 | 49 | func x() {} 50 | 51 | type tFoo struct { 52 | asd string 53 | aSd int // MATCH /Field 'aSd' differs only by capitalization to other field in the struct type tFoo/ 54 | qwe, asD bool // MATCH /Field 'asD' differs only by capitalization to other field in the struct type tFoo/ 55 | zxc float32 56 | } 57 | 58 | type tBar struct { 59 | asd string 60 | qwe bool 61 | zxc float32 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 23 | BL runtime·entersyscall(SB) 24 | MOVW trap+0(FP), R7 25 | MOVW a1+4(FP), R0 26 | MOVW a2+8(FP), R1 27 | MOVW a3+12(FP), R2 28 | MOVW $0, R3 29 | MOVW $0, R4 30 | MOVW $0, R5 31 | SWI $0 32 | MOVW R0, r1+16(FP) 33 | MOVW $0, R0 34 | MOVW R0, r2+20(FP) 35 | BL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | B syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | B syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW trap+0(FP), R7 // syscall entry 46 | MOVW a1+4(FP), R0 47 | MOVW a2+8(FP), R1 48 | MOVW a3+12(FP), R2 49 | SWI $0 50 | MOVW R0, r1+16(FP) 51 | MOVW $0, R0 52 | MOVW R0, r2+20(FP) 53 | RET 54 | 55 | TEXT ·seek(SB),NOSPLIT,$0-28 56 | B syscall·seek(SB) 57 | -------------------------------------------------------------------------------- /DEVELOPING.md: -------------------------------------------------------------------------------- 1 | # Developer's Guide 2 | 3 | This document explains how to build, test, and develop features for revive. 4 | 5 | ## Installation 6 | 7 | In order to install all the dependencies run: 8 | 9 | ```bash 10 | go get -u github.com/mgechev/revive 11 | cd $GOPATH/src/github.com/mgechev/revive 12 | ``` 13 | 14 | After that install the dependencies using go modules: 15 | 16 | ```bash 17 | make install 18 | ``` 19 | 20 | ## Build 21 | 22 | In order to build the project run: 23 | 24 | ```bash 25 | make build 26 | ``` 27 | 28 | The command will produce the `revive` binary in the root of the project. 29 | 30 | ## Development of rules 31 | 32 | If you want to develop a new rule, follow as an example the already existing rules in the [rule package](https://github.com/mgechev/revive/tree/master/rule). 33 | 34 | All rules should implement the following interface: 35 | 36 | ```go 37 | type Rule interface { 38 | Name() string 39 | Apply(*File, Arguments) []Failure 40 | } 41 | ``` 42 | 43 | ## Development of formatters 44 | 45 | If you want to develop a new formatter, follow as an example the already existing formatters in the [formatter package](https://github.com/mgechev/revive/tree/master/formatter). 46 | 47 | All formatters should implement the following interface: 48 | 49 | ```go 50 | type Formatter interface { 51 | Format(<-chan Failure, RulesConfig) (string, error) 52 | Name() string 53 | } 54 | ``` 55 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R2 27 | MOVD a2+16(FP), R3 28 | MOVD a3+24(FP), R4 29 | MOVD $0, R5 30 | MOVD $0, R6 31 | MOVD $0, R7 32 | MOVD trap+0(FP), R1 // syscall entry 33 | SYSCALL 34 | MOVD R2, r1+32(FP) 35 | MOVD R3, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R2 47 | MOVD a2+16(FP), R3 48 | MOVD a3+24(FP), R4 49 | MOVD $0, R5 50 | MOVD $0, R6 51 | MOVD $0, R7 52 | MOVD trap+0(FP), R1 // syscall entry 53 | SYSCALL 54 | MOVD R2, r1+32(FP) 55 | MOVD R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracearm_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(arm, arm64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build arm arm64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsArm is the registers used by arm binaries. 11 | type PtraceRegsArm struct { 12 | Uregs [18]uint32 13 | } 14 | 15 | // PtraceGetRegsArm fetches the registers used by arm binaries. 16 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 17 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 18 | } 19 | 20 | // PtraceSetRegsArm sets the registers used by arm binaries. 21 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 22 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 23 | } 24 | 25 | // PtraceRegsArm64 is the registers used by arm64 binaries. 26 | type PtraceRegsArm64 struct { 27 | Regs [31]uint64 28 | Sp uint64 29 | Pc uint64 30 | Pstate uint64 31 | } 32 | 33 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 34 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 35 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 36 | } 37 | 38 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 39 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 40 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | JAL runtime·entersyscall(SB) 29 | MOVW a1+4(FP), R4 30 | MOVW a2+8(FP), R5 31 | MOVW a3+12(FP), R6 32 | MOVW R0, R7 33 | MOVW trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVW R2, r1+16(FP) // r1 36 | MOVW R3, r2+20(FP) // r2 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVW a1+4(FP), R4 48 | MOVW a2+8(FP), R5 49 | MOVW a3+12(FP), R6 50 | MOVW trap+0(FP), R2 // syscall entry 51 | SYSCALL 52 | MOVW R2, r1+16(FP) 53 | MOVW R3, r2+20(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | JAL runtime·entersyscall(SB) 26 | MOVV a1+8(FP), R4 27 | MOVV a2+16(FP), R5 28 | MOVV a3+24(FP), R6 29 | MOVV R0, R7 30 | MOVV R0, R8 31 | MOVV R0, R9 32 | MOVV trap+0(FP), R2 // syscall entry 33 | SYSCALL 34 | MOVV R2, r1+32(FP) 35 | MOVV R3, r2+40(FP) 36 | JAL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | JMP syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | JMP syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVV a1+8(FP), R4 47 | MOVV a2+16(FP), R5 48 | MOVV a3+24(FP), R6 49 | MOVV R0, R7 50 | MOVV R0, R8 51 | MOVV R0, R9 52 | MOVV trap+0(FP), R2 // syscall entry 53 | SYSCALL 54 | MOVV R2, r1+32(FP) 55 | MOVV R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R3 27 | MOVD a2+16(FP), R4 28 | MOVD a3+24(FP), R5 29 | MOVD R0, R6 30 | MOVD R0, R7 31 | MOVD R0, R8 32 | MOVD trap+0(FP), R9 // syscall entry 33 | SYSCALL R9 34 | MOVD R3, r1+32(FP) 35 | MOVD R4, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R3 47 | MOVD a2+16(FP), R4 48 | MOVD a3+24(FP), R5 49 | MOVD R0, R6 50 | MOVD R0, R7 51 | MOVD R0, R8 52 | MOVD trap+0(FP), R9 // syscall entry 53 | SYSCALL R9 54 | MOVD R3, r1+32(FP) 55 | MOVD R4, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | CALL runtime·entersyscall(SB) 24 | MOVQ a1+8(FP), DI 25 | MOVQ a2+16(FP), SI 26 | MOVQ a3+24(FP), DX 27 | MOVQ $0, R10 28 | MOVQ $0, R8 29 | MOVQ $0, R9 30 | MOVQ trap+0(FP), AX // syscall entry 31 | SYSCALL 32 | MOVQ AX, r1+32(FP) 33 | MOVQ DX, r2+40(FP) 34 | CALL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVQ a1+8(FP), DI 45 | MOVQ a2+16(FP), SI 46 | MOVQ a3+24(FP), DX 47 | MOVQ $0, R10 48 | MOVQ $0, R8 49 | MOVQ $0, R9 50 | MOVQ trap+0(FP), AX // syscall entry 51 | SYSCALL 52 | MOVQ AX, r1+32(FP) 53 | MOVQ DX, r2+40(FP) 54 | RET 55 | 56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 57 | JMP syscall·gettimeofday(SB) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by the Linux kernel and glibc. 10 | // 11 | // The information below is extracted and adapted from bits/sysmacros.h in the 12 | // glibc sources: 13 | // 14 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 15 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 16 | // number and m is a hex digit of the minor number. This is backward compatible 17 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 18 | // backward compatible with the Linux kernel, which for some architectures uses 19 | // 32-bit dev_t, encoded as mmmM MMmm. 20 | 21 | package unix 22 | 23 | // Major returns the major component of a Linux device number. 24 | func Major(dev uint64) uint32 { 25 | return uint32((dev >> 16) & 0xffff) 26 | } 27 | 28 | // Minor returns the minor component of a Linux device number. 29 | func Minor(dev uint64) uint32 { 30 | return uint32(dev & 0xffff) 31 | } 32 | 33 | // Mkdev returns a Linux device number generated from the given major and minor 34 | // components. 35 | func Mkdev(major, minor uint32) uint64 { 36 | return uint64(((major) << 16) | (minor)) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for OpenBSD from master list 7 | # (for example, /usr/src/sys/kern/syscalls.master). 8 | 9 | use strict; 10 | 11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 12 | print STDERR "GOARCH or GOOS not defined in environment\n"; 13 | exit 1; 14 | } 15 | 16 | my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV); 17 | 18 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '13' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print < 2 types 36 | func l() (int, error, int) { // MATCH /error should be the last type when returning multiple items/ 37 | return 0, nil, 0 38 | } 39 | 40 | // Check for error in the wrong location with named variables. 41 | func m() (x int, err error, y int) { // MATCH /error should be the last type when returning multiple items/ 42 | return 0, nil, 0 43 | } 44 | 45 | // Check for multiple error returns but with errors at the end. 46 | func n() (int, error, error) { // ok 47 | return 0, nil, nil 48 | } 49 | 50 | // Check for multiple error returns mixed in order, but keeping one error at last position. 51 | func o() (int, error, int, error) { // ok 52 | return 0, nil, 0, nil 53 | } 54 | -------------------------------------------------------------------------------- /fixtures/atomic.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | import ( 4 | "sync/atomic" 5 | ) 6 | 7 | type Counter uint64 8 | 9 | func AtomicTests() { 10 | x := uint64(1) 11 | x = atomic.AddUint64(&x, 1) // MATCH /direct assignment to atomic value/ 12 | _, x = 10, atomic.AddUint64(&x, 1) // MATCH /direct assignment to atomic value/ 13 | x, _ = atomic.AddUint64(&x, 1), 10 // MATCH /direct assignment to atomic value/ 14 | 15 | y := &x 16 | *y = atomic.AddUint64(y, 1) // MATCH /direct assignment to atomic value/ 17 | 18 | var su struct{ Counter uint64 } 19 | su.Counter = atomic.AddUint64(&su.Counter, 1) // MATCH /direct assignment to atomic value/ 20 | z1 := atomic.AddUint64(&su.Counter, 1) 21 | _ = z1 // Avoid err "z declared and not used" 22 | 23 | var sp struct{ Counter *uint64 } 24 | *sp.Counter = atomic.AddUint64(sp.Counter, 1) // MATCH /direct assignment to atomic value/ 25 | z2 := atomic.AddUint64(sp.Counter, 1) 26 | _ = z2 // Avoid err "z declared and not used" 27 | 28 | au := []uint64{10, 20} 29 | au[0] = atomic.AddUint64(&au[0], 1) // MATCH /direct assignment to atomic value/ 30 | au[1] = atomic.AddUint64(&au[0], 1) 31 | 32 | ap := []*uint64{&au[0], &au[1]} 33 | *ap[0] = atomic.AddUint64(ap[0], 1) // MATCH /direct assignment to atomic value/ 34 | *ap[1] = atomic.AddUint64(ap[0], 1) 35 | } 36 | 37 | type T struct{} 38 | 39 | func (T) AddUint64(addr *uint64, delta uint64) uint64 { return 0 } 40 | 41 | func NonAtomic() { 42 | x := uint64(1) 43 | var atomic T 44 | x = atomic.AddUint64(&x, 1) // MATCH /direct assignment to atomic value/ 45 | } 46 | -------------------------------------------------------------------------------- /rule/restrict-global-variables.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "go/ast" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | type RestrictGlobalVariablesRule struct{} 10 | 11 | // Apply applies the rule to given file. 12 | func (r *RestrictGlobalVariablesRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { 13 | var failures []lint.Failure 14 | 15 | fileAst := file.AST 16 | walker := lintRestrictGlobalVariables{ 17 | file: file, 18 | fileAst: fileAst, 19 | onFailure: func(failure lint.Failure) { 20 | failures = append(failures, failure) 21 | }, 22 | } 23 | 24 | ast.Walk(walker, fileAst) 25 | 26 | return failures 27 | } 28 | 29 | // Name returns the rule name. 30 | func (r *RestrictGlobalVariablesRule) Name() string { 31 | return "restrict-global-variables" 32 | } 33 | 34 | type lintRestrictGlobalVariables struct { 35 | file *lint.File 36 | fileAst *ast.File 37 | onFailure func(lint.Failure) 38 | } 39 | 40 | func (w lintRestrictGlobalVariables) Visit(node ast.Node) ast.Visitor { 41 | globalVar := true 42 | ast.Inspect(node, func(n ast.Node) bool { 43 | switch n := n.(type) { 44 | case *ast.ValueSpec: 45 | if globalVar == true { 46 | w.onFailure(lint.Failure{ 47 | Failure: "global variable found, should not use global variable as they are not tracked on the ledger", 48 | Confidence: 1, 49 | Node: n, 50 | Category: "variable scope", 51 | }) 52 | } 53 | case *ast.FuncDecl: 54 | globalVar = false 55 | } 56 | return true 57 | }) 58 | return w 59 | 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/csv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Oleku Konko All rights reserved. 2 | // Use of this source code is governed by a MIT 3 | // license that can be found in the LICENSE file. 4 | 5 | // This module is a Table Writer API for the Go Programming Language. 6 | // The protocols were written in pure Go and works on windows and unix systems 7 | 8 | package tablewriter 9 | 10 | import ( 11 | "encoding/csv" 12 | "io" 13 | "os" 14 | ) 15 | 16 | // Start A new table by importing from a CSV file 17 | // Takes io.Writer and csv File name 18 | func NewCSV(writer io.Writer, fileName string, hasHeader bool) (*Table, error) { 19 | file, err := os.Open(fileName) 20 | if err != nil { 21 | return &Table{}, err 22 | } 23 | defer file.Close() 24 | csvReader := csv.NewReader(file) 25 | t, err := NewCSVReader(writer, csvReader, hasHeader) 26 | return t, err 27 | } 28 | 29 | // Start a New Table Writer with csv.Reader 30 | // This enables customisation such as reader.Comma = ';' 31 | // See http://golang.org/src/pkg/encoding/csv/reader.go?s=3213:3671#L94 32 | func NewCSVReader(writer io.Writer, csvReader *csv.Reader, hasHeader bool) (*Table, error) { 33 | t := NewWriter(writer) 34 | if hasHeader { 35 | // Read the first row 36 | headers, err := csvReader.Read() 37 | if err != nil { 38 | return &Table{}, err 39 | } 40 | t.SetHeader(headers) 41 | } 42 | for { 43 | record, err := csvReader.Read() 44 | if err == io.EOF { 45 | break 46 | } else if err != nil { 47 | return &Table{}, err 48 | } 49 | t.Append(record) 50 | } 51 | return t, nil 52 | } 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/README.md: -------------------------------------------------------------------------------- 1 | # go-colorable 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) 4 | [![Build Status](https://travis-ci.org/mattn/go-colorable.svg?branch=master)](https://travis-ci.org/mattn/go-colorable) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-colorable/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-colorable?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable) 7 | 8 | Colorable writer for windows. 9 | 10 | For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.) 11 | This package is possible to handle escape sequence for ansi color on windows. 12 | 13 | ## Too Bad! 14 | 15 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png) 16 | 17 | 18 | ## So Good! 19 | 20 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png) 21 | 22 | ## Usage 23 | 24 | ```go 25 | logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) 26 | logrus.SetOutput(colorable.NewColorableStdout()) 27 | 28 | logrus.Info("succeeded") 29 | logrus.Warn("not correct") 30 | logrus.Error("something error") 31 | logrus.Fatal("panic") 32 | ``` 33 | 34 | You can compile above code on non-windows OSs. 35 | 36 | ## Installation 37 | 38 | ``` 39 | $ go get github.com/mattn/go-colorable 40 | ``` 41 | 42 | # License 43 | 44 | MIT 45 | 46 | # Author 47 | 48 | Yasuhiro Matsumoto (a.k.a mattn) 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc64 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by the Linux kernel and glibc. 10 | // 11 | // The information below is extracted and adapted from bits/sysmacros.h in the 12 | // glibc sources: 13 | // 14 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 15 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 16 | // number and m is a hex digit of the minor number. This is backward compatible 17 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 18 | // backward compatible with the Linux kernel, which for some architectures uses 19 | // 32-bit dev_t, encoded as mmmM MMmm. 20 | 21 | package unix 22 | 23 | // Major returns the major component of a Linux device number. 24 | func Major(dev uint64) uint32 { 25 | return uint32((dev & 0x3fffffff00000000) >> 32) 26 | } 27 | 28 | // Minor returns the minor component of a Linux device number. 29 | func Minor(dev uint64) uint32 { 30 | return uint32((dev & 0x00000000ffffffff) >> 0) 31 | } 32 | 33 | // Mkdev returns a Linux device number generated from the given major and minor 34 | // components. 35 | func Mkdev(major, minor uint32) uint64 { 36 | var DEVNO64 uint64 37 | DEVNO64 = 0x8000000000000000 38 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) 39 | } 40 | -------------------------------------------------------------------------------- /rule/confusing-results.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "go/ast" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // ConfusingResultsRule lints given function declarations 10 | type ConfusingResultsRule struct{} 11 | 12 | // Apply applies the rule to given file. 13 | func (r *ConfusingResultsRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { 14 | var failures []lint.Failure 15 | 16 | fileAst := file.AST 17 | walker := lintConfusingResults{ 18 | onFailure: func(failure lint.Failure) { 19 | failures = append(failures, failure) 20 | }, 21 | } 22 | 23 | ast.Walk(walker, fileAst) 24 | 25 | return failures 26 | } 27 | 28 | // Name returns the rule name. 29 | func (r *ConfusingResultsRule) Name() string { 30 | return "confusing-results" 31 | } 32 | 33 | type lintConfusingResults struct { 34 | onFailure func(lint.Failure) 35 | } 36 | 37 | func (w lintConfusingResults) Visit(n ast.Node) ast.Visitor { 38 | fn, ok := n.(*ast.FuncDecl) 39 | if !ok || fn.Type.Results == nil || len(fn.Type.Results.List) < 2 { 40 | return w 41 | } 42 | lastType := "" 43 | for _, result := range fn.Type.Results.List { 44 | if len(result.Names) > 0 { 45 | return w 46 | } 47 | 48 | t, ok := result.Type.(*ast.Ident) 49 | if !ok { 50 | return w 51 | } 52 | 53 | if t.Name == lastType { 54 | w.onFailure(lint.Failure{ 55 | Node: n, 56 | Confidence: 1, 57 | Category: "naming", 58 | Failure: "unnamed results of the same type may be confusing, consider using named results", 59 | }) 60 | break 61 | } 62 | lastType = t.Name 63 | 64 | } 65 | 66 | return w 67 | } 68 | -------------------------------------------------------------------------------- /rule/context-as-argument.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "go/ast" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // ContextAsArgumentRule lints given else constructs. 10 | type ContextAsArgumentRule struct{} 11 | 12 | // Apply applies the rule to given file. 13 | func (r *ContextAsArgumentRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { 14 | var failures []lint.Failure 15 | 16 | fileAst := file.AST 17 | walker := lintContextArguments{ 18 | file: file, 19 | fileAst: fileAst, 20 | onFailure: func(failure lint.Failure) { 21 | failures = append(failures, failure) 22 | }, 23 | } 24 | 25 | ast.Walk(walker, fileAst) 26 | 27 | return failures 28 | } 29 | 30 | // Name returns the rule name. 31 | func (r *ContextAsArgumentRule) Name() string { 32 | return "context-as-argument" 33 | } 34 | 35 | type lintContextArguments struct { 36 | file *lint.File 37 | fileAst *ast.File 38 | onFailure func(lint.Failure) 39 | } 40 | 41 | func (w lintContextArguments) Visit(n ast.Node) ast.Visitor { 42 | fn, ok := n.(*ast.FuncDecl) 43 | if !ok || len(fn.Type.Params.List) <= 1 { 44 | return w 45 | } 46 | // A context.Context should be the first parameter of a function. 47 | // Flag any that show up after the first. 48 | for _, arg := range fn.Type.Params.List[1:] { 49 | if isPkgDot(arg.Type, "context", "Context") { 50 | w.onFailure(lint.Failure{ 51 | Node: fn, 52 | Category: "arg-order", 53 | Failure: "context.Context should be the first parameter of a function", 54 | Confidence: 0.9, 55 | }) 56 | break // only flag one 57 | } 58 | } 59 | return w 60 | } 61 | -------------------------------------------------------------------------------- /rule/get-return.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "fmt" 5 | "go/ast" 6 | "strings" 7 | 8 | "github.com/mgechev/revive/lint" 9 | ) 10 | 11 | // GetReturnRule lints given else constructs. 12 | type GetReturnRule struct{} 13 | 14 | // Apply applies the rule to given file. 15 | func (r *GetReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { 16 | var failures []lint.Failure 17 | 18 | onFailure := func(failure lint.Failure) { 19 | failures = append(failures, failure) 20 | } 21 | 22 | w := lintReturnRule{onFailure} 23 | ast.Walk(w, file.AST) 24 | return failures 25 | } 26 | 27 | // Name returns the rule name. 28 | func (r *GetReturnRule) Name() string { 29 | return "get-return" 30 | } 31 | 32 | type lintReturnRule struct { 33 | onFailure func(lint.Failure) 34 | } 35 | 36 | func isGetter(name string) bool { 37 | if strings.HasPrefix(strings.ToUpper(name), "GET") { 38 | if len(name) > 3 { 39 | c := name[3] 40 | return !(c >= 'a' && c <= 'z') 41 | } 42 | } 43 | 44 | return false 45 | } 46 | 47 | func hasResults(rs *ast.FieldList) bool { 48 | return rs != nil && len(rs.List) > 0 49 | } 50 | 51 | func (w lintReturnRule) Visit(node ast.Node) ast.Visitor { 52 | fd, ok := node.(*ast.FuncDecl) 53 | if !ok { 54 | return w 55 | } 56 | 57 | if !isGetter(fd.Name.Name) { 58 | return w 59 | } 60 | if !hasResults(fd.Type.Results) { 61 | w.onFailure(lint.Failure{ 62 | Confidence: 0.8, 63 | Node: fd, 64 | Category: "logic", 65 | Failure: fmt.Sprintf("function '%s' seems to be a getter but it does not return any result", fd.Name.Name), 66 | }) 67 | } 68 | 69 | return w 70 | } 71 | -------------------------------------------------------------------------------- /fixtures/golint/unexported-return.go: -------------------------------------------------------------------------------- 1 | // Test for unexported return types. 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | type hidden struct{} 7 | 8 | // Exported returns a hidden type, which is annoying. 9 | func Exported() hidden { // MATCH /exported func Exported returns unexported type foo.hidden, which can be annoying to use/ 10 | return hidden{} 11 | } 12 | 13 | // ExpErr returns a builtin type. 14 | func ExpErr() error { // ok 15 | return nil 16 | } 17 | 18 | func (h hidden) ExpOnHidden() hidden { // ok 19 | return h 20 | } 21 | 22 | func (hidden) ForInterface() error { 23 | return nil 24 | } 25 | 26 | // Interface is exported. 27 | type Interface interface { 28 | ForInterface() error 29 | } 30 | 31 | // ExportedAsInterface returns a hidden type as an exported interface, which is fine. 32 | func ExportedAsInterface() Interface { // ok 33 | return Exported() 34 | } 35 | 36 | // T is another test type. 37 | type T struct{} 38 | 39 | // MethodOnT returns a hidden type, which is annoying. 40 | func (T) MethodOnT() hidden { // MATCH /exported method MethodOnT returns unexported type foo.hidden, which can be annoying to use/ 41 | return hidden{} 42 | } 43 | 44 | // ExpT returns a T. 45 | func ExpT() T { // ok 46 | return T{} 47 | } 48 | 49 | func unexp() hidden { // ok 50 | return hidden{} 51 | } 52 | 53 | // This is slightly sneaky: we shadow the builtin "int" type. 54 | 55 | type int struct{} 56 | 57 | // ExportedIntReturner returns an unexported type from this package. 58 | func ExportedIntReturner() int { // MATCH /exported func ExportedIntReturner returns unexported type foo.int, which can be annoying to use/ 59 | return int{} 60 | } 61 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemips_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mips, mips64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mips mips64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMips is the registers used by mips binaries. 11 | type PtraceRegsMips struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMips fetches the registers used by mips binaries. 22 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMips sets the registers used by mips binaries. 27 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64 is the registers used by mips64 binaries. 32 | type PtraceRegsMips64 struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 43 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 48 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /fixtures/bool-literal-in-expr.go: -------------------------------------------------------------------------------- 1 | package fixtures 2 | 3 | func foo(a, b, c, d int) bool { 4 | if bar == true { // MATCH /omit Boolean literal in expression/ 5 | 6 | } 7 | for f() || false != yes { // MATCH /omit Boolean literal in expression/ 8 | 9 | } 10 | 11 | return b > c == false // MATCH /omit Boolean literal in expression/ 12 | } 13 | 14 | // from github.com/jmespath/go-jmespath/functions.go 15 | func jpfToNumber(arguments []interface{}) (interface{}, error) { 16 | arg := arguments[0] 17 | // code skipped 18 | if arg == true || // MATCH /omit Boolean literal in expression/ 19 | arg == false { // MATCH /omit Boolean literal in expression/ 20 | return nil, nil 21 | } 22 | return nil, errors.New("unknown type") 23 | } 24 | 25 | // from gopkg.in/yaml.v2/resolve.go 26 | func resolve(tag string, in string) (rtag string, out interface{}) { 27 | if err == nil { 28 | if true || intv == int64(int(intv)) { // MATCH /Boolean expression seems to always evaluate to true/ 29 | return yaml_INT_TAG, int(intv) 30 | } else { 31 | return yaml_INT_TAG, intv 32 | } 33 | } 34 | } 35 | 36 | // from github.com/miekg/dns/msg_helpers.go 37 | func packDataDomainNames(names []string, msg []byte, off int, compression map[string]int, compress bool) (int, error) { 38 | var err error 39 | for j := 0; j < len(names); j++ { 40 | off, err = PackDomainName(names[j], msg, off, compression, false && compress) // MATCH /Boolean expression seems to always evaluate to false/ 41 | if err != nil { 42 | return len(msg), err 43 | } 44 | } 45 | return off, nil 46 | } 47 | 48 | func isTrue(arg bool) bool { 49 | return arg 50 | } 51 | 52 | func main() { 53 | isTrue(true) 54 | } 55 | -------------------------------------------------------------------------------- /rule/argument-limit.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "fmt" 5 | "go/ast" 6 | 7 | "github.com/mgechev/revive/lint" 8 | ) 9 | 10 | // ArgumentsLimitRule lints given else constructs. 11 | type ArgumentsLimitRule struct{} 12 | 13 | // Apply applies the rule to given file. 14 | func (r *ArgumentsLimitRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { 15 | if len(arguments) != 1 { 16 | panic(`invalid configuration for "argument-limit"`) 17 | } 18 | 19 | total, ok := arguments[0].(int64) // Alt. non panicking version 20 | if !ok { 21 | panic(`invalid value passed as argument number to the "argument-list" rule`) 22 | } 23 | 24 | var failures []lint.Failure 25 | 26 | walker := lintArgsNum{ 27 | total: int(total), 28 | onFailure: func(failure lint.Failure) { 29 | failures = append(failures, failure) 30 | }, 31 | } 32 | 33 | ast.Walk(walker, file.AST) 34 | 35 | return failures 36 | } 37 | 38 | // Name returns the rule name. 39 | func (r *ArgumentsLimitRule) Name() string { 40 | return "argument-limit" 41 | } 42 | 43 | type lintArgsNum struct { 44 | total int 45 | onFailure func(lint.Failure) 46 | } 47 | 48 | func (w lintArgsNum) Visit(n ast.Node) ast.Visitor { 49 | node, ok := n.(*ast.FuncDecl) 50 | if ok { 51 | num := 0 52 | for _, l := range node.Type.Params.List { 53 | for range l.Names { 54 | num++ 55 | } 56 | } 57 | if num > w.total { 58 | w.onFailure(lint.Failure{ 59 | Confidence: 1, 60 | Failure: fmt.Sprintf("maximum number of arguments per function exceeded; max %d but got %d", w.total, num), 61 | Node: node.Type, 62 | }) 63 | return w 64 | } 65 | } 66 | return w 67 | } 68 | -------------------------------------------------------------------------------- /rule/max-public-structs.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "go/ast" 5 | 6 | "strings" 7 | 8 | "github.com/mgechev/revive/lint" 9 | ) 10 | 11 | // MaxPublicStructsRule lints given else constructs. 12 | type MaxPublicStructsRule struct{} 13 | 14 | // Apply applies the rule to given file. 15 | func (r *MaxPublicStructsRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { 16 | var failures []lint.Failure 17 | 18 | fileAst := file.AST 19 | walker := &lintMaxPublicStructs{ 20 | fileAst: fileAst, 21 | onFailure: func(failure lint.Failure) { 22 | failures = append(failures, failure) 23 | }, 24 | } 25 | 26 | ast.Walk(walker, fileAst) 27 | 28 | max, ok := arguments[0].(int64) // Alt. non panicking version 29 | if !ok { 30 | panic(`invalid value passed as argument number to the "max-public-structs" rule`) 31 | } 32 | 33 | if walker.current > max { 34 | walker.onFailure(lint.Failure{ 35 | Failure: "you have exceeded the maximum number of public struct declarations", 36 | Confidence: 1, 37 | Node: fileAst, 38 | Category: "style", 39 | }) 40 | } 41 | 42 | return failures 43 | } 44 | 45 | // Name returns the rule name. 46 | func (r *MaxPublicStructsRule) Name() string { 47 | return "max-public-structs" 48 | } 49 | 50 | type lintMaxPublicStructs struct { 51 | current int64 52 | fileAst *ast.File 53 | onFailure func(lint.Failure) 54 | } 55 | 56 | func (w *lintMaxPublicStructs) Visit(n ast.Node) ast.Visitor { 57 | switch v := n.(type) { 58 | case *ast.TypeSpec: 59 | name := v.Name.Name 60 | first := string(name[0]) 61 | if strings.ToUpper(first) == first { 62 | w.current++ 63 | } 64 | break 65 | } 66 | return w 67 | } 68 | -------------------------------------------------------------------------------- /rule/error-return.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "go/ast" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // ErrorReturnRule lints given else constructs. 10 | type ErrorReturnRule struct{} 11 | 12 | // Apply applies the rule to given file. 13 | func (r *ErrorReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { 14 | var failures []lint.Failure 15 | 16 | fileAst := file.AST 17 | walker := lintErrorReturn{ 18 | file: file, 19 | fileAst: fileAst, 20 | onFailure: func(failure lint.Failure) { 21 | failures = append(failures, failure) 22 | }, 23 | } 24 | 25 | ast.Walk(walker, fileAst) 26 | 27 | return failures 28 | } 29 | 30 | // Name returns the rule name. 31 | func (r *ErrorReturnRule) Name() string { 32 | return "error-return" 33 | } 34 | 35 | type lintErrorReturn struct { 36 | file *lint.File 37 | fileAst *ast.File 38 | onFailure func(lint.Failure) 39 | } 40 | 41 | func (w lintErrorReturn) Visit(n ast.Node) ast.Visitor { 42 | fn, ok := n.(*ast.FuncDecl) 43 | if !ok || fn.Type.Results == nil { 44 | return w 45 | } 46 | ret := fn.Type.Results.List 47 | if len(ret) <= 1 { 48 | return w 49 | } 50 | if isIdent(ret[len(ret)-1].Type, "error") { 51 | return nil 52 | } 53 | // An error return parameter should be the last parameter. 54 | // Flag any error parameters found before the last. 55 | for _, r := range ret[:len(ret)-1] { 56 | if isIdent(r.Type, "error") { 57 | w.onFailure(lint.Failure{ 58 | Category: "arg-order", 59 | Confidence: 0.9, 60 | Node: fn, 61 | Failure: "error should be the last type when returning multiple items", 62 | }) 63 | break // only flag one 64 | } 65 | } 66 | return w 67 | } 68 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemipsle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mipsle, mips64le). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mipsle mips64le 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMipsle is the registers used by mipsle binaries. 11 | type PtraceRegsMipsle struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 22 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 27 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64le is the registers used by mips64le binaries. 32 | type PtraceRegsMips64le struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 43 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 48 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | 8 | "github.com/fatih/color" 9 | "github.com/mgechev/revive/lint" 10 | ) 11 | 12 | var logo = color.YellowString(` _ __ _____ _(_)__ _____ 13 | | '__/ _ \ \ / / \ \ / / _ \ 14 | | | | __/\ V /| |\ V / __/ 15 | |_| \___| \_/ |_| \_/ \___|`) 16 | 17 | var call = color.MagentaString("revive -config c.toml -formatter friendly -exclude a.go -exclude b.go ./...") 18 | 19 | var banner = fmt.Sprintf(` 20 | %s 21 | 22 | Example: 23 | %s 24 | `, logo, call) 25 | 26 | func main() { 27 | config := getConfig() 28 | formatter := getFormatter() 29 | packages := getPackages() 30 | 31 | revive := lint.New(func(file string) ([]byte, error) { 32 | return ioutil.ReadFile(file) 33 | }) 34 | 35 | lintingRules := getLintingRules(config) 36 | 37 | failures, err := revive.Lint(packages, lintingRules, *config) 38 | if err != nil { 39 | fail(err.Error()) 40 | } 41 | 42 | formatChan := make(chan lint.Failure) 43 | exitChan := make(chan bool) 44 | 45 | var output string 46 | go (func() { 47 | output, err = formatter.Format(formatChan, config.Rules) 48 | if err != nil { 49 | fail(err.Error()) 50 | } 51 | exitChan <- true 52 | })() 53 | 54 | exitCode := 0 55 | for f := range failures { 56 | if f.Confidence < config.Confidence { 57 | continue 58 | } 59 | if exitCode == 0 { 60 | exitCode = config.WarningCode 61 | } 62 | if c, ok := config.Rules[f.RuleName]; ok && c.Severity == lint.SeverityError { 63 | exitCode = config.ErrorCode 64 | } 65 | formatChan <- f 66 | } 67 | 68 | close(formatChan) 69 | <-exitChan 70 | if output != "" { 71 | fmt.Println(output) 72 | } 73 | 74 | os.Exit(exitCode) 75 | } 76 | -------------------------------------------------------------------------------- /rule/waitgroup-by-value.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "go/ast" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // WaitGroupByValueRule lints sync.WaitGroup passed by copy in functions. 10 | type WaitGroupByValueRule struct{} 11 | 12 | // Apply applies the rule to given file. 13 | func (r *WaitGroupByValueRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { 14 | var failures []lint.Failure 15 | 16 | onFailure := func(failure lint.Failure) { 17 | failures = append(failures, failure) 18 | } 19 | 20 | w := lintWaitGroupByValueRule{onFailure: onFailure} 21 | ast.Walk(w, file.AST) 22 | return failures 23 | } 24 | 25 | // Name returns the rule name. 26 | func (r *WaitGroupByValueRule) Name() string { 27 | return "waitgroup-by-value" 28 | } 29 | 30 | type lintWaitGroupByValueRule struct { 31 | onFailure func(lint.Failure) 32 | } 33 | 34 | func (w lintWaitGroupByValueRule) Visit(node ast.Node) ast.Visitor { 35 | // look for function declarations 36 | fd, ok := node.(*ast.FuncDecl) 37 | if !ok { 38 | return w 39 | } 40 | 41 | // Check all function's parameters 42 | for _, field := range fd.Type.Params.List { 43 | if !w.isWaitGroup(field.Type) { 44 | continue 45 | } 46 | 47 | w.onFailure(lint.Failure{ 48 | Confidence: 1, 49 | Node: field, 50 | Failure: "sync.WaitGroup passed by value, the function will get a copy of the original one", 51 | }) 52 | } 53 | 54 | return nil 55 | } 56 | 57 | func (lintWaitGroupByValueRule) isWaitGroup(ft ast.Expr) bool { 58 | se, ok := ft.(*ast.SelectorExpr) 59 | if !ok { 60 | return false 61 | } 62 | 63 | x, _ := se.X.(*ast.Ident) 64 | sel := se.Sel.Name 65 | return x.Name == "sync" && sel == "WaitGroup" 66 | } 67 | -------------------------------------------------------------------------------- /rule/empty-block.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "go/ast" 5 | 6 | "github.com/mgechev/revive/lint" 7 | ) 8 | 9 | // EmptyBlockRule lints given else constructs. 10 | type EmptyBlockRule struct{} 11 | 12 | // Apply applies the rule to given file. 13 | func (r *EmptyBlockRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { 14 | var failures []lint.Failure 15 | 16 | onFailure := func(failure lint.Failure) { 17 | failures = append(failures, failure) 18 | } 19 | 20 | w := lintEmptyBlock{make([]*ast.BlockStmt, 0), onFailure} 21 | ast.Walk(w, file.AST) 22 | return failures 23 | } 24 | 25 | // Name returns the rule name. 26 | func (r *EmptyBlockRule) Name() string { 27 | return "empty-block" 28 | } 29 | 30 | type lintEmptyBlock struct { 31 | ignore []*ast.BlockStmt 32 | onFailure func(lint.Failure) 33 | } 34 | 35 | func (w lintEmptyBlock) Visit(node ast.Node) ast.Visitor { 36 | fd, ok := node.(*ast.FuncDecl) 37 | if ok { 38 | w.ignore = append(w.ignore, fd.Body) 39 | return w 40 | } 41 | 42 | fl, ok := node.(*ast.FuncLit) 43 | if ok { 44 | w.ignore = append(w.ignore, fl.Body) 45 | return w 46 | } 47 | 48 | block, ok := node.(*ast.BlockStmt) 49 | if !ok { 50 | return w 51 | } 52 | 53 | if mustIgnore(block, w.ignore) { 54 | return w 55 | } 56 | 57 | if len(block.List) == 0 { 58 | w.onFailure(lint.Failure{ 59 | Confidence: 1, 60 | Node: block, 61 | Category: "logic", 62 | Failure: "this block is empty, you can remove it", 63 | }) 64 | } 65 | 66 | return w 67 | } 68 | 69 | func mustIgnore(block *ast.BlockStmt, blackList []*ast.BlockStmt) bool { 70 | for _, b := range blackList { 71 | if b == block { 72 | return true 73 | } 74 | } 75 | return false 76 | } 77 | --------------------------------------------------------------------------------