Thanks Rog - we are discarding a few errors after all! I just realised I was only scanning the bodies of top level functions, not methods. That's what I get for trying to code on holiday!

On 17/07/14 09:08, roger peppe wrote:
Nice (and good to get some familiarity with go/ast).

You might want to check out github.com/kisielk/errcheck, which
does a similar thing, but using the types package, so
it can do a somewhat more comprehensive check.

It's a lot slower though.

Here's the output when running it on juju-core:
     http://paste.ubuntu.com/7805613/

  cheers,
     rog.

On 16 July 2014 21:39, Jesse Meek <[email protected]> wrote:
After checking the import grouping I became curious as to what else I could
check. So, while on holiday, I wrote another script to check if errors are
being discarded. It uses the ast package to check for both assignment
statements, where a value of type "error" is being assigned to a variable of
name "_" and non-assignment expression statements that return at least one
value of type "error".

The results were disappointing, for me, but good for Juju. It only picked up
one case:

environs/config.go:48-51

     p, _ := Provider(kind)
     if p == nil {
         return fmt.Errorf("environment %q has an unknown provider type %q",
rawEnviron["name"], kind)
     }

So, not a huge revelation, but good to know we are not discarding errors at
least. :)

--
Juju-dev mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/juju-dev


--
Juju-dev mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju-dev

Reply via email to