From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:47094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hT5yq-0003tM-6W for guix-patches@gnu.org; Tue, 21 May 2019 10:43:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hT5yo-00087p-Fs for guix-patches@gnu.org; Tue, 21 May 2019 10:43:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55210) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hT5yo-00087a-1L for guix-patches@gnu.org; Tue, 21 May 2019 10:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hT5yn-0005jg-Ti for guix-patches@gnu.org; Tue, 21 May 2019 10:43:01 -0400 Subject: [bug#35790] [PATCH] scripts: lint: Handle warnings with a record type. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20190518093206.22069-1-mail@cbaines.net> Date: Tue, 21 May 2019 16:41:53 +0200 In-Reply-To: <20190518093206.22069-1-mail@cbaines.net> (Christopher Baines's message of "Sat, 18 May 2019 10:32:06 +0100") Message-ID: <878suz27ke.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Christopher Baines Cc: 35790@debbugs.gnu.org Hello! Christopher Baines 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 > records directly, rather than having to parse the output to determine the > package and location. Yay! > + As a rule of thumb, it=E2=80=99s best to not export the record type descrip= tor (RTD) because then anything could happen. In this case, I think the tests would be just as readable if we used =E2=80=98lint-warning-message=E2= =80=99 & co. instead of matching on the record. WDYT? > +(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; =E2=80=98lint-warning-message=E2=80=99 would alway= s return the English message, and it=E2=80=99d be up to the user to call =E2=80=98gettex= t=E2=80=99 on it, like we do for package descriptions. To achieve this, you=E2=80=99d need a little trick so that =E2=80=98xgettex= t=E2=80=99 can still extract the messages, like: (define-syntax-rule make-warning (syntax-rule (G_) ((_ package (G_ message) rest ...) (%make-warning package message rest ...)))) where =E2=80=98%make-warning=E2=80=99 is the procedure you define above. Then you need an explicit call to =E2=80=98G_=E2=80=99 at the point where m= essages are displayed. Does that make sense? > +(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 =E2=80=98append=E2=80=99, and thus =E2=80=98append-warnings= =E2=80=99 looks like an anti-pattern to me. What about simply ensuring that every checker returns a list of s? That way, we wouldn=E2=80=99t have to do such things, I t= hink. That=E2=80=99s all! Thanks, Ludo=E2=80=99.