diff --git a/lint/file.go b/lint/file.go index 7396f2859..16110289d 100644 --- a/lint/file.go +++ b/lint/file.go @@ -47,7 +47,7 @@ func (f *File) ToPosition(pos token.Pos) token.Position { return f.Pkg.fset.Position(pos) } -// Render renters a node. +// Render renders a node. func (f *File) Render(x interface{}) string { var buf bytes.Buffer if err := printer.Fprint(&buf, f.Pkg.fset, x); err != nil { @@ -74,7 +74,7 @@ var basicTypeKinds = map[types.BasicKind]string{ // and indicates what its default type is. // scope may be nil. func (f *File) IsUntypedConst(expr ast.Expr) (defType string, ok bool) { - // Re-evaluate expr outside of its context to see if it's untyped. + // Re-evaluate expr outside its context to see if it's untyped. // (An expr evaluated within, for example, an assignment context will get the type of the LHS.) exprStr := f.Render(expr) tv, err := types.Eval(f.Pkg.fset, f.Pkg.TypesPkg, expr.Pos(), exprStr) @@ -206,7 +206,6 @@ func (f *File) disabledIntervals(rules []Rule, mustSpecifyDisableReason bool, fa if len(match) == 0 { continue } - ruleNames := []string{} tempNames := strings.Split(match[rulesPos], ",") for _, name := range tempNames { @@ -215,7 +214,6 @@ func (f *File) disabledIntervals(rules []Rule, mustSpecifyDisableReason bool, fa ruleNames = append(ruleNames, name) } } - mustCheckDisablingReason := mustSpecifyDisableReason && match[directivePos] == "disable" if mustCheckDisablingReason && strings.Trim(match[reasonPos], " ") == "" { failures <- Failure{ diff --git a/lint/linter.go b/lint/linter.go index cdca84fb5..b124e626b 100644 --- a/lint/linter.go +++ b/lint/linter.go @@ -70,7 +70,13 @@ func (l *Linter) lintPackage(filenames []string, ruleSet []Rule, config Config, file, err := NewFile(filename, content, pkg) if err != nil { - return err + failures <- Failure{ + Confidence: 1, + Failure: fmt.Sprintf("invalid file %s: %v", filename, err.Error()), + RuleName: "no-rule", + Category: "validity", + } + continue } pkg.files[filename] = file }