test: Add a check for too long or badly reflowed docstrings
This ensures that docstring comments are wrapped to 80 chars. ffrank seemed to be making this mistake far too often, and it's a silly thing to look for manually. As it turns out, I've made it too, as have many others. Now we have a test that checks for most cases. There are still a few stray cases that aren't checked automatically, but this can be improved upon if someone is motivated to do so. Before anyone complains about the 80 character limit: this only checks docstring comments, not source code length or inline source code comments. There's no excuse for having docstrings that are badly reflowed or over 80 chars, particularly if you have an automated test.
This commit is contained in:
@@ -62,8 +62,8 @@ const (
|
||||
FileModeAllowAssign = false
|
||||
)
|
||||
|
||||
// FileRes is a file and directory resource. Dirs are defined by names ending
|
||||
// in a slash.
|
||||
// FileRes is a file and directory resource. Dirs are defined by names ending in
|
||||
// a slash.
|
||||
type FileRes struct {
|
||||
traits.Base // add the base methods without re-implementation
|
||||
traits.Edgeable
|
||||
@@ -324,11 +324,11 @@ func (obj *FileRes) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Watch is the primary listener for this resource and it outputs events.
|
||||
// This one is a file watcher for files and directories.
|
||||
// Modify with caution, it is probably important to write some test cases first!
|
||||
// If the Watch returns an error, it means that something has gone wrong, and it
|
||||
// must be restarted. On a clean exit it returns nil.
|
||||
// Watch is the primary listener for this resource and it outputs events. This
|
||||
// one is a file watcher for files and directories. Modify with caution, it is
|
||||
// probably important to write some test cases first! If the Watch returns an
|
||||
// error, it means that something has gone wrong, and it must be restarted. On a
|
||||
// clean exit it returns nil.
|
||||
func (obj *FileRes) Watch() error {
|
||||
// TODO: chan *recwatch.Event instead?
|
||||
inputEvents := make(chan recwatch.Event)
|
||||
@@ -1322,7 +1322,8 @@ func (obj *FileResAutoEdges) Next() []engine.ResUID {
|
||||
return []engine.ResUID{value} // we return one, even though api supports N
|
||||
}
|
||||
|
||||
// Test gets results of the earlier Next() call, & returns if we should continue!
|
||||
// Test gets results of the earlier Next() call, & returns if we should
|
||||
// continue!
|
||||
func (obj *FileResAutoEdges) Test(input []bool) bool {
|
||||
// We do all of these first...
|
||||
if !obj.fdone && len(obj.frags) > 0 {
|
||||
@@ -1390,8 +1391,8 @@ func (obj *FileRes) AutoEdges() (engine.AutoEdge, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UIDs includes all params to make a unique identification of this object.
|
||||
// Most resources only return one, although some resources can return multiple.
|
||||
// UIDs includes all params to make a unique identification of this object. Most
|
||||
// resources only return one, although some resources can return multiple.
|
||||
func (obj *FileRes) UIDs() []engine.ResUID {
|
||||
x := &FileUID{
|
||||
BaseUID: engine.BaseUID{Name: obj.Name(), Kind: obj.Kind()},
|
||||
@@ -1417,8 +1418,8 @@ func (obj *FileRes) CollectPattern(pattern string) {
|
||||
obj.Dirname = pattern // XXX: simplistic for now
|
||||
}
|
||||
|
||||
// UnmarshalYAML is the custom unmarshal handler for this struct.
|
||||
// It is primarily useful for setting the defaults.
|
||||
// UnmarshalYAML is the custom unmarshal handler for this struct. It is
|
||||
// primarily useful for setting the defaults.
|
||||
func (obj *FileRes) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
type rawRes FileRes // indirection to avoid infinite recursion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user