lang, test: Fix capitalization for consistency
This commit is contained in:
@@ -38,7 +38,7 @@ import (
|
|||||||
"github.com/purpleidea/mgmt/lang/interfaces"
|
"github.com/purpleidea/mgmt/lang/interfaces"
|
||||||
"github.com/purpleidea/mgmt/lang/types"
|
"github.com/purpleidea/mgmt/lang/types"
|
||||||
"github.com/purpleidea/mgmt/lang/types/full"
|
"github.com/purpleidea/mgmt/lang/types/full"
|
||||||
langutil "github.com/purpleidea/mgmt/lang/util"
|
langUtil "github.com/purpleidea/mgmt/lang/util"
|
||||||
"github.com/purpleidea/mgmt/pgraph"
|
"github.com/purpleidea/mgmt/pgraph"
|
||||||
"github.com/purpleidea/mgmt/util"
|
"github.com/purpleidea/mgmt/util"
|
||||||
"github.com/purpleidea/mgmt/util/errwrap"
|
"github.com/purpleidea/mgmt/util/errwrap"
|
||||||
@@ -3685,7 +3685,7 @@ func (obj *StmtProg) SetScope(scope *interfaces.Scope) error {
|
|||||||
return fmt.Errorf("import `%s` already exists in this scope", imp.Name)
|
return fmt.Errorf("import `%s` already exists in this scope", imp.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := langutil.ParseImportName(imp.Name)
|
result, err := langUtil.ParseImportName(imp.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "import `%s` is not valid", imp.Name)
|
return errwrap.Wrapf(err, "import `%s` is not valid", imp.Name)
|
||||||
}
|
}
|
||||||
@@ -7125,7 +7125,7 @@ func (obj *ExprFunc) Init(data *interfaces.Data) error {
|
|||||||
}
|
}
|
||||||
typs = append(typs, f.T)
|
typs = append(typs, f.T)
|
||||||
}
|
}
|
||||||
if err := langutil.HasDuplicateTypes(typs); err != nil {
|
if err := langUtil.HasDuplicateTypes(typs); err != nil {
|
||||||
return errwrap.Wrapf(err, "func list contains a duplicate signature")
|
return errwrap.Wrapf(err, "func list contains a duplicate signature")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7376,7 +7376,7 @@ func (obj *ExprFunc) SetType(typ *types.Type) error {
|
|||||||
|
|
||||||
if len(obj.Values) > 0 {
|
if len(obj.Values) > 0 {
|
||||||
// search for the compatible type
|
// search for the compatible type
|
||||||
_, err := langutil.FnMatch(typ, obj.Values)
|
_, err := langUtil.FnMatch(typ, obj.Values)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "could not build values func")
|
return errwrap.Wrapf(err, "could not build values func")
|
||||||
}
|
}
|
||||||
@@ -7708,7 +7708,7 @@ func (obj *ExprFunc) Graph(env map[string]interfaces.Func) (*pgraph.Graph, inter
|
|||||||
T: obj.typ,
|
T: obj.typ,
|
||||||
})
|
})
|
||||||
} else /* len(obj.Values) > 0 */ {
|
} else /* len(obj.Values) > 0 */ {
|
||||||
index, err := langutil.FnMatch(obj.typ, obj.Values)
|
index, err := langUtil.FnMatch(obj.typ, obj.Values)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// programming error
|
// programming error
|
||||||
// since type checking succeeded at this point, there should only be one match
|
// since type checking succeeded at this point, there should only be one match
|
||||||
@@ -8679,7 +8679,7 @@ func (obj *ExprVar) Apply(fn func(interfaces.Node) error) error { return fn(obj)
|
|||||||
// Init initializes this branch of the AST, and returns an error if it fails to
|
// Init initializes this branch of the AST, and returns an error if it fails to
|
||||||
// validate.
|
// validate.
|
||||||
func (obj *ExprVar) Init(*interfaces.Data) error {
|
func (obj *ExprVar) Init(*interfaces.Data) error {
|
||||||
return langutil.ValidateVarName(obj.Name)
|
return langUtil.ValidateVarName(obj.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interpolate returns a new node (aka a copy) once it has been expanded. This
|
// Interpolate returns a new node (aka a copy) once it has been expanded. This
|
||||||
@@ -8933,7 +8933,7 @@ func (obj *ExprParam) Apply(fn func(interfaces.Node) error) error { return fn(ob
|
|||||||
// Init initializes this branch of the AST, and returns an error if it fails to
|
// Init initializes this branch of the AST, and returns an error if it fails to
|
||||||
// validate.
|
// validate.
|
||||||
func (obj *ExprParam) Init(*interfaces.Data) error {
|
func (obj *ExprParam) Init(*interfaces.Data) error {
|
||||||
return langutil.ValidateVarName(obj.Name)
|
return langUtil.ValidateVarName(obj.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interpolate returns a new node (aka a copy) once it has been expanded. This
|
// Interpolate returns a new node (aka a copy) once it has been expanded. This
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/purpleidea/mgmt/lang/funcs"
|
"github.com/purpleidea/mgmt/lang/funcs"
|
||||||
"github.com/purpleidea/mgmt/lang/interfaces"
|
"github.com/purpleidea/mgmt/lang/interfaces"
|
||||||
"github.com/purpleidea/mgmt/lang/types"
|
"github.com/purpleidea/mgmt/lang/types"
|
||||||
langutil "github.com/purpleidea/mgmt/lang/util"
|
langUtil "github.com/purpleidea/mgmt/lang/util"
|
||||||
"github.com/purpleidea/mgmt/util/errwrap"
|
"github.com/purpleidea/mgmt/util/errwrap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ func Register(name string, fns []*types.FuncValue) {
|
|||||||
typs = append(typs, f.T)
|
typs = append(typs, f.T)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := langutil.HasDuplicateTypes(typs); err != nil {
|
if err := langUtil.HasDuplicateTypes(typs); err != nil {
|
||||||
panic(fmt.Sprintf("polyfunc %s has a duplicate implementation: %+v", name, err))
|
panic(fmt.Sprintf("polyfunc %s has a duplicate implementation: %+v", name, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,7 +483,7 @@ func (obj *WrappedFunc) Polymorphisms(partialType *types.Type, partialValues []t
|
|||||||
func (obj *WrappedFunc) Build(typ *types.Type) (*types.Type, error) {
|
func (obj *WrappedFunc) Build(typ *types.Type) (*types.Type, error) {
|
||||||
// typ is the KindFunc signature we're trying to build...
|
// typ is the KindFunc signature we're trying to build...
|
||||||
|
|
||||||
index, err := langutil.FnMatch(typ, obj.Fns)
|
index, err := langUtil.FnMatch(typ, obj.Fns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -523,7 +523,7 @@ func (obj *WrappedFunc) Validate() error {
|
|||||||
typs = append(typs, f.T)
|
typs = append(typs, f.T)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := langutil.HasDuplicateTypes(typs); err != nil {
|
if err := langUtil.HasDuplicateTypes(typs); err != nil {
|
||||||
return errwrap.Wrapf(err, "duplicate implementation found")
|
return errwrap.Wrapf(err, "duplicate implementation found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import (
|
|||||||
"github.com/purpleidea/mgmt/lang/funcs"
|
"github.com/purpleidea/mgmt/lang/funcs"
|
||||||
"github.com/purpleidea/mgmt/lang/interfaces"
|
"github.com/purpleidea/mgmt/lang/interfaces"
|
||||||
"github.com/purpleidea/mgmt/lang/types"
|
"github.com/purpleidea/mgmt/lang/types"
|
||||||
langutil "github.com/purpleidea/mgmt/lang/util"
|
langUtil "github.com/purpleidea/mgmt/lang/util"
|
||||||
"github.com/purpleidea/mgmt/util"
|
"github.com/purpleidea/mgmt/util"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
@@ -2568,7 +2568,7 @@ func TestImportParsing0(t *testing.T) {
|
|||||||
fail: true, // don't allow double root slash
|
fail: true, // don't allow double root slash
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Logf("ModuleMagicPrefix: %s", langutil.ModuleMagicPrefix)
|
t.Logf("ModuleMagicPrefix: %s", langUtil.ModuleMagicPrefix)
|
||||||
names := []string{}
|
names := []string{}
|
||||||
for index, tc := range testCases { // run all the tests
|
for index, tc := range testCases { // run all the tests
|
||||||
if util.StrInList(tc.name, names) {
|
if util.StrInList(tc.name, names) {
|
||||||
@@ -2579,7 +2579,7 @@ func TestImportParsing0(t *testing.T) {
|
|||||||
t.Run(fmt.Sprintf("test #%d (%s)", index, tc.name), func(t *testing.T) {
|
t.Run(fmt.Sprintf("test #%d (%s)", index, tc.name), func(t *testing.T) {
|
||||||
name, fail, alias, isSystem, isLocal, isFile, path, url := tc.name, tc.fail, tc.alias, tc.isSystem, tc.isLocal, tc.isFile, tc.path, tc.url
|
name, fail, alias, isSystem, isLocal, isFile, path, url := tc.name, tc.fail, tc.alias, tc.isSystem, tc.isLocal, tc.isFile, tc.path, tc.url
|
||||||
|
|
||||||
output, err := langutil.ParseImportName(name)
|
output, err := langUtil.ParseImportName(name)
|
||||||
if !fail && err != nil {
|
if !fail && err != nil {
|
||||||
t.Errorf("test #%d: FAIL", index)
|
t.Errorf("test #%d: FAIL", index)
|
||||||
t.Errorf("test #%d: ParseImportName failed with: %+v", index, err)
|
t.Errorf("test #%d: ParseImportName failed with: %+v", index, err)
|
||||||
|
|||||||
@@ -83,11 +83,15 @@ function consistent-imports() {
|
|||||||
if grep $'\t"github.com/hashicorp/go-multierror"' "$1"; then
|
if grep $'\t"github.com/hashicorp/go-multierror"' "$1"; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# import as langutil
|
# import as *Util (should be fooUtil) with util capitalized
|
||||||
|
if grep $'util "github.com/purpleidea/mgmt"' "$1"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# import as langUtil
|
||||||
if grep $'\t"github.com/purpleidea/mgmt/lang/util"' "$1"; then
|
if grep $'\t"github.com/purpleidea/mgmt/lang/util"' "$1"; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# import as engineutil
|
# import as engineUtil
|
||||||
if grep $'\t"github.com/purpleidea/mgmt/engine/util"' "$1"; then
|
if grep $'\t"github.com/purpleidea/mgmt/engine/util"' "$1"; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user