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:
James Shubin
2020-01-25 04:05:43 -05:00
parent 525e2bafee
commit f67ad9c061
73 changed files with 775 additions and 410 deletions

View File

@@ -215,15 +215,15 @@ func modeValueFrom(who string, modeType uint32) os.FileMode {
// ParseSymbolicModes parses a slice of symbolic mode strings. By default it
// will only accept the assignment input (=), but if allowAssign is true, then
// all symbolic mode strings (=,+,-) can be used as well.
// all symbolic mode strings (=, +, -) can be used as well.
//
// Symbolic mode is expected to be a string of who (user, group, other) then
// the operation (=, +, -) then the change (read, write, execute, setuid,
// setgid, sticky).
// Symbolic mode is expected to be a string of who (user, group, other) then the
// operation (=, +, -) then the change (read, write, execute, setuid, setgid,
// sticky).
//
// Eg: ug=rw
//
// If you repeat yourself in the slice (ex. u=rw,u=w) ParseSymbolicModes will
// If you repeat yourself in the slice (eg. u=rw,u=w) ParseSymbolicModes will
// fail with an error.
func ParseSymbolicModes(modes []string, from os.FileMode, allowAssign bool) (os.FileMode, error) {
symModes := make([]struct {

View File

@@ -91,7 +91,8 @@ func ResToB64(res engine.Res) (string, error) {
return base64.StdEncoding.EncodeToString(b.Bytes()), nil
}
// B64ToRes decodes a resource from a base64 encoded string (after deserialization).
// B64ToRes decodes a resource from a base64 encoded string (after
// deserialization).
func B64ToRes(str string) (engine.Res, error) {
var output interface{}
bb, err := base64.StdEncoding.DecodeString(str)
@@ -441,12 +442,11 @@ func (obj *autoEdgeCombiner) Test(input []bool) bool {
return len(obj.ae) > obj.ptr // are there any auto edges left?
}
// AutoEdgeCombiner takes any number of AutoEdge structs, and combines them
// into a single one, so that the logic from each one can be built separately,
// and then combined using this utility. This makes implementing different
// AutoEdge generators much easier. This respects the Next() and Test() API,
// and ratchets through each AutoEdge entry until they have all run their
// course.
// AutoEdgeCombiner takes any number of AutoEdge structs, and combines them into
// a single one, so that the logic from each one can be built separately, and
// then combined using this utility. This makes implementing different AutoEdge
// generators much easier. This respects the Next() and Test() API, and ratchets
// through each AutoEdge entry until they have all run their course.
func AutoEdgeCombiner(ae ...engine.AutoEdge) (engine.AutoEdge, error) {
return &autoEdgeCombiner{
ae: ae,