aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-09-18 21:49:51 +0200
committerLudovic Courtès <ludo@gnu.org>2015-09-18 21:54:04 +0200
commite0566f12f8b57f3311c9aba1737e791763e89544 (patch)
treebac87e3ddaab353624b46008d0bc9b7065c9139c /guix
parent24a848c8e36e762968e6e2803a72ae570e9edbec (diff)
downloadgnu-guix-e0566f12f8b57f3311c9aba1737e791763e89544.tar
gnu-guix-e0566f12f8b57f3311c9aba1737e791763e89544.tar.gz
lint: Report lonely parentheses.
* guix/scripts/lint.scm (%hanging-paren-rx): New variable. (report-lone-parentheses): New procedure. (%formatting-reporters): Use it. * tests/lint.scm ("formatting: lonely parentheses"): New test.
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/lint.scm15
1 files changed, 14 insertions, 1 deletions
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 26b40182a5..8224f540bb 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -594,12 +594,25 @@ descriptions maintained upstream."
(format #f (_ "line ~a is way too long (~a characters)")
line-number (string-length line)))))
+(define %hanging-paren-rx
+ (make-regexp "^[[:blank:]]*[()]+[[:blank:]]*$"))
+
+(define (report-lone-parentheses package line line-number)
+ "Emit a warning if LINE contains hanging parentheses."
+ (when (regexp-exec %hanging-paren-rx line)
+ (emit-warning package
+ (format #f
+ (_ "line ~a: parentheses feel lonely, \
+move to the previous or next line")
+ line-number))))
+
(define %formatting-reporters
;; List of procedures that report formatting issues. These are not separate
;; checkers because they would need to re-read the file.
(list report-tabulations
report-trailing-white-space
- report-long-line))
+ report-long-line
+ report-lone-parentheses))
(define* (report-formatting-issues package file starting-line
#:key (reporters %formatting-reporters))