Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add .gometalint.json config #165

Merged
merged 1 commit into from
Jul 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .gometalinter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"Disable": ["gotype", "gotypex", "maligned", "gocyclo", "golint"],
"Enable": [
"gas",
"errcheck",
"deadcode",
"gochecknoinits",
"goconst",
"gocyclo",
"gofmt",
"goimports",
"golint",
"gotype",
"gotypex",
"ineffassign",
"interfacer",
"maligned",
"megacheck",
"safesql",
"structcheck",
"test",
"testify",
"unconvert",
"unparam",
"varcheck",
"vet",
"vetshadow"
],
"Deadline": "300s",
"Vendor": true,
"LineLength": 120,
"Skip": ["server/static", "mocks"],
"WarnUnmatchedDirective": true,
"Linters": {
"gas": "gas -exclude=G104 -fmt=csv:^(?P<path>.*?\\.go),(?P<line>\\d+),(?P<message>[^,]+,[^,]+,[^,]+)",
"errcheck": {
"Command": "errcheck -abspath -ignore 'fmt:.*'",
"Pattern": "PATH:LINE:COL:MESSAGE",
"PartitionStrategy": "packages"
}
}
}
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ gometalint: ## Run every linter ever
# gocyclo is temporarily disabled because we don't pass it right now
# golint is temporarily disabled because we need to add comments everywhere first
# CGO_ENABLED=0 is attempted workaround for https://github.com/alecthomas/gometalinter/issues/149
# errcheck is temporarily disabled until https://github.com/alecthomas/gometalinter/pull/498 is fixed
CGO_ENABLED=0 gometalinter --disable gotype --disable gotypex --disable maligned --disable gocyclo --disable golint --disable errcheck --enable=megacheck --enable=unparam --linter='gas:gas -exclude=G104 -fmt=csv:^(?P<path>.*?\.go),(?P<line>\d+),(?P<message>[^,]+,[^,]+,[^,]+)' --deadline=300s --vendor -t --line-length=120 --skip server/static ./...
CGO_ENABLED=0 gometalinter --config=.gometalinter.json ./...

gometalint-install: ## Install gometalint
go get -u github.com/alecthomas/gometalinter
Expand Down
1 change: 0 additions & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ func (s *ServerCmd) setDefaults(c *server.UserConfig) {
}
}

// nolint: gocyclo
func (s *ServerCmd) validate(userConfig server.UserConfig) error {
logLevel := userConfig.LogLevel
if logLevel != "debug" && logLevel != "info" && logLevel != "warn" && logLevel != "error" {
Expand Down
1 change: 0 additions & 1 deletion server/events/comment_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ type CommentParseResult struct {
// - atlantis plan -w staging -d dir --verbose
// - atlantis plan --verbose -- -key=value -key2 value2
//
// nolint: gocyclo
func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) CommentParseResult {
if multiLineRegex.MatchString(comment) {
return CommentParseResult{Ignore: true}
Expand Down
1 change: 0 additions & 1 deletion server/events/runtime/init_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type InitStepRunner struct {
DefaultTFVersion *version.Version
}

// nolint: unparam
func (i *InitStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string) (string, error) {
tfVersion := i.DefaultTFVersion
if ctx.ProjectConfig != nil && ctx.ProjectConfig.TerraformVersion != nil {
Expand Down
8 changes: 5 additions & 3 deletions server/events/vcs/github_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"github.com/runatlantis/atlantis/server/events/models"
)

// maxCommentBodySize is derived from the error message when you go over
// this limit.
const maxCommentBodySize = 65536

// GithubClient is used to perform GitHub actions.
type GithubClient struct {
client *github.Client
Expand Down Expand Up @@ -87,9 +91,6 @@ func (g *GithubClient) GetModifiedFiles(repo models.Repo, pull models.PullReques
// If comment length is greater than the max comment length we split into
// multiple comments.
func (g *GithubClient) CreateComment(repo models.Repo, pullNum int, comment string) error {
// maxCommentBodySize is derived from the error message when you go over
// this limit.
const maxCommentBodySize = 65536
comments := g.splitAtMaxChars(comment, maxCommentBodySize, "\ncontinued...\n")
for _, c := range comments {
_, _, err := g.client.Issues.CreateComment(g.ctx, repo.Owner, repo.Name, pullNum, &github.IssueComment{Body: &c})
Expand Down Expand Up @@ -145,6 +146,7 @@ func (g *GithubClient) UpdateStatus(repo models.Repo, pull models.PullRequest, s
// len separated by join which gets appended to the ends of the middle strings.
// If max <= len(join) we return an empty slice since this is an edge case we
// don't want to handle.
// nolint: unparam
func (g *GithubClient) splitAtMaxChars(comment string, max int, join string) []string {
// If we're under the limit then no need to split.
if len(comment) <= max {
Expand Down
2 changes: 1 addition & 1 deletion server/events/yaml/raw/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (s Step) ToValid() valid.Step {
for _, v := range s.StringVal {
// We ignore the error here because it should have been checked in
// Validate().
split, _ := shlex.Split(v) // nolint: errcheck
split, _ := shlex.Split(v)
return valid.Step{
StepName: RunStepName,
RunCommand: split,
Expand Down