lint.scm 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
  3. ;;; Copyright © 2014, 2015 Eric Bavier <bavier@member.fsf.org>
  4. ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
  5. ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org>
  6. ;;; Copyright © 2016 Danny Milosavljevic <dannym+a@scratchpost.org>
  7. ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
  8. ;;; Copyright © 2017 Alex Kost <alezost@gmail.com>
  9. ;;; Copyright © 2017, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  10. ;;; Copyright © 2017, 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
  11. ;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
  12. ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
  13. ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
  14. ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
  15. ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
  16. ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
  17. ;;;
  18. ;;; This file is part of GNU Guix.
  19. ;;;
  20. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  21. ;;; under the terms of the GNU General Public License as published by
  22. ;;; the Free Software Foundation; either version 3 of the License, or (at
  23. ;;; your option) any later version.
  24. ;;;
  25. ;;; GNU Guix is distributed in the hope that it will be useful, but
  26. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  27. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. ;;; GNU General Public License for more details.
  29. ;;;
  30. ;;; You should have received a copy of the GNU General Public License
  31. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  32. (define-module (guix lint)
  33. #:use-module (guix store)
  34. #:autoload (guix base16) (bytevector->base16-string)
  35. #:use-module (guix base32)
  36. #:use-module (guix diagnostics)
  37. #:use-module (guix download)
  38. #:use-module (guix ftp-client)
  39. #:use-module (guix http-client)
  40. #:use-module (guix packages)
  41. #:use-module (guix i18n)
  42. #:use-module ((guix gexp)
  43. #:select (gexp? local-file? local-file-absolute-file-name
  44. gexp->approximate-sexp))
  45. #:use-module (guix licenses)
  46. #:use-module (guix records)
  47. #:use-module (guix grafts)
  48. #:use-module (guix upstream)
  49. #:use-module (guix utils)
  50. #:use-module (guix memoization)
  51. #:use-module (guix profiles)
  52. #:use-module (guix monads)
  53. #:use-module (guix scripts)
  54. #:use-module ((guix ui) #:select (texi->plain-text fill-paragraph))
  55. #:use-module (guix gnu-maintenance)
  56. #:use-module (guix cve)
  57. #:use-module ((guix swh) #:hide (origin?))
  58. #:autoload (guix git-download) (git-reference?
  59. git-reference-url git-reference-commit)
  60. #:use-module (guix import stackage)
  61. #:use-module (ice-9 match)
  62. #:use-module (ice-9 regex)
  63. #:use-module (ice-9 format)
  64. #:use-module (web client)
  65. #:use-module (web uri)
  66. #:use-module ((guix build download)
  67. #:select (maybe-expand-mirrors
  68. (open-connection-for-uri
  69. . guix:open-connection-for-uri)))
  70. #:use-module (web request)
  71. #:use-module (web response)
  72. #:autoload (gnutls) (error->string)
  73. #:use-module (srfi srfi-1)
  74. #:use-module (srfi srfi-6) ;Unicode string ports
  75. #:use-module (srfi srfi-9)
  76. #:use-module (srfi srfi-11)
  77. #:use-module (srfi srfi-26)
  78. #:use-module (srfi srfi-34)
  79. #:use-module (srfi srfi-35)
  80. #:use-module (ice-9 rdelim)
  81. #:export (check-description-style
  82. check-inputs-should-be-native
  83. check-inputs-should-not-be-an-input-at-all
  84. check-input-labels
  85. check-wrapper-inputs
  86. check-patch-file-names
  87. check-patch-headers
  88. check-synopsis-style
  89. check-derivation
  90. check-home-page
  91. check-name
  92. check-source
  93. check-source-file-name
  94. check-source-unstable-tarball
  95. check-optional-tests
  96. check-mirror-url
  97. check-github-url
  98. check-license
  99. check-vulnerabilities
  100. check-for-updates
  101. check-formatting
  102. check-archival
  103. check-profile-collisions
  104. check-haskell-stackage
  105. check-tests-true
  106. lint-warning
  107. lint-warning?
  108. lint-warning-package
  109. lint-warning-message
  110. lint-warning-message-text
  111. lint-warning-message-data
  112. lint-warning-location
  113. %local-checkers
  114. %network-dependent-checkers
  115. %all-checkers
  116. lint-checker
  117. lint-checker?
  118. lint-checker-name
  119. lint-checker-description
  120. lint-checker-check
  121. lint-checker-requires-store?))
  122. ;;;
  123. ;;; Warnings
  124. ;;;
  125. (define-record-type* <lint-warning>
  126. lint-warning make-lint-warning
  127. lint-warning?
  128. (package lint-warning-package)
  129. (message-text lint-warning-message-text)
  130. (message-data lint-warning-message-data
  131. (default '()))
  132. (location lint-warning-location
  133. (default #f)))
  134. (define (lint-warning-message warning)
  135. (apply format #f
  136. (G_ (lint-warning-message-text warning))
  137. (lint-warning-message-data warning)))
  138. (define (package-file package)
  139. (location-file
  140. (package-location package)))
  141. (define* (%make-warning package message-text
  142. #:optional (message-data '())
  143. #:key field location)
  144. (make-lint-warning
  145. package
  146. message-text
  147. message-data
  148. (or location
  149. (and field (package-field-location package field))
  150. (package-location package))))
  151. (define-syntax make-warning
  152. (syntax-rules (G_)
  153. ((_ package (G_ message) rest ...)
  154. (%make-warning package message rest ...))))
  155. ;;;
  156. ;;; Procedures for analysing Scheme code in package definitions
  157. ;;;
  158. (define* (find-procedure-body expression found
  159. #:key (not-found (const '())))
  160. "Try to find the body of the procedure defined inline by EXPRESSION.
  161. If it was found, call FOUND with its body. If it wasn't, call
  162. the thunk NOT-FOUND."
  163. (match expression
  164. (`(,(or 'let 'let*) . ,_)
  165. (find-procedure-body (car (last-pair expression)) found
  166. #:not-found not-found))
  167. (`(,(or 'lambda 'lambda*) ,_ . ,code)
  168. (found code))
  169. (_ (not-found))))
  170. (define* (report-bogus-phase-deltas package bogus-deltas)
  171. "Report a bogus invocation of ‘modify-phases’."
  172. (list (make-warning package
  173. ;; TRANSLATORS: 'modify-phases' is a Scheme syntax
  174. ;; and should not be translated.
  175. (G_ "incorrect call to ‘modify-phases’")
  176. #:field 'arguments)))
  177. (define* (find-phase-deltas package found
  178. #:key (not-found (const '()))
  179. (bogus
  180. (cut report-bogus-phase-deltas package <>)))
  181. "Try to find the clauses of the ‘modify-phases’ form in the phases
  182. specification of PACKAGE. If they were found, all FOUND with a list
  183. of the clauses. If they weren't (e.g. because ‘modify-phases’ wasn't
  184. used at all), call the thunk NOT-FOUND instead. If ‘modify-phases’
  185. was used, but the clauses don't form a list, call BOGUS with the
  186. not-a-list."
  187. (apply (lambda* (#:key phases #:allow-other-keys)
  188. (define phases/sexp
  189. (if (gexp? phases)
  190. (gexp->approximate-sexp phases)
  191. phases))
  192. (match phases/sexp
  193. (`(modify-phases ,_ . ,changes)
  194. ((if (list? changes) found bogus) changes))
  195. (_ (not-found))))
  196. (package-arguments package)))
  197. (define (report-bogus-phase-procedure package)
  198. "Report a syntactically-invalid phase clause."
  199. (list (make-warning package
  200. ;; TRANSLATORS: See ‘modify-phases’ in the manual.
  201. (G_ "invalid phase clause")
  202. #:field 'arguments)))
  203. (define* (find-phase-procedure package expression found
  204. #:key (not-found (const '()))
  205. (bogus (cut report-bogus-phase-procedure
  206. package)))
  207. "Try to find the procedure in the phase clause EXPRESSION. If it was
  208. found, call FOUND with the procedure expression. If EXPRESSION isn't
  209. actually a phase clause, call the thunk BOGUS. If the phase form doesn't
  210. have a procedure, call the thunk NOT-FOUND."
  211. (match expression
  212. (('add-after before after proc-expr)
  213. (found proc-expr))
  214. (('add-before after before proc-expr)
  215. (found proc-expr))
  216. (('replace _ proc-expr)
  217. (found proc-expr))
  218. (('delete _) (not-found))
  219. (_ (bogus))))
  220. ;;;
  221. ;;; Checkers
  222. ;;;
  223. (define-record-type* <lint-checker>
  224. lint-checker make-lint-checker
  225. lint-checker?
  226. ;; TODO: add a 'certainty' field that shows how confident we are in the
  227. ;; checker. Then allow users to only run checkers that have a certain
  228. ;; 'certainty' level.
  229. (name lint-checker-name)
  230. (description lint-checker-description)
  231. (check lint-checker-check)
  232. (requires-store? lint-checker-requires-store?
  233. (default #f)))
  234. (define (check-name package)
  235. "Check whether PACKAGE's name matches our guidelines."
  236. (let ((name (package-name package)))
  237. (cond
  238. ;; Currently checks only whether the name is too short.
  239. ((and (<= (string-length name) 1)
  240. (not (string=? name "r"))) ; common-sense exception
  241. (list
  242. (make-warning package
  243. (G_ "name should be longer than a single character")
  244. #:field 'name)))
  245. ((string-index name #\_)
  246. (list
  247. (make-warning package
  248. (G_ "name should use hyphens instead of underscores")
  249. #:field 'name)))
  250. (else '()))))
  251. (define (check-tests-true package)
  252. "Check whether PACKAGE explicitly requests to run tests, which is
  253. superfluous when building natively and incorrect when cross-compiling."
  254. (define (tests-explicitly-enabled?)
  255. (apply (lambda* (#:key tests? #:allow-other-keys)
  256. (eq? tests? #t))
  257. (package-arguments package)))
  258. (if (and (tests-explicitly-enabled?)
  259. ;; Some packages, e.g. gnutls, set #:tests?
  260. ;; differently depending on whether it is being
  261. ;; cross-compiled.
  262. (parameterize ((%current-target-system "aarch64-linux-gnu"))
  263. (tests-explicitly-enabled?)))
  264. (list (make-warning package
  265. ;; TRANSLATORS: #:tests? and #t are Scheme constants
  266. ;; and must not be translated.
  267. (G_ "#:tests? must not be explicitly set to #t")
  268. #:field 'arguments))
  269. '()))
  270. (define (properly-starts-sentence? s)
  271. (string-match "^[(\"'`[:upper:][:digit:]]" s))
  272. (define (starts-with-abbreviation? s)
  273. "Return #t if S starts with what looks like an abbreviation or acronym."
  274. (string-match "^[A-Z][A-Z0-9]+\\>" s))
  275. (define %quoted-identifier-rx
  276. ;; A quoted identifier, like 'this'.
  277. (make-regexp "['`][[:graph:]]+'"))
  278. (define (check-description-style package)
  279. ;; Emit a warning if stylistic issues are found in the description of PACKAGE.
  280. (define (check-not-empty description)
  281. (if (string-null? description)
  282. (list
  283. (make-warning package
  284. (G_ "description should not be empty")
  285. #:field 'description))
  286. '()))
  287. (define (check-texinfo-markup description)
  288. "Check that DESCRIPTION can be parsed as a Texinfo fragment. If the
  289. markup is valid return a plain-text version of DESCRIPTION, otherwise #f."
  290. (catch #t
  291. (lambda () (texi->plain-text description))
  292. (lambda (keys . args)
  293. (make-warning package
  294. (G_ "Texinfo markup in description is invalid")
  295. #:field 'description))))
  296. (define (check-trademarks description)
  297. "Check that DESCRIPTION does not contain '™' or '®' characters. See
  298. http://www.gnu.org/prep/standards/html_node/Trademarks.html."
  299. (match (string-index description (char-set #\™ #\®))
  300. ((and (? number?) index)
  301. (list
  302. (make-warning package
  303. (G_ "description should not contain ~
  304. trademark sign '~a' at ~d")
  305. (list (string-ref description index) index)
  306. #:field 'description)))
  307. (else '())))
  308. (define (check-quotes description)
  309. "Check whether DESCRIPTION contains single quotes and suggest @code."
  310. (if (regexp-exec %quoted-identifier-rx description)
  311. (list
  312. (make-warning package
  313. ;; TRANSLATORS: '@code' is Texinfo markup and must be kept
  314. ;; as is.
  315. (G_ "use @code or similar ornament instead of quotes")
  316. #:field 'description))
  317. '()))
  318. (define (check-proper-start description)
  319. (if (or (string-null? description)
  320. (properly-starts-sentence? description)
  321. (string-prefix-ci? (package-name package) description))
  322. '()
  323. (list
  324. (make-warning
  325. package
  326. (G_ "description should start with an upper-case letter or digit")
  327. #:field 'description))))
  328. (define (check-end-of-sentence-space description)
  329. "Check that an end-of-sentence period is followed by two spaces."
  330. (let ((infractions
  331. (reverse (fold-matches
  332. "\\. [A-Z]" description '()
  333. (lambda (m r)
  334. ;; Filter out matches of common abbreviations.
  335. (if (find (lambda (s)
  336. (string-suffix-ci? s (match:prefix m)))
  337. '("i.e" "e.g" "a.k.a" "resp"))
  338. r (cons (match:start m) r)))))))
  339. (if (null? infractions)
  340. '()
  341. (list
  342. (make-warning package
  343. (G_ "sentences in description should be followed ~
  344. by two spaces; possible infraction~p at ~{~a~^, ~}")
  345. (list (length infractions)
  346. infractions)
  347. #:field 'description)))))
  348. (define (check-no-leading-whitespace description)
  349. "Check that DESCRIPTION doesn't have trailing whitespace."
  350. (if (string-prefix? " " description)
  351. (list
  352. (make-warning package
  353. (G_ "description contains leading whitespace")
  354. #:field 'description))
  355. '()))
  356. (define (check-no-trailing-whitespace description)
  357. "Check that DESCRIPTION doesn't have trailing whitespace."
  358. (if (string-suffix? " " description)
  359. (list
  360. (make-warning package
  361. (G_ "description contains trailing whitespace")
  362. #:field 'description))
  363. '()))
  364. (let ((description (package-description package)))
  365. (if (string? description)
  366. (append
  367. (check-not-empty description)
  368. (check-quotes description)
  369. (check-trademarks description)
  370. ;; Use raw description for this because Texinfo rendering
  371. ;; automatically fixes end of sentence space.
  372. (check-end-of-sentence-space description)
  373. (check-no-leading-whitespace description)
  374. (check-no-trailing-whitespace description)
  375. (match (check-texinfo-markup description)
  376. ((and warning (? lint-warning?)) (list warning))
  377. (plain-description
  378. (check-proper-start plain-description))))
  379. (list
  380. (make-warning package
  381. (G_ "invalid description: ~s")
  382. (list description)
  383. #:field 'description)))))
  384. (define (package-input-intersection inputs-to-check input-names)
  385. "Return the intersection between INPUTS-TO-CHECK, the list of input tuples
  386. of a package, and INPUT-NAMES, a list of package specifications such as
  387. \"glib:bin\"."
  388. (match inputs-to-check
  389. (((labels packages . outputs) ...)
  390. (filter-map (lambda (package output)
  391. (and (package? package)
  392. (let ((input (string-append
  393. (package-name package)
  394. (if (> (length output) 0)
  395. (string-append ":" (car output))
  396. ""))))
  397. (and (member input input-names)
  398. input))))
  399. packages outputs))))
  400. (define (check-inputs-should-be-native package)
  401. ;; Emit a warning if some inputs of PACKAGE are likely to belong to its
  402. ;; native inputs.
  403. (let ((inputs (append (package-inputs package)
  404. (package-propagated-inputs package)))
  405. (input-names
  406. '("pkg-config"
  407. "autoconf"
  408. "automake"
  409. "bison"
  410. "cmake"
  411. "dejagnu"
  412. "desktop-file-utils"
  413. "doxygen"
  414. "extra-cmake-modules"
  415. "flex"
  416. "gettext"
  417. "glib:bin"
  418. "gobject-introspection"
  419. "googletest-source"
  420. "groff"
  421. "gtk-doc"
  422. "help2man"
  423. "intltool"
  424. "itstool"
  425. "libtool"
  426. "m4"
  427. "qttools"
  428. "yasm" "nasm" "fasm"
  429. "python-coverage" "python2-coverage"
  430. "python-cython" "python2-cython"
  431. "python-docutils" "python2-docutils"
  432. "python-mock" "python2-mock"
  433. "python-nose" "python2-nose"
  434. "python-pbr" "python2-pbr"
  435. "python-pytest" "python2-pytest"
  436. "python-pytest-cov" "python2-pytest-cov"
  437. "python-setuptools-scm" "python2-setuptools-scm"
  438. "python-sphinx" "python2-sphinx"
  439. "scdoc"
  440. "swig"
  441. "qmake"
  442. "qttools"
  443. "texinfo"
  444. "xorg-server-for-tests"
  445. "yelp-tools")))
  446. (map (lambda (input)
  447. (make-warning
  448. package
  449. (G_ "'~a' should probably be a native input")
  450. (list input)
  451. #:field 'inputs))
  452. (package-input-intersection inputs input-names))))
  453. (define (check-inputs-should-not-be-an-input-at-all package)
  454. ;; Emit a warning if some inputs of PACKAGE are likely to should not be
  455. ;; an input at all.
  456. (let ((input-names '("python-setuptools"
  457. "python2-setuptools"
  458. "python-pip"
  459. "python2-pip")))
  460. (map (lambda (input)
  461. (make-warning
  462. package
  463. (G_ "'~a' should probably not be an input at all")
  464. (list input)
  465. #:field 'inputs))
  466. (package-input-intersection (package-direct-inputs package)
  467. input-names))))
  468. (define (check-input-labels package)
  469. "Emit a warning for labels that differ from the corresponding package name."
  470. (define (check input-kind package-inputs)
  471. (define (warning label name)
  472. (make-warning package
  473. (G_ "label '~a' does not match package name '~a'")
  474. (list label name)
  475. #:field input-kind))
  476. (append-map (match-lambda
  477. (((? string? label) (? package? dependency))
  478. (if (string=? label (package-name dependency))
  479. '()
  480. (list (warning label (package-name dependency)))))
  481. (((? string? label) (? package? dependency) output)
  482. (let ((expected (string-append (package-name dependency)
  483. ":" output)))
  484. (if (string=? label expected)
  485. '()
  486. (list (warning label expected)))))
  487. (_
  488. '()))
  489. (package-inputs package)))
  490. (append-map (match-lambda
  491. ((kind proc)
  492. (check kind proc)))
  493. `((native-inputs ,package-native-inputs)
  494. (inputs ,package-inputs)
  495. (propagated-inputs ,package-propagated-inputs))))
  496. (define (report-wrap-program-error package wrapper-name)
  497. "Warn that \"bash-minimal\" is missing from 'inputs', while WRAPPER-NAME
  498. requires it."
  499. (make-warning package
  500. (G_ "\"bash-minimal\" should be in 'inputs' when '~a' is used")
  501. (list wrapper-name)))
  502. (define (check-wrapper-inputs package)
  503. "Emit a warning if PACKAGE uses 'wrap-program' or similar, but \"bash\"
  504. or \"bash-minimal\" is not in its inputs. 'wrap-script' is not supported."
  505. (define input-names '("bash" "bash-minimal"))
  506. (define has-bash-input?
  507. (pair? (package-input-intersection (package-inputs package)
  508. input-names)))
  509. (define (check-procedure-body body)
  510. (match body
  511. ;; Explicitely setting an interpreter is acceptable,
  512. ;; #:sh support is added on 'core-updates'.
  513. ;; TODO(core-updates): remove mention of core-updates.
  514. (('wrap-program _ '#:sh . _) '())
  515. (('wrap-program _ . _)
  516. (list (report-wrap-program-error package 'wrap-program)))
  517. ;; Wrapper of 'wrap-program' for Qt programs.
  518. ;; TODO #:sh is not yet supported but probably will be.
  519. (('wrap-qt-program _ '#:sh . _) '())
  520. (('wrap-qt-program _ . _)
  521. (list (report-wrap-program-error package 'wrap-qt-program)))
  522. ((x . y)
  523. (append (check-procedure-body x) (check-procedure-body y)))
  524. (_ '())))
  525. (define (check-phase-procedure expression)
  526. (find-procedure-body expression check-procedure-body))
  527. (define (check-delta expression)
  528. (find-phase-procedure package expression check-phase-procedure))
  529. (define (check-deltas deltas)
  530. (append-map check-delta deltas))
  531. (if has-bash-input?
  532. ;; "bash" (or "bash-minimal") is in 'inputs', so everything seems ok.
  533. '()
  534. ;; "bash" is not in 'inputs'. Verify 'wrap-program' and friends
  535. ;; are unused
  536. (find-phase-deltas package check-deltas)))
  537. (define (package-name-regexp package)
  538. "Return a regexp that matches PACKAGE's name as a word at the beginning of a
  539. line."
  540. (make-regexp (string-append "^" (regexp-quote (package-name package))
  541. "\\>")
  542. regexp/icase))
  543. (define (check-synopsis-style package)
  544. ;; Emit a warning if stylistic issues are found in the synopsis of PACKAGE.
  545. (define (check-final-period synopsis)
  546. ;; Synopsis should not end with a period, except for some special cases.
  547. (if (and (string-suffix? "." synopsis)
  548. (not (string-suffix? "etc." synopsis)))
  549. (list
  550. (make-warning package
  551. (G_ "no period allowed at the end of the synopsis")
  552. #:field 'synopsis))
  553. '()))
  554. (define check-start-article
  555. ;; Skip this check for GNU packages, as suggested by Karl Berry's reply to
  556. ;; <http://lists.gnu.org/archive/html/bug-womb/2014-11/msg00000.html>.
  557. (if (false-if-exception (gnu-package? package))
  558. (const '())
  559. (lambda (synopsis)
  560. (if (or (string-prefix-ci? "A " synopsis)
  561. (string-prefix-ci? "An " synopsis))
  562. (list
  563. (make-warning package
  564. (G_ "no article allowed at the beginning of \
  565. the synopsis")
  566. #:field 'synopsis))
  567. '()))))
  568. (define (check-synopsis-length synopsis)
  569. (if (>= (string-length synopsis) 80)
  570. (list
  571. (make-warning package
  572. (G_ "synopsis should be less than 80 characters long")
  573. #:field 'synopsis))
  574. '()))
  575. (define (check-proper-start synopsis)
  576. (if (properly-starts-sentence? synopsis)
  577. '()
  578. (list
  579. (make-warning package
  580. (G_ "synopsis should start with an upper-case letter or digit")
  581. #:field 'synopsis))))
  582. (define (check-start-with-package-name synopsis)
  583. (if (and (regexp-exec (package-name-regexp package) synopsis)
  584. (not (starts-with-abbreviation? synopsis)))
  585. (list
  586. (make-warning package
  587. (G_ "synopsis should not start with the package name")
  588. #:field 'synopsis))
  589. '()))
  590. (define (check-texinfo-markup synopsis)
  591. "Check that SYNOPSIS can be parsed as a Texinfo fragment. If the
  592. markup is valid return a plain-text version of SYNOPSIS, otherwise #f."
  593. (catch #t
  594. (lambda ()
  595. (texi->plain-text synopsis)
  596. '())
  597. (lambda (keys . args)
  598. (list
  599. (make-warning package
  600. (G_ "Texinfo markup in synopsis is invalid")
  601. #:field 'synopsis)))))
  602. (define (check-no-trailing-whitespace synopsis)
  603. "Check that SYNOPSIS doesn't have trailing whitespace."
  604. (if (string-suffix? " " synopsis)
  605. (list
  606. (make-warning package
  607. (G_ "synopsis contains trailing whitespace")
  608. #:field 'synopsis))
  609. '()))
  610. (define checks
  611. (list check-proper-start
  612. check-final-period
  613. check-start-article
  614. check-start-with-package-name
  615. check-synopsis-length
  616. check-texinfo-markup
  617. check-no-trailing-whitespace))
  618. (match (package-synopsis package)
  619. (""
  620. (list
  621. (make-warning package
  622. (G_ "synopsis should not be empty")
  623. #:field 'synopsis)))
  624. ((? string? synopsis)
  625. (append-map
  626. (lambda (proc)
  627. (proc synopsis))
  628. checks))
  629. (invalid
  630. (list
  631. (make-warning package
  632. (G_ "invalid synopsis: ~s")
  633. (list invalid)
  634. #:field 'synopsis)))))
  635. (define* (probe-uri uri #:key timeout)
  636. "Probe URI, a URI object, and return two values: a symbol denoting the
  637. probing status, such as 'http-response' when we managed to get an HTTP
  638. response from URI, and additional details, such as the actual HTTP response.
  639. TIMEOUT is the maximum number of seconds (possibly an inexact number) to wait
  640. for connections to complete; when TIMEOUT is #f, wait as long as needed."
  641. (define headers
  642. '((User-Agent . "GNU Guile")
  643. (Accept . "*/*")))
  644. (let loop ((uri uri)
  645. (visited '()))
  646. (match (uri-scheme uri)
  647. ((or 'http 'https)
  648. (catch #t
  649. (lambda ()
  650. (let ((port (guix:open-connection-for-uri
  651. uri #:timeout timeout))
  652. (request (build-request uri #:headers headers)))
  653. (define response
  654. (dynamic-wind
  655. (const #f)
  656. (lambda ()
  657. (write-request request port)
  658. (force-output port)
  659. (read-response port))
  660. (lambda ()
  661. (close-port port))))
  662. (case (response-code response)
  663. ((302 ; found (redirection)
  664. 303 ; see other
  665. 307 ; temporary redirection
  666. 308) ; permanent redirection
  667. (let ((location (response-location response)))
  668. (if (or (not location) (member location visited))
  669. (values 'http-response response)
  670. (loop location (cons location visited))))) ;follow the redirect
  671. ((301) ; moved permanently
  672. (let ((location (response-location response)))
  673. ;; Return RESPONSE, unless the final response as we follow
  674. ;; redirects is not 200.
  675. (if location
  676. (let-values (((status response2)
  677. (loop location (cons location visited))))
  678. (case status
  679. ((http-response)
  680. (values 'http-response
  681. (if (= 200 (response-code response2))
  682. response
  683. response2)))
  684. (else
  685. (values status response2))))
  686. (values 'http-response response)))) ;invalid redirect
  687. (else
  688. (values 'http-response response)))))
  689. (lambda (key . args)
  690. (case key
  691. ((bad-header bad-header-component)
  692. ;; This can happen if the server returns an invalid HTTP header,
  693. ;; as is the case with the 'Date' header at sqlite.org.
  694. (values 'invalid-http-response #f))
  695. ((getaddrinfo-error system-error
  696. gnutls-error tls-certificate-error)
  697. (values key args))
  698. (else
  699. (apply throw key args))))))
  700. ('ftp
  701. (catch #t
  702. (lambda ()
  703. (let ((conn (ftp-open (uri-host uri) #:timeout timeout)))
  704. (define response
  705. (dynamic-wind
  706. (const #f)
  707. (lambda ()
  708. (ftp-chdir conn (dirname (uri-path uri)))
  709. (ftp-size conn (basename (uri-path uri))))
  710. (lambda ()
  711. (ftp-close conn))))
  712. (values 'ftp-response '(ok))))
  713. (lambda (key . args)
  714. (case key
  715. ((ftp-error)
  716. (values 'ftp-response `(error ,@args)))
  717. ((getaddrinfo-error system-error gnutls-error)
  718. (values key args))
  719. (else
  720. (apply throw key args))))))
  721. (_
  722. (values 'unknown-protocol #f)))))
  723. (define (call-with-networking-fail-safe message error-value proc)
  724. "Call PROC catching any network-related errors. Upon a networking error,
  725. display a message including MESSAGE and return ERROR-VALUE."
  726. (guard (c ((http-get-error? c)
  727. (warning (G_ "~a: HTTP GET error for ~a: ~a (~s)~%")
  728. message
  729. (uri->string (http-get-error-uri c))
  730. (http-get-error-code c)
  731. (http-get-error-reason c))
  732. error-value))
  733. (catch #t
  734. proc
  735. (match-lambda*
  736. (('getaddrinfo-error errcode)
  737. (warning (G_ "~a: host lookup failure: ~a~%")
  738. message
  739. (gai-strerror errcode))
  740. error-value)
  741. (('tls-certificate-error args ...)
  742. (warning (G_ "~a: TLS certificate error: ~a")
  743. message
  744. (tls-certificate-error-string args))
  745. error-value)
  746. (('gnutls-error error function _ ...)
  747. (warning (G_ "~a: TLS error in '~a': ~a~%")
  748. message
  749. function (error->string error))
  750. error-value)
  751. ((and ('system-error _ ...) args)
  752. (let ((errno (system-error-errno args)))
  753. (if (member errno (list ECONNRESET ECONNABORTED ECONNREFUSED))
  754. (let ((details (call-with-output-string
  755. (lambda (port)
  756. (print-exception port #f (car args)
  757. (cdr args))))))
  758. (warning (G_ "~a: ~a~%") message details)
  759. error-value)
  760. (apply throw args))))
  761. (args
  762. (apply throw args))))))
  763. (define-syntax-rule (with-networking-fail-safe message error-value exp ...)
  764. (call-with-networking-fail-safe message error-value
  765. (lambda () exp ...)))
  766. (define (tls-certificate-error-string args)
  767. "Return a string explaining the 'tls-certificate-error' arguments ARGS."
  768. (call-with-output-string
  769. (lambda (port)
  770. (print-exception port #f
  771. 'tls-certificate-error args))))
  772. (define (validate-uri uri package field)
  773. "Return #t if the given URI can be reached, otherwise return a warning for
  774. PACKAGE mentioning the FIELD."
  775. (let-values (((status argument)
  776. (probe-uri uri #:timeout 3))) ;wait at most 3 seconds
  777. (case status
  778. ((http-response)
  779. (cond ((= 200 (response-code argument))
  780. (match (response-content-length argument)
  781. ((? number? length)
  782. ;; As of July 2016, SourceForge returns 200 (instead of 404)
  783. ;; with a small HTML page upon failure. Attempt to detect
  784. ;; such malicious behavior.
  785. (or (> length 1000)
  786. (make-warning package
  787. (G_ "URI ~a returned \
  788. suspiciously small file (~a bytes)")
  789. (list (uri->string uri)
  790. length)
  791. #:field field)))
  792. (_ #t)))
  793. ((= 301 (response-code argument))
  794. (if (response-location argument)
  795. (make-warning package
  796. (G_ "permanent redirect from ~a to ~a")
  797. (list (uri->string uri)
  798. (uri->string
  799. (response-location argument)))
  800. #:field field)
  801. (make-warning package
  802. (G_ "invalid permanent redirect \
  803. from ~a")
  804. (list (uri->string uri))
  805. #:field field)))
  806. (else
  807. (make-warning package
  808. (G_ "URI ~a not reachable: ~a (~s)")
  809. (list (uri->string uri)
  810. (response-code argument)
  811. (response-reason-phrase argument))
  812. #:field field))))
  813. ((ftp-response)
  814. (match argument
  815. (('ok) #t)
  816. (('error port command code message)
  817. (make-warning package
  818. (G_ "URI ~a not reachable: ~a (~s)")
  819. (list (uri->string uri)
  820. code (string-trim-both message))
  821. #:field field))))
  822. ((getaddrinfo-error)
  823. (make-warning package
  824. (G_ "URI ~a domain not found: ~a")
  825. (list (uri->string uri)
  826. (gai-strerror (car argument)))
  827. #:field field))
  828. ((system-error)
  829. (make-warning package
  830. (G_ "URI ~a unreachable: ~a")
  831. (list (uri->string uri)
  832. (strerror
  833. (system-error-errno
  834. (cons status argument))))
  835. #:field field))
  836. ((tls-certificate-error)
  837. (make-warning package
  838. (G_ "TLS certificate error: ~a")
  839. (list (tls-certificate-error-string argument))
  840. #:field field))
  841. ((invalid-http-response gnutls-error)
  842. ;; Probably a misbehaving server; ignore.
  843. #f)
  844. ((unknown-protocol) ;nothing we can do
  845. #f)
  846. (else
  847. (error "internal linter error" status)))))
  848. (define (check-home-page package)
  849. "Emit a warning if PACKAGE has an invalid 'home-page' field, or if that
  850. 'home-page' is not reachable."
  851. (let ((uri (and=> (package-home-page package) string->uri)))
  852. (cond
  853. ((uri? uri)
  854. (match (validate-uri uri package 'home-page)
  855. ((and (? lint-warning? warning) warning)
  856. (list warning))
  857. (_ '())))
  858. ((not (package-home-page package))
  859. (if (or (string-contains (package-name package) "bootstrap")
  860. (string=? (package-name package) "ld-wrapper"))
  861. '()
  862. (list
  863. (make-warning package
  864. (G_ "invalid value for home page")
  865. #:field 'home-page))))
  866. (else
  867. (list
  868. (make-warning package
  869. (G_ "invalid home page URL: ~s")
  870. (list (package-home-page package))
  871. #:field 'home-page))))))
  872. (define %distro-directory
  873. (mlambda ()
  874. (dirname (search-path %load-path "gnu.scm"))))
  875. (define (check-patch-file-names package)
  876. "Emit a warning if the patches requires by PACKAGE are badly named or if the
  877. patch could not be found."
  878. (guard (c ((formatted-message? c) ;raised by 'search-patch'
  879. (list (%make-warning package
  880. (formatted-message-string c)
  881. (formatted-message-arguments c)
  882. #:field 'source))))
  883. (define patches
  884. (match (package-source package)
  885. ((? origin? origin) (origin-patches origin))
  886. (_ '())))
  887. (define (starts-with-package-name? file-name)
  888. (and=> (string-contains file-name (package-name package))
  889. zero?))
  890. (append
  891. (if (every (match-lambda ;patch starts with package name?
  892. ((? string? patch)
  893. (starts-with-package-name? (basename patch)))
  894. ((? origin? patch)
  895. (starts-with-package-name? (origin-actual-file-name patch)))
  896. (_ #f)) ;must be some other file-like object
  897. patches)
  898. '()
  899. (list
  900. (make-warning
  901. package
  902. (G_ "file names of patches should start with the package name")
  903. #:field 'patch-file-names)))
  904. ;; Check whether we're reaching tar's maximum file name length.
  905. (let ((prefix (string-length (%distro-directory)))
  906. (margin (string-length "guix-2.0.0rc3-10000-1234567890/"))
  907. (max 99))
  908. (filter-map (match-lambda
  909. ((? string? patch)
  910. (if (> (+ margin (if (string-prefix? (%distro-directory)
  911. patch)
  912. (- (string-length patch) prefix)
  913. (string-length patch)))
  914. max)
  915. (make-warning
  916. package
  917. (G_ "~a: file name is too long")
  918. (list (basename patch))
  919. #:field 'patch-file-names)
  920. #f))
  921. (_ #f))
  922. patches)))))
  923. (define (check-patch-headers package)
  924. "Check that PACKAGE's patches start with a comment. Return a list of
  925. warnings."
  926. (define (blank? str)
  927. (string-every char-set:blank str))
  928. (define (patch-header-warnings patch)
  929. (call-with-input-file patch
  930. (lambda (port)
  931. ;; Read from PORT until a non-blank line is found or EOF is reached.
  932. (let loop ()
  933. (let ((line (read-line port)))
  934. (cond ((eof-object? line)
  935. (list (make-warning package
  936. (G_ "~a: empty patch")
  937. (list (basename patch))
  938. #:field 'source)))
  939. ((blank? line)
  940. (loop))
  941. ((or (string-prefix? "--- " line)
  942. (string-prefix? "+++ " line)
  943. (string-prefix? "diff --git " line))
  944. (list (make-warning package
  945. (G_ "~a: patch lacks comment and \
  946. upstream status")
  947. (list (basename patch))
  948. #:field 'source)))
  949. (else
  950. '())))))))
  951. (guard (c ((formatted-message? c) ;raised by 'search-patch'
  952. (list (%make-warning package
  953. (formatted-message-string c)
  954. (formatted-message-arguments c)
  955. #:field 'source))))
  956. (let ((patches (if (origin? (package-source package))
  957. (origin-patches (package-source package))
  958. '())))
  959. (append-map (lambda (patch)
  960. ;; Dismiss PATCH if it's an origin or similar.
  961. (cond ((string? patch)
  962. (patch-header-warnings patch))
  963. ((local-file? patch)
  964. (patch-header-warnings
  965. (local-file-absolute-file-name patch)))
  966. (else
  967. '())))
  968. patches))))
  969. (define (escape-quotes str)
  970. "Replace any quote character in STR by an escaped quote character."
  971. (list->string
  972. (string-fold-right (lambda (chr result)
  973. (match chr
  974. (#\" (cons* #\\ #\"result))
  975. (_ (cons chr result))))
  976. '()
  977. str)))
  978. (define official-gnu-packages*
  979. (mlambda ()
  980. "A memoizing version of 'official-gnu-packages' that returns the empty
  981. list when something goes wrong, such as a networking issue."
  982. (let ((gnus (false-if-exception (official-gnu-packages))))
  983. (or gnus '()))))
  984. (define (check-gnu-synopsis+description package)
  985. "Make sure that, if PACKAGE is a GNU package, it uses the synopsis and
  986. descriptions maintained upstream."
  987. (match (find (lambda (descriptor)
  988. (string=? (gnu-package-name descriptor)
  989. (package-name package)))
  990. (official-gnu-packages*))
  991. (#f ;not a GNU package, so nothing to do
  992. '())
  993. (descriptor ;a genuine GNU package
  994. (append
  995. (let ((upstream (gnu-package-doc-summary descriptor))
  996. (downstream (package-synopsis package)))
  997. (if (and upstream
  998. (or (not (string? downstream))
  999. (not (string=? upstream downstream))))
  1000. (list
  1001. (make-warning package
  1002. (G_ "proposed synopsis: ~s~%")
  1003. (list upstream)
  1004. #:field 'synopsis))
  1005. '()))
  1006. (let ((upstream (gnu-package-doc-description descriptor))
  1007. (downstream (package-description package)))
  1008. (if (and upstream
  1009. (or (not (string? downstream))
  1010. (not (string=? (fill-paragraph upstream 100)
  1011. (fill-paragraph downstream 100)))))
  1012. (list
  1013. (make-warning
  1014. package
  1015. (G_ "proposed description:~% \"~a\"~%")
  1016. (list (fill-paragraph (escape-quotes upstream) 77 7))
  1017. #:field 'description))
  1018. '()))))))
  1019. (define (origin-uris origin)
  1020. "Return the list of URIs (strings) for ORIGIN."
  1021. (match (origin-uri origin)
  1022. ((? string? uri)
  1023. (list uri))
  1024. ((uris ...)
  1025. uris)))
  1026. (define (check-source package)
  1027. "Emit a warning if PACKAGE has an invalid 'source' field, or if that
  1028. 'source' is not reachable."
  1029. (define (warnings-for-uris uris)
  1030. (let loop ((uris uris)
  1031. (warnings '()))
  1032. (match uris
  1033. (()
  1034. (reverse warnings))
  1035. ((uri rest ...)
  1036. (match (validate-uri uri package 'source)
  1037. (#t
  1038. ;; We found a working URL, so stop right away.
  1039. '())
  1040. (#f
  1041. ;; Unsupported URL or other error, skip.
  1042. (loop rest warnings))
  1043. ((? lint-warning? warning)
  1044. (loop rest (cons warning warnings))))))))
  1045. (let ((origin (package-source package)))
  1046. (if (origin? origin)
  1047. (cond
  1048. ((eq? (origin-method origin) url-fetch)
  1049. (let* ((uris (append-map (cut maybe-expand-mirrors <> %mirrors)
  1050. (map string->uri (origin-uris origin))))
  1051. (warnings (warnings-for-uris uris)))
  1052. ;; Just make sure that at least one of the URIs is valid.
  1053. (if (= (length uris) (length warnings))
  1054. ;; When everything fails, report all of WARNINGS, otherwise don't
  1055. ;; report anything.
  1056. ;;
  1057. ;; XXX: Ideally we'd still allow warnings to be raised if *some*
  1058. ;; URIs are unreachable, but distinguish that from the error case
  1059. ;; where *all* the URIs are unreachable.
  1060. (cons*
  1061. (make-warning package
  1062. (G_ "all the source URIs are unreachable:")
  1063. #:field 'source)
  1064. warnings)
  1065. '())))
  1066. ((git-reference? (origin-uri origin))
  1067. (warnings-for-uris
  1068. (list (string->uri (git-reference-url (origin-uri origin))))))
  1069. (else
  1070. '()))
  1071. '())))
  1072. (define (check-source-file-name package)
  1073. "Emit a warning if PACKAGE's origin has no meaningful file name."
  1074. (define (origin-file-name-valid? origin)
  1075. ;; Return #f if the source file name contains only a version or is #f;
  1076. ;; indicates that the origin needs a 'file-name' field.
  1077. (let ((file-name (origin-actual-file-name origin))
  1078. (version (package-version package)))
  1079. (and file-name
  1080. ;; Common in many projects is for the filename to start
  1081. ;; with a "v" followed by the version,
  1082. ;; e.g. "v3.2.0.tar.gz".
  1083. (not (string-match (string-append "^v?" version) file-name)))))
  1084. (let ((origin (package-source package)))
  1085. (if (or (not (origin? origin)) (origin-file-name-valid? origin))
  1086. '()
  1087. (list
  1088. (make-warning package
  1089. (G_ "the source file name should contain the package name")
  1090. #:field 'source)))))
  1091. (define (check-source-unstable-tarball package)
  1092. "Emit a warning if PACKAGE's source is an autogenerated tarball."
  1093. (define (check-source-uri uri)
  1094. (if (and (string=? (uri-host (string->uri uri)) "github.com")
  1095. (match (split-and-decode-uri-path
  1096. (uri-path (string->uri uri)))
  1097. ((_ _ "archive" _ ...) #t)
  1098. (_ #f)))
  1099. (make-warning package
  1100. (G_ "the source URI should not be an autogenerated tarball")
  1101. #:field 'source)
  1102. #f))
  1103. (let ((origin (package-source package)))
  1104. (if (and (origin? origin)
  1105. (eqv? (origin-method origin) url-fetch))
  1106. (filter-map check-source-uri
  1107. (origin-uris origin))
  1108. '())))
  1109. (define (check-mirror-url package)
  1110. "Check whether PACKAGE uses source URLs that should be 'mirror://'."
  1111. (define (check-mirror-uri uri) ;XXX: could be optimized
  1112. (let loop ((mirrors %mirrors))
  1113. (match mirrors
  1114. (()
  1115. #f)
  1116. (((mirror-id mirror-urls ...) rest ...)
  1117. (match (find (cut string-prefix? <> uri) mirror-urls)
  1118. (#f
  1119. (loop rest))
  1120. (prefix
  1121. (make-warning package
  1122. (G_ "URL should be \
  1123. 'mirror://~a/~a'")
  1124. (list mirror-id
  1125. (string-drop uri (string-length prefix)))
  1126. #:field 'source)))))))
  1127. (let ((origin (package-source package)))
  1128. (if (and (origin? origin)
  1129. (eqv? (origin-method origin) url-fetch))
  1130. (let ((uris (origin-uris origin)))
  1131. (filter-map check-mirror-uri uris))
  1132. '())))
  1133. (define* (check-github-url package #:key (timeout 3))
  1134. "Check whether PACKAGE uses source URLs that redirect to GitHub."
  1135. (define (follow-redirect url)
  1136. (let* ((uri (string->uri url))
  1137. (port (guix:open-connection-for-uri uri #:timeout timeout))
  1138. (response (http-head uri #:port port)))
  1139. (close-port port)
  1140. (case (response-code response)
  1141. ((301 302)
  1142. (uri->string (assoc-ref (response-headers response) 'location)))
  1143. (else #f))))
  1144. (define (follow-redirects-to-github uri)
  1145. (cond
  1146. ((string-prefix? "https://github.com/" uri) uri)
  1147. ((string-prefix? "http" uri)
  1148. (and=> (follow-redirect uri) follow-redirects-to-github))
  1149. ;; Do not attempt to follow redirects on URIs other than http and https
  1150. ;; (such as mirror, file)
  1151. (else #f)))
  1152. (let ((origin (package-source package)))
  1153. (if (and (origin? origin)
  1154. (eqv? (origin-method origin) url-fetch))
  1155. (filter-map
  1156. (lambda (uri)
  1157. (and=> (with-networking-fail-safe
  1158. (format #f (G_ "while accessing '~a'") uri)
  1159. #f
  1160. (follow-redirects-to-github uri))
  1161. (lambda (github-uri)
  1162. (and (not (string=? github-uri uri))
  1163. (make-warning
  1164. package
  1165. (G_ "URL should be '~a'")
  1166. (list github-uri)
  1167. #:field 'source)))))
  1168. (origin-uris origin))
  1169. '())))
  1170. ;; Guile 3.0.0 does not export this predicate.
  1171. (define exception-with-kind-and-args?
  1172. (exception-predicate &exception-with-kind-and-args))
  1173. (define (check-optional-tests package)
  1174. "Emit a warning if the test suite is run unconditionally."
  1175. (define (sexp-contains-atom? sexp atom)
  1176. "Test if SEXP contains ATOM."
  1177. (if (pair? sexp)
  1178. (or (sexp-contains-atom? (car sexp) atom)
  1179. (sexp-contains-atom? (cdr sexp) atom))
  1180. (eq? sexp atom)))
  1181. (define (sexp-uses-tests?? sexp)
  1182. "Test if SEXP contains the symbol 'tests?'."
  1183. (sexp-contains-atom? sexp 'tests?))
  1184. (define (check-procedure-body code)
  1185. (if (sexp-uses-tests?? code)
  1186. '()
  1187. (list (make-warning package
  1188. ;; TRANSLATORS: check and #:tests? are a
  1189. ;; Scheme symbol and keyword respectively
  1190. ;; and should not be translated.
  1191. (G_ "the 'check' phase should respect #:tests?")
  1192. #:field 'arguments))))
  1193. (define (check-check-procedure expression)
  1194. (find-procedure-body expression check-procedure-body))
  1195. (define (check-phases-delta delta)
  1196. (match delta
  1197. (`(replace 'check ,expression)
  1198. (check-check-procedure expression))
  1199. (_ '())))
  1200. (define (check-phases-deltas deltas)
  1201. (append-map check-phases-delta deltas))
  1202. (find-phase-deltas package check-phases-deltas))
  1203. (define* (check-derivation package #:key store)
  1204. "Emit a warning if we fail to compile PACKAGE to a derivation."
  1205. (define (try store system)
  1206. (guard (c ((store-protocol-error? c)
  1207. (make-warning package
  1208. (G_ "failed to create ~a derivation: ~a")
  1209. (list system
  1210. (store-protocol-error-message c))))
  1211. ((exception-with-kind-and-args? c)
  1212. (make-warning package
  1213. (G_ "failed to create ~a derivation: ~s")
  1214. (list system
  1215. (cons (exception-kind c)
  1216. (exception-args c)))))
  1217. ((message-condition? c)
  1218. (make-warning package
  1219. (G_ "failed to create ~a derivation: ~a")
  1220. (list system
  1221. (condition-message c))))
  1222. ((formatted-message? c)
  1223. (let ((str (apply format #f
  1224. (formatted-message-string c)
  1225. (formatted-message-arguments c))))
  1226. (make-warning package
  1227. (G_ "failed to create ~a derivation: ~a")
  1228. (list system str)))))
  1229. (parameterize ((%graft? #f))
  1230. (package-derivation store package system #:graft? #f)
  1231. ;; If there's a replacement, make sure we can compute its
  1232. ;; derivation.
  1233. (match (package-replacement package)
  1234. (#f #t)
  1235. (replacement
  1236. (package-derivation store replacement system
  1237. #:graft? #f))))))
  1238. (define (check-with-store store)
  1239. (filter lint-warning?
  1240. (map (cut try store <>) (package-supported-systems package))))
  1241. ;; For backwards compatability, don't rely on store being set
  1242. (or (and=> store check-with-store)
  1243. (with-store store
  1244. (check-with-store store))))
  1245. (define* (check-profile-collisions package #:key store)
  1246. "Check for collisions that would occur when installing PACKAGE as a result
  1247. of the propagated inputs it pulls in."
  1248. (define (do-check store)
  1249. (guard (c ((profile-collision-error? c)
  1250. (let ((first (profile-collision-error-entry c))
  1251. (second (profile-collision-error-conflict c)))
  1252. (define format
  1253. (if (string=? (manifest-entry-version first)
  1254. (manifest-entry-version second))
  1255. manifest-entry-item
  1256. (lambda (entry)
  1257. (string-append (manifest-entry-name entry) "@"
  1258. (manifest-entry-version entry)))))
  1259. (list (make-warning package
  1260. (G_ "propagated inputs ~a and ~a collide")
  1261. (list (format first)
  1262. (format second)))))))
  1263. ;; Disable grafts to avoid building PACKAGE and its dependencies.
  1264. (parameterize ((%graft? #f))
  1265. (run-with-store store
  1266. (mbegin %store-monad
  1267. (check-for-collisions (packages->manifest (list package))
  1268. (%current-system))
  1269. (return '()))))))
  1270. (if store
  1271. (do-check store)
  1272. (with-store store
  1273. (do-check store))))
  1274. (define (check-license package)
  1275. "Warn about type errors of the 'license' field of PACKAGE."
  1276. (match (package-license package)
  1277. ((or (? license?)
  1278. ((? license?) ...))
  1279. '())
  1280. (x
  1281. (list
  1282. (make-warning package (G_ "invalid license field")
  1283. #:field 'license)))))
  1284. (define (current-vulnerabilities*)
  1285. "Like 'current-vulnerabilities', but return the empty list upon networking
  1286. or HTTP errors. This allows network-less operation and makes problems with
  1287. the NIST server non-fatal."
  1288. (with-networking-fail-safe (G_ "while retrieving CVE vulnerabilities")
  1289. '()
  1290. (current-vulnerabilities #:timeout 4)))
  1291. (define package-vulnerabilities
  1292. (let ((lookup (delay (vulnerabilities->lookup-proc
  1293. (current-vulnerabilities*)))))
  1294. (lambda (package)
  1295. "Return a list of vulnerabilities affecting PACKAGE."
  1296. ;; First we retrieve the Common Platform Enumeration (CPE) name and
  1297. ;; version for PACKAGE, then we can pass them to LOOKUP.
  1298. (let ((name (or (assoc-ref (package-properties package)
  1299. 'cpe-name)
  1300. (package-name package)))
  1301. (version (or (assoc-ref (package-properties package)
  1302. 'cpe-version)
  1303. (package-version package))))
  1304. ((force lookup) name version)))))
  1305. (define* (check-vulnerabilities package
  1306. #:optional (package-vulnerabilities
  1307. package-vulnerabilities))
  1308. "Check for known vulnerabilities for PACKAGE. Obtain the list of
  1309. vulnerability records for PACKAGE by calling PACKAGE-VULNERABILITIES."
  1310. (let ((package (or (package-replacement package) package)))
  1311. (match (package-vulnerabilities package)
  1312. (()
  1313. '())
  1314. ((vulnerabilities ...)
  1315. (let* ((patched (package-patched-vulnerabilities package))
  1316. (known-safe (or (assq-ref (package-properties package)
  1317. 'lint-hidden-cve)
  1318. '()))
  1319. (unpatched (remove (lambda (vuln)
  1320. (let ((id (vulnerability-id vuln)))
  1321. (or (member id patched)
  1322. (member id known-safe))))
  1323. vulnerabilities)))
  1324. (if (null? unpatched)
  1325. '()
  1326. (list
  1327. (make-warning
  1328. package
  1329. (G_ "probably vulnerable to ~a")
  1330. (list (string-join (map vulnerability-id unpatched)
  1331. ", "))))))))))
  1332. (define (check-for-updates package)
  1333. "Check if there is an update available for PACKAGE."
  1334. (match (lookup-updater package)
  1335. (#f
  1336. (list (make-warning package (G_ "no updater for ~a")
  1337. (list (package-name package))
  1338. #:field 'source)))
  1339. ((? upstream-updater? updater)
  1340. (match (with-networking-fail-safe
  1341. (format #f (G_ "while retrieving upstream info for '~a'")
  1342. (package-name package))
  1343. #f
  1344. (package-latest-release package))
  1345. ((? upstream-source? source)
  1346. (if (version>? (upstream-source-version source)
  1347. (package-version package))
  1348. (list
  1349. (make-warning package
  1350. (G_ "can be upgraded to ~a")
  1351. (list (upstream-source-version source))
  1352. #:field 'version))
  1353. '()))
  1354. (#f ;cannot find upstream release
  1355. (list (make-warning package
  1356. (G_ "updater '~a' failed to find \
  1357. upstream releases")
  1358. (list (upstream-updater-name updater))
  1359. #:field 'source)))))))
  1360. (define (lookup-disarchive-spec hash)
  1361. "If Disarchive mirrors have a spec for HASH, return the list of SWH
  1362. directory identifiers the spec refers to. Otherwise return #f."
  1363. (define (extract-swh-id spec)
  1364. ;; Return the list of SWH directory identifiers SPEC refers to, where SPEC
  1365. ;; is a Disarchive sexp. Instead of attempting to parse it, traverse it
  1366. ;; in a pretty unintelligent fashion.
  1367. (let loop ((sexp spec)
  1368. (ids '()))
  1369. (match sexp
  1370. ((? string? str)
  1371. (let ((prefix "swh:1:dir:"))
  1372. (if (string-prefix? prefix str)
  1373. (cons (string-drop str (string-length prefix)) ids)
  1374. ids)))
  1375. ((head tail ...)
  1376. (loop tail (loop head ids)))
  1377. (_ ids))))
  1378. (any (lambda (mirror)
  1379. (with-networking-fail-safe
  1380. (format #f (G_ "failed to access Disarchive database at ~a")
  1381. mirror)
  1382. #f
  1383. (guard (c ((http-get-error? c) #f))
  1384. (let* ((url (string-append mirror
  1385. (symbol->string
  1386. (content-hash-algorithm hash))
  1387. "/"
  1388. (bytevector->base16-string
  1389. (content-hash-value hash))))
  1390. (port (http-fetch (string->uri url) #:text? #t))
  1391. (spec (read port)))
  1392. (close-port port)
  1393. (extract-swh-id spec)))))
  1394. %disarchive-mirrors))
  1395. (define (check-archival package)
  1396. "Check whether PACKAGE's source code is archived on Software Heritage. If
  1397. it's not, and if its source code is a VCS snapshot, then send a \"save\"
  1398. request to Software Heritage.
  1399. Software Heritage imposes limits on the request rate per client IP address.
  1400. This checker prints a notice and stops doing anything once that limit has been
  1401. reached."
  1402. (define (response->warning url method response)
  1403. (if (request-rate-limit-reached? url method)
  1404. (list (make-warning package
  1405. (G_ "Software Heritage rate limit reached; \
  1406. try again later")
  1407. #:field 'source))
  1408. (list (make-warning package
  1409. (G_ "'~a' returned ~a")
  1410. (list url (response-code response))
  1411. #:field 'source))))
  1412. (define skip-key (gensym "skip-archival-check"))
  1413. (define (skip-when-limit-reached url method)
  1414. (or (not (request-rate-limit-reached? url method))
  1415. (throw skip-key #t)))
  1416. (parameterize ((%allow-request? skip-when-limit-reached))
  1417. (catch #t
  1418. (lambda ()
  1419. (match (and (origin? (package-source package))
  1420. (package-source package))
  1421. (#f ;no source
  1422. '())
  1423. ((= origin-uri (? git-reference? reference))
  1424. (define url
  1425. (git-reference-url reference))
  1426. (define commit
  1427. (git-reference-commit reference))
  1428. (match (if (commit-id? commit)
  1429. (or (lookup-revision commit)
  1430. (lookup-origin-revision url commit))
  1431. (lookup-origin-revision url commit))
  1432. ((? revision? revision)
  1433. '())
  1434. (#f
  1435. ;; Revision is missing from the archive, attempt to save it.
  1436. (catch 'swh-error
  1437. (lambda ()
  1438. (save-origin (git-reference-url reference) "git")
  1439. (list (make-warning
  1440. package
  1441. ;; TRANSLATORS: "Software Heritage" is a proper noun
  1442. ;; that must remain untranslated. See
  1443. ;; <https://www.softwareheritage.org>.
  1444. (G_ "scheduled Software Heritage archival")
  1445. #:field 'source)))
  1446. (lambda (key url method response . _)
  1447. (cond ((= 429 (response-code response))
  1448. (list (make-warning
  1449. package
  1450. (G_ "archival rate limit exceeded; \
  1451. try again later")
  1452. #:field 'source)))
  1453. (else
  1454. (response->warning url method response))))))))
  1455. ((? origin? origin)
  1456. ;; Since "save" origins are not supported for non-VCS source, all
  1457. ;; we can do is tell whether a given tarball is available or not.
  1458. (if (and=> (origin-hash origin) ;XXX: for ungoogled-chromium
  1459. content-hash-value) ;& icecat
  1460. (let ((hash (origin-hash origin)))
  1461. (match (lookup-content (content-hash-value hash)
  1462. (symbol->string
  1463. (content-hash-algorithm hash)))
  1464. (#f
  1465. ;; If SWH doesn't have HASH as is, it may be because it's
  1466. ;; a hand-crafted tarball. In that case, check whether
  1467. ;; the Disarchive database has an entry for that tarball.
  1468. (match (lookup-disarchive-spec hash)
  1469. (#f
  1470. (list (make-warning package
  1471. (G_ "source not archived on Software \
  1472. Heritage and missing from the Disarchive database")
  1473. #:field 'source)))
  1474. (directory-ids
  1475. (match (find (lambda (id)
  1476. (not (lookup-directory id)))
  1477. directory-ids)
  1478. (#f '())
  1479. (id
  1480. (list (make-warning package
  1481. (G_ "
  1482. Disarchive entry refers to non-existent SWH directory '~a'")
  1483. (list id)
  1484. #:field 'source)))))))
  1485. ((? content?)
  1486. '())))
  1487. '()))
  1488. (_
  1489. (list (make-warning package
  1490. (G_ "unsupported source type")
  1491. #:field 'source)))))
  1492. (match-lambda*
  1493. (('swh-error url method response)
  1494. (response->warning url method response))
  1495. ((key . args)
  1496. (if (eq? key skip-key)
  1497. '()
  1498. (with-networking-fail-safe
  1499. (G_ "while connecting to Software Heritage")
  1500. '()
  1501. (apply throw key args))))))))
  1502. (define (check-haskell-stackage package)
  1503. "Check whether PACKAGE is a Haskell package ahead of the current
  1504. Stackage LTS version."
  1505. (match (with-networking-fail-safe
  1506. (format #f (G_ "while retrieving upstream info for '~a'")
  1507. (package-name package))
  1508. #f
  1509. (package-latest-release package (list %stackage-updater)))
  1510. ((? upstream-source? source)
  1511. (if (version>? (package-version package)
  1512. (upstream-source-version source))
  1513. (list
  1514. (make-warning package
  1515. (G_ "ahead of Stackage LTS version ~a")
  1516. (list (upstream-source-version source))
  1517. #:field 'version))
  1518. '()))
  1519. (#f '())))
  1520. ;;;
  1521. ;;; Source code formatting.
  1522. ;;;
  1523. (define (report-tabulations package line line-number)
  1524. "Warn about tabulations found in LINE."
  1525. (match (string-index line #\tab)
  1526. (#f #f)
  1527. (index
  1528. (make-warning package
  1529. (G_ "tabulation on line ~a, column ~a")
  1530. (list line-number index)
  1531. #:location
  1532. (location (package-file package)
  1533. line-number
  1534. index)))))
  1535. (define (report-trailing-white-space package line line-number)
  1536. "Warn about trailing white space in LINE."
  1537. (and (not (or (string=? line (string-trim-right line))
  1538. (string=? line (string #\page))))
  1539. (make-warning package
  1540. (G_ "trailing white space on line ~a")
  1541. (list line-number)
  1542. #:location
  1543. (location (package-file package)
  1544. line-number
  1545. 0))))
  1546. (define (report-long-line package line line-number)
  1547. "Emit a warning if LINE is too long."
  1548. ;; Note: We don't warn at 80 characters because sometimes hashes and URLs
  1549. ;; make it hard to fit within that limit and we want to avoid making too
  1550. ;; much noise.
  1551. (and (> (string-length line) 90)
  1552. (make-warning package
  1553. (G_ "line ~a is way too long (~a characters)")
  1554. (list line-number (string-length line))
  1555. #:location
  1556. (location (package-file package)
  1557. line-number
  1558. 0))))
  1559. (define %hanging-paren-rx
  1560. (make-regexp "^[[:blank:]]*[()]+[[:blank:]]*$"))
  1561. (define (report-lone-parentheses package line line-number)
  1562. "Emit a warning if LINE contains hanging parentheses."
  1563. (and (regexp-exec %hanging-paren-rx line)
  1564. (make-warning package
  1565. (G_ "parentheses feel lonely, \
  1566. move to the previous or next line")
  1567. (list line-number)
  1568. #:location
  1569. (location (package-file package)
  1570. line-number
  1571. 0))))
  1572. (define %formatting-reporters
  1573. ;; List of procedures that report formatting issues. These are not separate
  1574. ;; checkers because they would need to re-read the file.
  1575. (list report-tabulations
  1576. report-trailing-white-space
  1577. report-long-line
  1578. report-lone-parentheses))
  1579. (define* (report-formatting-issues package file starting-line
  1580. #:key (reporters %formatting-reporters))
  1581. "Report white-space issues in FILE starting from STARTING-LINE, and report
  1582. them for PACKAGE."
  1583. (define (sexp-last-line port)
  1584. ;; Return the last line of the sexp read from PORT or an estimate thereof.
  1585. (define &failure (list 'failure))
  1586. (let ((start (ftell port))
  1587. (start-line (port-line port))
  1588. (sexp (catch 'read-error
  1589. (lambda () (read port))
  1590. (const &failure))))
  1591. (let ((line (port-line port)))
  1592. (seek port start SEEK_SET)
  1593. (set-port-line! port start-line)
  1594. (if (eq? sexp &failure)
  1595. (+ start-line 60) ;conservative estimate
  1596. line))))
  1597. (call-with-input-file file
  1598. (lambda (port)
  1599. (let loop ((line-number 1)
  1600. (last-line #f)
  1601. (warnings '()))
  1602. (let ((line (read-line port)))
  1603. (if (or (eof-object? line)
  1604. (and last-line (> line-number last-line)))
  1605. warnings
  1606. (if (and (= line-number starting-line)
  1607. (not last-line))
  1608. (loop (+ 1 line-number)
  1609. (+ 1 (sexp-last-line port))
  1610. warnings)
  1611. (loop (+ 1 line-number)
  1612. last-line
  1613. (append
  1614. warnings
  1615. (if (< line-number starting-line)
  1616. '()
  1617. (filter-map (lambda (report)
  1618. (report package line line-number))
  1619. reporters)))))))))))
  1620. (define (check-formatting package)
  1621. "Check the formatting of the source code of PACKAGE."
  1622. (let ((location (package-location package)))
  1623. (if location
  1624. ;; Report issues starting from the line before the 'package'
  1625. ;; form, which usually contains the 'define' form.
  1626. (let ((line (- (location-line location) 1)))
  1627. (match (search-path %load-path (location-file location))
  1628. ((? string? file)
  1629. (report-formatting-issues package file line))
  1630. (#f
  1631. ;; It could be that LOCATION lists a "true" relative file
  1632. ;; name--i.e., not relative to an element of %LOAD-PATH.
  1633. (let ((file (location-file location)))
  1634. (if (file-exists? file)
  1635. (report-formatting-issues package file line)
  1636. (list (make-warning package
  1637. (G_ "source file not found"))))))))
  1638. '())))
  1639. ;;;
  1640. ;;; List of checkers.
  1641. ;;;
  1642. (define %local-checkers
  1643. (list
  1644. (lint-checker
  1645. (name 'name)
  1646. (description "Validate package names")
  1647. (check check-name))
  1648. (lint-checker
  1649. (name 'tests-true)
  1650. (description "Check if tests are explicitly enabled")
  1651. (check check-tests-true))
  1652. (lint-checker
  1653. (name 'description)
  1654. (description "Validate package descriptions")
  1655. (check check-description-style))
  1656. (lint-checker
  1657. (name 'inputs-should-be-native)
  1658. (description "Identify inputs that should be native inputs")
  1659. (check check-inputs-should-be-native))
  1660. (lint-checker
  1661. (name 'inputs-should-not-be-input)
  1662. (description "Identify inputs that shouldn't be inputs at all")
  1663. (check check-inputs-should-not-be-an-input-at-all))
  1664. (lint-checker
  1665. (name 'input-labels)
  1666. (description "Identify input labels that do not match package names")
  1667. (check check-input-labels))
  1668. (lint-checker
  1669. (name 'wrapper-inputs)
  1670. (description "Make sure 'wrap-program' can finds its interpreter.")
  1671. (check check-wrapper-inputs))
  1672. (lint-checker
  1673. (name 'license)
  1674. ;; TRANSLATORS: <license> is the name of a data type and must not be
  1675. ;; translated.
  1676. (description "Make sure the 'license' field is a <license> \
  1677. or a list thereof")
  1678. (check check-license))
  1679. (lint-checker
  1680. (name 'optional-tests)
  1681. (description "Make sure tests are only run when requested")
  1682. (check check-optional-tests))
  1683. (lint-checker
  1684. (name 'mirror-url)
  1685. (description "Suggest 'mirror://' URLs")
  1686. (check check-mirror-url))
  1687. (lint-checker
  1688. (name 'source-file-name)
  1689. (description "Validate file names of sources")
  1690. (check check-source-file-name))
  1691. (lint-checker
  1692. (name 'source-unstable-tarball)
  1693. (description "Check for autogenerated tarballs")
  1694. (check check-source-unstable-tarball))
  1695. (lint-checker
  1696. (name 'derivation)
  1697. (description "Report failure to compile a package to a derivation")
  1698. (check check-derivation)
  1699. (requires-store? #t))
  1700. (lint-checker
  1701. (name 'profile-collisions)
  1702. (description "Report collisions that would occur due to propagated inputs")
  1703. (check check-profile-collisions)
  1704. (requires-store? #t))
  1705. (lint-checker
  1706. (name 'patch-file-names)
  1707. (description "Validate file names and availability of patches")
  1708. (check check-patch-file-names))
  1709. (lint-checker
  1710. (name 'patch-headers)
  1711. (description "Validate patch headers")
  1712. (check check-patch-headers))
  1713. (lint-checker
  1714. (name 'formatting)
  1715. (description "Look for formatting issues in the source")
  1716. (check check-formatting))))
  1717. (define %network-dependent-checkers
  1718. (list
  1719. (lint-checker
  1720. (name 'synopsis)
  1721. (description "Validate package synopses")
  1722. (check check-synopsis-style))
  1723. (lint-checker
  1724. (name 'gnu-description)
  1725. (description "Validate synopsis & description of GNU packages")
  1726. (check check-gnu-synopsis+description))
  1727. (lint-checker
  1728. (name 'home-page)
  1729. (description "Validate home-page URLs")
  1730. (check check-home-page))
  1731. (lint-checker
  1732. (name 'source)
  1733. (description "Validate source URLs")
  1734. (check check-source))
  1735. (lint-checker
  1736. (name 'github-url)
  1737. (description "Suggest GitHub URLs")
  1738. (check check-github-url))
  1739. (lint-checker
  1740. (name 'cve)
  1741. (description "Check the Common Vulnerabilities and Exposures\
  1742. (CVE) database")
  1743. (check check-vulnerabilities))
  1744. (lint-checker
  1745. (name 'refresh)
  1746. (description "Check the package for new upstream releases")
  1747. (check check-for-updates))
  1748. (lint-checker
  1749. (name 'archival)
  1750. (description "Ensure source code archival on Software Heritage")
  1751. (check check-archival))
  1752. (lint-checker
  1753. (name 'haskell-stackage)
  1754. (description "Ensure Haskell packages use Stackage LTS versions")
  1755. (check check-haskell-stackage))))
  1756. (define %all-checkers
  1757. (append %local-checkers
  1758. %network-dependent-checkers))