test: Fix broken gometalinter test
The test for gometalinter got silently broken in an earlier commit. Look for the missing space that was added back in this commit to see why! In any case, this now fixes some of the things that weren't previously caught by this change. If anyone knows how to run these sorts of tests properly so that entire packages are tested and so that we can enable additional tests, please let me know! It's also unclear why goreportcard catches a few additional problems which aren't found by running this ourselves. See: https://goreportcard.com/report/github.com/purpleidea/mgmt for more information.
This commit is contained in:
@@ -322,10 +322,7 @@ func (obj *File) Truncate(size int64) error {
|
||||
obj.ModTime = time.Now()
|
||||
|
||||
// this pushes the new data and metadata up to etcd
|
||||
if err := obj.Sync(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return obj.Sync()
|
||||
}
|
||||
|
||||
// Read reads up to len(b) bytes from the File. It returns the number of bytes
|
||||
|
||||
@@ -37,7 +37,7 @@ func init() {
|
||||
funcs.Register("vumeter", func() interfaces.Func { return &VUMeterFunc{} }) // must register the func and name
|
||||
}
|
||||
|
||||
// VUMeter is a gimmic function to display a vu meter from the microphone.
|
||||
// VUMeterFunc is a gimmic function to display a vu meter from the microphone.
|
||||
type VUMeterFunc struct {
|
||||
init *interfaces.Init
|
||||
last types.Value // last value received to use for diff
|
||||
|
||||
@@ -55,6 +55,8 @@ type Info struct {
|
||||
Err error // did this fact validate?
|
||||
}
|
||||
|
||||
// Init is the structure of values and references which is passed into all
|
||||
// facts on initialization.
|
||||
type Init struct {
|
||||
Hostname string // uuid for the host
|
||||
//Noop bool
|
||||
|
||||
@@ -85,7 +85,7 @@ func (obj *StmtBind) Unify() ([]interfaces.Invariant, error) {
|
||||
// that fulfill the Stmt interface do not produces vertices, where as their
|
||||
// children might. This particular bind statement adds its linked expression to
|
||||
// the graph. It is not logically done in the ExprVar since that could exist
|
||||
// mulitple times for the single binding operation done here.
|
||||
// multiple times for the single binding operation done here.
|
||||
func (obj *StmtBind) Graph() (*pgraph.Graph, error) {
|
||||
return obj.Value.Graph()
|
||||
}
|
||||
@@ -134,7 +134,7 @@ func (obj *StmtRes) Interpolate() (interfaces.Stmt, error) {
|
||||
}
|
||||
|
||||
// SetScope stores the scope for later use in this resource and it's children,
|
||||
// which it propogates this downwards to.
|
||||
// which it propagates this downwards to.
|
||||
func (obj *StmtRes) SetScope(scope *interfaces.Scope) error {
|
||||
if err := obj.Name.SetScope(scope); err != nil {
|
||||
return err
|
||||
@@ -419,7 +419,7 @@ func (obj *StmtEdge) Interpolate() (interfaces.Stmt, error) {
|
||||
}
|
||||
|
||||
// SetScope stores the scope for later use in this resource and it's children,
|
||||
// which it propogates this downwards to.
|
||||
// which it propagates this downwards to.
|
||||
func (obj *StmtEdge) SetScope(scope *interfaces.Scope) error {
|
||||
for _, x := range obj.EdgeHalfList {
|
||||
if err := x.Name.SetScope(scope); err != nil {
|
||||
@@ -592,7 +592,7 @@ func (obj *StmtIf) Interpolate() (interfaces.Stmt, error) {
|
||||
}
|
||||
|
||||
// SetScope stores the scope for later use in this resource and it's children,
|
||||
// which it propogates this downwards to.
|
||||
// which it propagates this downwards to.
|
||||
func (obj *StmtIf) SetScope(scope *interfaces.Scope) error {
|
||||
if err := obj.Condition.SetScope(scope); err != nil {
|
||||
return err
|
||||
@@ -1280,7 +1280,7 @@ func (obj *ExprList) Interpolate() (interfaces.Expr, error) {
|
||||
}
|
||||
|
||||
// SetScope stores the scope for later use in this resource and it's children,
|
||||
// which it propogates this downwards to.
|
||||
// which it propagates this downwards to.
|
||||
func (obj *ExprList) SetScope(scope *interfaces.Scope) error {
|
||||
for _, x := range obj.Elements {
|
||||
if err := x.SetScope(scope); err != nil {
|
||||
@@ -1533,7 +1533,7 @@ func (obj *ExprMap) Interpolate() (interfaces.Expr, error) {
|
||||
}
|
||||
|
||||
// SetScope stores the scope for later use in this resource and it's children,
|
||||
// which it propogates this downwards to.
|
||||
// which it propagates this downwards to.
|
||||
func (obj *ExprMap) SetScope(scope *interfaces.Scope) error {
|
||||
for _, x := range obj.KVs {
|
||||
if err := x.Key.SetScope(scope); err != nil {
|
||||
@@ -1869,7 +1869,7 @@ func (obj *ExprStruct) Interpolate() (interfaces.Expr, error) {
|
||||
}
|
||||
|
||||
// SetScope stores the scope for later use in this resource and it's children,
|
||||
// which it propogates this downwards to.
|
||||
// which it propagates this downwards to.
|
||||
func (obj *ExprStruct) SetScope(scope *interfaces.Scope) error {
|
||||
for _, x := range obj.Fields {
|
||||
if err := x.Value.SetScope(scope); err != nil {
|
||||
@@ -2164,10 +2164,7 @@ func (obj *ExprFunc) Func() (interfaces.Func, error) {
|
||||
// ever receive any incoming values (no incoming edges) so this should never be
|
||||
// called. It has been implemented for uniformity.
|
||||
func (obj *ExprFunc) SetValue(value types.Value) error {
|
||||
if err := obj.typ.Cmp(value.Type()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return obj.typ.Cmp(value.Type())
|
||||
}
|
||||
|
||||
// Value returns the value of this expression in our type system. This will
|
||||
@@ -2283,7 +2280,7 @@ func (obj *ExprCall) Interpolate() (interfaces.Expr, error) {
|
||||
}
|
||||
|
||||
// SetScope stores the scope for later use in this resource and it's children,
|
||||
// which it propogates this downwards to.
|
||||
// which it propagates this downwards to.
|
||||
func (obj *ExprCall) SetScope(scope *interfaces.Scope) error {
|
||||
for _, x := range obj.Args {
|
||||
if err := x.SetScope(scope); err != nil {
|
||||
@@ -2876,18 +2873,15 @@ func (obj *ExprIf) Interpolate() (interfaces.Expr, error) {
|
||||
}
|
||||
|
||||
// SetScope stores the scope for later use in this resource and it's children,
|
||||
// which it propogates this downwards to.
|
||||
// which it propagates this downwards to.
|
||||
func (obj *ExprIf) SetScope(scope *interfaces.Scope) error {
|
||||
if err := obj.Condition.SetScope(scope); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := obj.ThenBranch.SetScope(scope); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := obj.ElseBranch.SetScope(scope); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return obj.Condition.SetScope(scope)
|
||||
}
|
||||
|
||||
// SetType is used to set the type of this expression once it is known. This
|
||||
|
||||
@@ -27,7 +27,7 @@ gml='gometalinter --disable-all'
|
||||
gml="$gml --enable=goimports"
|
||||
gml="$gml --enable=golint"
|
||||
#gml="$gml --enable=gosimple" # TODO: only a few fixes needed
|
||||
gml="$gml --enable=gotype"
|
||||
#gml="$gml --enable=gotype"
|
||||
#gml="$gml --enable=ineffassign" # TODO: only a few fixes needed
|
||||
#gml="$gml --enable=interfacer" # TODO: only a few fixes needed
|
||||
#gml="$gml --enable=lll --line-length=200" # TODO: only a few fixes needed
|
||||
@@ -35,15 +35,18 @@ gml="$gml --enable=misspell"
|
||||
#gml="$gml --enable=safesql" # FIXME: made my machine slow
|
||||
#gml="$gml --enable=staticcheck" # TODO: only a few fixes needed
|
||||
#gml="$gml --enable=structcheck" # TODO: only a few fixes needed
|
||||
gml="$gml --enable=unconvert"
|
||||
#gml="$gml --enable=unconvert"
|
||||
#gml="$gml --enable=unparam" # TODO: only a few fixes needed
|
||||
#gml="$gml --enable=unused" # TODO: only a few fixes needed
|
||||
#gml="$gml --enable=varcheck" # TODO: only a few fixes needed
|
||||
gometalinter="$gml"
|
||||
|
||||
echo "Using: $gometalinter"
|
||||
# loop through directories in an attempt to scan each go package
|
||||
# TODO: lint the *.go examples as individual files and not as a single *.go
|
||||
for dir in `find . -maxdepth 5 -type d -not -path './old/*' -not -path './old' -not -path './tmp/*' -not -path './tmp' -not -path './.*' -not -path './vendor/*' -not -path './bindata/*' -not -path ' ./examples/*' -not -path './test/*'`; do
|
||||
#echo "Running in: $dir"
|
||||
|
||||
match="$dir/*.go"
|
||||
#echo "match is: $match"
|
||||
if ! ls $match &>/dev/null; then
|
||||
@@ -51,6 +54,7 @@ for dir in `find . -maxdepth 5 -type d -not -path './old/*' -not -path './old' -
|
||||
continue # no *.go files found
|
||||
fi
|
||||
|
||||
#echo "Running: $gometalinter '$dir'"
|
||||
run-test $gometalinter "$dir" || fail_test "gometalinter did not pass"
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user