Support filtering lint warnings by linter

This commit is contained in:
Christopher Baines 2019-09-01 14:11:50 +01:00
parent 2bfd81ee1b
commit be25e487f1
3 changed files with 28 additions and 10 deletions

View file

@ -59,13 +59,25 @@ INNER JOIN lint_warning_message_sets
INNER JOIN lint_warning_messages INNER JOIN lint_warning_messages
ON lint_warning_messages.locale = 'en_US.utf8' ON lint_warning_messages.locale = 'en_US.utf8'
AND lint_warning_messages.id = ANY (lint_warning_message_sets.message_ids) AND lint_warning_messages.id = ANY (lint_warning_message_sets.message_ids)
WHERE lint_warnings.id IN ( "
(if linters
(string-append
"INNER JOIN (VALUES "
(string-join
(map (lambda (lint-checker-name)
(simple-format
#f "($STR$~A$STR$)" lint-checker-name))
linters)
",")
") AS linters (name) ON lint_checkers.name = linters.name ")
"")
"WHERE lint_warnings.id IN (
SELECT lint_warning_id SELECT lint_warning_id
FROM guix_revision_lint_warnings FROM guix_revision_lint_warnings
INNER JOIN guix_revisions ON guix_revision_id = guix_revisions.id INNER JOIN guix_revisions ON guix_revision_id = guix_revisions.id
WHERE commit = $1 WHERE commit = $1
)" )"
(if package-query (if package-query
" AND to_tsvector(packages.name) @@ plainto_tsquery($2)" " AND to_tsvector(packages.name) @@ plainto_tsquery($2)"
"") "")
(if message-query (if message-query

View file

@ -344,6 +344,13 @@
`("Revision " (samp ,commit-hash))) `("Revision " (samp ,commit-hash)))
(header-link (header-link
(string-append "/revision/" commit-hash))) (string-append "/revision/" commit-hash)))
(define lint-checker-options
(map (match-lambda
((name description network-dependent)
(cons (string-append name ": " description )
name)))
(lint-checkers-for-revision conn commit-hash)))
(if (any-invalid-query-parameters? query-parameters) (if (any-invalid-query-parameters? query-parameters)
(case (most-appropriate-mime-type (case (most-appropriate-mime-type
'(application/json text/html) '(application/json text/html)
@ -356,7 +363,7 @@
#:sxml (view-revision-lint-warnings commit-hash #:sxml (view-revision-lint-warnings commit-hash
query-parameters query-parameters
'() '()
'() lint-checker-options
#:path-base path-base #:path-base path-base
#:header-text header-text #:header-text header-text
#:header-link header-link)))) #:header-link header-link))))
@ -406,7 +413,7 @@
query-parameters query-parameters
lint-warnings lint-warnings
git-repositories git-repositories
'() lint-checker-options
#:path-base path-base #:path-base path-base
#:header-text header-text #:header-text header-text
#:header-link header-link) #:header-link header-link)

View file

@ -739,12 +739,11 @@
"Package query" query-parameters "Package query" query-parameters
#:help-text #:help-text
"Lint warnings where the package name matches the query.") "Lint warnings where the package name matches the query.")
;; TODO as there's not an easy way to find all the relevant lint checkers ,(form-horizontal-control
;; ,(form-horizontal-control "Linter" query-parameters
;; "Linter" query-parameters #:options lint-checker-options
;; #:options lint-checker-options #:help-text
;; #:help-text "Lint warnings for specific lint checkers.")
;; "Lint warnings for specific lint checkers.")
,(form-horizontal-control ,(form-horizontal-control
"Message query" query-parameters "Message query" query-parameters
#:help-text #:help-text