lint.scm 74 KB

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