lint.scm 75 KB

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