And now for my next trick ...
Jesse Meek
jesse.meek at canonical.com
Fri Jul 18 01:08:21 UTC 2014
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 <jesse.meek at canonical.com> 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
>> Juju-dev at lists.ubuntu.com
>> Modify settings or unsubscribe at:
>> https://lists.ubuntu.com/mailman/listinfo/juju-dev
More information about the Juju-dev
mailing list