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: 35790@debbugs.gnu.org
Subject: [bug#35790] [PATCH] scripts: lint: Handle warnings with a record type.
Date: Sat, 01 Jun 2019 20:09:02 +0100	[thread overview]
Message-ID: <87ef4dxgvl.fsf@cbaines.net> (raw)
In-Reply-To: <878suz27ke.fsf@gnu.org>

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


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

> Hello!
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> 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.
>
> Yay!
>
>> +            <lint-warning>
>
> As a rule of thumb, it’s best to not export the record type descriptor
> (RTD) because then anything could happen.  In this case, I think the
> tests would be just as readable if we used ‘lint-warning-message’ &
> co. instead of matching on the record.
>
> WDYT?

Interesting. I've now adjusted the tests accordingly and sent an updated
patch.

I've stuck with using match, as this gives much better error messages
than using car, or lint-warning-message without checking the thing your
working with is actually a list with a single warning. I've wrapped this
up as a single-lint-warning-message that many of the tests use.

>> +(define* (make-warning package message
>> +                       #:key field location)
>> +  (make-lint-warning
>> +   package
>> +   message
>
> In practice MESSAGE is already translated.  I think it would be more
> flexible if it were not; ‘lint-warning-message’ would always return the
> English message, and it’d be up to the user to call ‘gettext’ on it,
> like we do for package descriptions.
>
> To achieve this, you’d need a little trick so that ‘xgettext’ can still
> extract the messages, like:
>
>
>   (define-syntax-rule make-warning
>     (syntax-rule (G_)
>       ((_ package (G_ message) rest ...)
>        (%make-warning package message rest ...))))
>
> where ‘%make-warning’ is the procedure you define above.
>
> Then you need an explicit call to ‘G_’ at the point where messages are
> displayed.
>
> Does that make sense?

Yes, but I'm unsure it'll work for all the messages.

Some of them it translates a format string first, then uses that format
string, and that becomes the message, e.g.

  (format #f (G_ "invalid description: ~s") description)

Given that you'd be trying to get the translation for "invalid
description: guile" for example, I'm not sure you can defer the
translation without also defering customising the message, if that makes
sense?

I haven't actually tried this yet, so I could be wrong.

>> +(define (append-warnings . args)
>> +  (fold (lambda (arg warnings)
>> +          (cond
>> +           ((list? arg)
>> +            (append warnings
>> +                    (filter lint-warning?
>> +                            arg)))
>> +           ((lint-warning? arg)
>> +            (append warnings
>> +                    (list arg)))
>> +           (else warnings)))
>> +        '()
>> +        args))
>
> I always feel that we should have procedures that operate on lists of
> anything, like ‘append’, and thus ‘append-warnings’ looks like an
> anti-pattern to me.
>
> What about simply ensuring that every checker returns a list of
> <lint-warning>s?  That way, we wouldn’t have to do such things, I think.

I did consider that initially, but it involved restructuring the code
even more, so I put it off. In this latest patch though, I have adjusted
it so all the checkers return lists of warnings.

Thanks for taking a look :)

Chris

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

  parent reply	other threads:[~2019-06-01 19:10 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-18  9:32 [bug#35790] [PATCH] scripts: lint: Handle warnings with a record type Christopher Baines
2019-05-21 14:41 ` Ludovic Courtès
2019-06-01 18:31   ` Christopher Baines
2019-06-07  7:44     ` Ludovic Courtès
2019-06-16 13:00       ` Christopher Baines
2019-06-20 11:40         ` Ludovic Courtès
2019-06-01 19:09   ` Christopher Baines [this message]
2019-06-07  7:38     ` Ludovic Courtès
2019-06-16 12:56       ` [bug#35790] [PATCH] scripts: lint: Separate the message warning text and data Christopher Baines
2019-06-24  8:36         ` Ludovic Courtès
2019-06-29  8:46           ` Christopher Baines
2019-06-16 13:05       ` [bug#35790] [PATCH] scripts: lint: Handle warnings with a record type Christopher Baines
2019-06-20 11:49         ` Ludovic Courtès
2019-06-24  6:46           ` Christopher Baines
2019-06-24  8:33             ` Ludovic Courtès
2019-06-24  8:39             ` Ludovic Courtès
2019-06-29 11:25               ` [bug#35790] [PATCH 1/2] " Christopher Baines
2019-06-29 11:25                 ` [bug#35790] [PATCH 2/2] scripts: lint: Separate the message warning text and data Christopher Baines
2019-06-29 11:56               ` [bug#35790] [PATCH] scripts: lint: Handle warnings with a record type Christopher Baines
2019-07-01 12:32                 ` Ludovic Courtès
2019-07-02 19:25                   ` [bug#35790] [PATCH 1/2] lint: Move the linting code to a different module Christopher Baines
2019-07-02 19:25                     ` [bug#35790] [PATCH 2/2] lint: Separate checkers by dependence on the internet Christopher Baines
2019-07-12 14:38                       ` Ludovic Courtès
2019-07-14 18:17                         ` Christopher Baines
2019-07-12 14:36                     ` [bug#35790] [PATCH 1/2] lint: Move the linting code to a different module Ludovic Courtès
2019-07-14 18:03                       ` Christopher Baines
2019-07-14 18:23                         ` Christopher Baines
2019-07-15  9:20                         ` Ludovic Courtès
2019-07-15 19:45                           ` [bug#35790] [PATCH 1/4] scripts: lint: Handle warnings with a record type Christopher Baines
2019-07-15 19:45                             ` [bug#35790] [PATCH 2/4] scripts: lint: Separate the message warning text and data Christopher Baines
2019-07-15 19:45                             ` [bug#35790] [PATCH 3/4] lint: Move the linting code to a different module Christopher Baines
2019-07-15 19:45                             ` [bug#35790] [PATCH 4/4] lint: Separate checkers by dependence on the internet Christopher Baines
2019-07-15 20:17                               ` Ludovic Courtès
2019-07-15 22:23                                 ` bug#35790: " Christopher Baines
2019-07-16 21:34                                   ` [bug#35790] " Ludovic Courtès
2019-07-15 19:51                           ` [bug#35790] [PATCH 1/2] lint: Move the linting code to a different module Christopher Baines
2019-07-02 20:15                   ` [bug#35790] [PATCH] scripts: lint: Handle warnings with a record type 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=87ef4dxgvl.fsf@cbaines.net \
    --to=mail@cbaines.net \
    --cc=35790@debbugs.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.