lint.scm 75 KB

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