Skip to content

Commit

Permalink
Integration istio/common-files (istio#1508)
Browse files Browse the repository at this point in the history
* Integration istio/common-files

Istio has a repo to store common files so things like linting, license,
etc are consistent across repos. This change integrates these files
here.

This also replaces the lint presubmit test with the common linters.

* Add back linter

* Fix linter errors
  • Loading branch information
howardjohn authored and istio-testing committed Jul 19, 2019
1 parent f896300 commit b0f8b09
Show file tree
Hide file tree
Showing 23 changed files with 678 additions and 1,492 deletions.
1 change: 1 addition & 0 deletions .commonfiles.sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
950d08195523c9f44f15e7283274259ee0ace593
160 changes: 139 additions & 21 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# WARNING: DO NOT EDIT, THIS FILE IS PROBABLY A COPY
#
# The original version of this file is located in the https://github.com/istio/common-files repo.
# If you're looking at this file in a different repo and want to make a change, please go to the
# common-files repo, make the change there and check it in. Then come back to this repo and run
# "make updatecommon".

service:
# When updating this, also update bin/linters.sh accordingly
golangci-lint-version: 1.16.x # use the fixed version to not introduce new linters unexpectedly
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 600s
deadline: 20m

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs:
- genfiles$
- vendor$
Expand All @@ -23,41 +30,152 @@ run:
- ".*\\.gen\\.go"

linters:
disable-all: true
enable:
- deadcode
- errcheck
enable-all: true
disable:
- depguard
- dupl
- gochecknoglobals
- gochecknoinits
- goconst
- gofmt
- goimports
- golint
- ineffassign
- interfacer
- lll
- megacheck
- misspell
- structcheck
- unconvert
- varcheck
- vet
- vetshadow
- gocyclo
- gosec
- nakedret
- prealloc
- scopelint
fast: false

linters-settings:
errcheck:
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: false

# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: false
govet:
# report about shadowed variables
check-shadowing: false
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.0
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: istio.io/
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: US
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 160
# tab width in spaces. Default to 1.
tab-width: 1
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unparam:
# call graph construction algorithm (cha, rta). In general, use cha for libraries,
# and rta for programs with main packages. Default is cha.
algo: cha

# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
gocritic:
enabled-checks:
- appendCombine
- argOrder
- assignOp
- badCond
- boolExprSimplify
- builtinShadow
- captLocal
- caseOrder
- codegenComment
- commentedOutCode
- commentedOutImport
- defaultCaseOrder
- deprecatedComment
- docStub
- dupArg
- dupBranchBody
- dupCase
- dupSubExpr
- elseif
- emptyFallthrough
- equalFold
- flagDeref
- flagName
- hexLiteral
- indexAlloc
- initClause
- methodExprCall
- nilValReturn
- octalLiteral
- offBy1
- rangeExprCopy
- regexpMust
- sloppyLen
- stringXbytes
- switchTrue
- typeAssertChain
- typeSwitchVar
- typeUnparen
- underef
- unlambda
- unnecessaryBlock
- unslice
- valSwap
- weakCond
- yodaStyleExpr

# Unused
# - appendAssign
# - commentFormatting
# - emptyStringTest
# - exitAfterDefer
# - ifElseChain
# - hugeParam
# - importShadow
# - nestingReduce
# - paramTypeCombine
# - ptrToRefParam
# - rangeValCopy
# - singleCaseSwitch
# - sloppyReassign
# - unlabelStmt
# - unnamedResult
# - wrapperFunc

issues:
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
- should have a package comment
- composite literal uses unkeyed fields

exclude-rules:
# Exclude some linters from running on test files.
- path: _test\.go$|^tests/|^samples/
linters:
- errcheck
- maligned

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
Expand All @@ -69,4 +187,4 @@ issues:
max-per-linter: 0

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
max-same-issues: 0
10 changes: 10 additions & 0 deletions BUGS-AND-FEATURE-REQUESTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Bugs and Feature Requests

You can report bugs and feature requests to the Istio team in one of three places:

- [Product Bugs and Feature Requests](https://github.com/istio/istio/issues)
- [Documentation Bugs and Feature Requests](https://github.com/istio/istio.io/issues)
- [Community and Governance Issues](https://github.com/istio/community/issues)

For security vulnerabilities, please don't report a bug (which is public) and instead follow
[these procedures](https://istio.io/about/security-vulnerabilities/).
36 changes: 4 additions & 32 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
# Contributing guidelines
# Contribution guidelines

So, you want to hack on Istio? Yay!

- [Contributor license agreements](#contributor-license-agreements)
- [Contributing a patch](#contributing-a-patch)

## Contributor license agreements

We'd love to accept your patches! Before we can take them, you have to jump a
few legal hurdles.

Please fill out the [Google CLA](https://cla.developers.google.com).

Once you are CLA'ed, we'll be able to accept your pull requests. This is necessary
because you own the copyright to your changes, even after your contribution
becomes part of this project. So this agreement simply gives us permission
to use and redistribute your contributions as part of the project.

## Contributing a patch

If you're working on an existing issue, simply respond to the issue and express
interest in working on it. This helps other people know that the issue is
active, and hopefully prevents duplicated efforts.

If you want to work on a new idea of relatively small scope:

1. Submit an issue describing your proposed change to the repo in question.
1. The repo owners will respond to your issue promptly.
1. If your proposed change is accepted, and you haven't already done so, sign a
Contributor License Agreement (see details above).
1. Fork the repo, develop, and test your changes.
1. Submit a pull request.
So you want to hack on Istio? Yay! Please refer to Istio's overall
[contribution guidelines](https://github.com/istio/community/blob/master/CONTRIBUTING.md)
to find out how you can help.
Loading

0 comments on commit b0f8b09

Please sign in to comment.