all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christopher Baines <mail@cbaines.net>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: Linting, and how to get the information in to the Guix Data Serivce
Date: Fri, 10 May 2019 08:02:54 +0100	[thread overview]
Message-ID: <8736lmokpt.fsf@cbaines.net> (raw)
In-Reply-To: <874l662cea.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3688 bytes --]


Ludovic Courtès <ludo@gnu.org> writes:

> Hello!
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> Christopher Baines <mail@cbaines.net> writes:
>>
>>> I've never worked with this part of Guix before, and some of it is quite
>>> complex, so I've started by attempting to do the first bit, storing
>>> warnings as data before outputting them. I've attached a patch.
>
> Providing more structure sounds like a good idea to me (though in the
> end it’s still just text; not sure if that’s good enough for what you
> had in mind?).

Great, I'm also not entirely sure what would be best, but I think having
the package and location as the record values, along with the message is
a good start.

> From a UI viewpoint, it’s important that ‘guix lint’ prints warning as
> they come, rather than eat CPU for some time and eventually spit out
> everything at once.

So, currently this does change the behaviour, but I'm hoping it's still
ok. The warnings will be printed after running each checker. So if there
are checkers that take a long time, and possibly report multiple
warnings, then that could be an issue, but I don't believe this is the
case.

>> From cd16443893afdacf9f3e4d8256cc943a5928aed4 Mon Sep 17 00:00:00 2001
>> From: Christopher Baines <mail@cbaines.net>
>> Date: Mon, 6 May 2019 19:00:58 +0100
>> Subject: [PATCH] scripts: lint: Handle warnings with a record type.
>>
>> Rather than emiting warnings directly to a port, have the checkers return the
>> warning or warnings.
>>
>> This makes it easier to use the warnings in different ways, for example,
>> loading the data in to a database, as you can work with the <lint-warning>
>> records directly, rather than having to parse the output to determine the
>> package and location.
>
> [...]
>
>> +(define-record-type* <lint-warning>
>> +  lint-warning make-lint-warning
>> +  lint-warning?
>> +  (package  lint-warning-package)
>> +  (message  lint-warning-message)
>> +  (location lint-warning-field
>> +            (default #f)))
>
> It could be useful to have a ‘checker’ field linking to the checker that
> produced the warning.

Good point. Any suggestions on how to do this? At the moment, the
checker values don't really have names, they're just in a list. I could
move the definitions out of the list, and define them at the top level
like packages. Another option I was possibly considering is populating
the checker field after the warnings are returned from the checker
function... any thoughts?

>>    (define (check-not-empty description)
>>      (when (string-null? description)
>> -      (emit-warning package
>> +      (make-warning package
>>                      (G_ "description should not be empty")
>> -                    'description)))
>> +                    #:field 'description)))
>
> This procedure returns either a warning or the unspecified value, which
> is probably not intended?  I suppose a lot of the code is currently
> written with ‘emit-warning’ in effect position, which will have to be
> changed.

So, it's important that all the generated warnings are returned, so I
changed some checkers to return lists. Also, I added a append-warnings
function which takes 1 or more arguments, and will sort the warnings in
to a neat list. I did consider changing all the checkers to return a
neat list of warnings, but that would require more changes. What do you
think?

> I suppose tests/lint.scm needs to be converted to the new API?

Ah, yep. I've made a start on this now. I think returning
<lint-warnings> will make writing the tests easier, which is nice.

Thanks,

Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 962 bytes --]

  reply	other threads:[~2019-05-10  7:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06 18:26 Linting, and how to get the information in to the Guix Data Serivce Christopher Baines
2019-05-06 19:10 ` Christopher Baines
2019-05-07 21:16   ` Ludovic Courtès
2019-05-10  7:02     ` Christopher Baines [this message]
2019-05-18 10:30       ` Christopher Baines

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8736lmokpt.fsf@cbaines.net \
    --to=mail@cbaines.net \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.