Skip to content

Add automated coding conventions checking #1324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ EMACS := $(shell which "$${EMACS}" 2> /dev/null || which "emacs")
EMACS_VERSION := $(shell "$(EMACS)" -Q --batch --eval '(princ emacs-version)')

EFLAGS = --eval "(add-to-list 'load-path (expand-file-name \"tests/compat\") 'append)" \
--eval '(setq byte-compile-error-on-warn t)' \
--eval '(when (not (version< emacs-version "24.4")) (setq load-prefer-newer t))' \
--eval '(defun byte-compile-dest-file (filename) \
(concat (file-name-directory filename) "build-" emacs-version "/" \
(file-name-nondirectory filename) "c"))'
--eval "(when (boundp 'load-prefer-newer) (setq load-prefer-newer t))"

BATCH = $(EMACS) $(EFLAGS) --batch -Q -L .

Expand All @@ -58,32 +54,35 @@ check-emacs-version :
(message \" 3. make EMACS=/path/to/emacs\") \
(kill-emacs 2))"

compile: build-$(EMACS_VERSION)
compile: build-$(EMACS_VERSION)/build-flag

build-$(EMACS_VERSION) : $(ELFILES)
if [ ! -d $@ ]; then mkdir $@; fi
$(BATCH) -f batch-byte-compile-if-not-done $^
build-$(EMACS_VERSION)/build-flag : $(ELFILES)
if [ ! -d $$(dirname $@) ]; then mkdir $$(dirname $@); fi
$(BATCH) --eval '(setq byte-compile-error-on-warn t)' \
--eval "(defun byte-compile-dest-file (filename) \
(concat (file-name-directory filename) \"build-\" emacs-version \"/\" \
(file-name-nondirectory filename) \"c\"))'" \
-f batch-byte-compile $^
touch $@

check-%: tests/%-tests.el
$(BATCH) -l "$<" -f ert-run-tests-batch-and-exit;

check: $(ELCHECKS) build-$(EMACS_VERSION)
check: compile $(AUTOLOADS) check-ert check-conventions

check-conventions :
$(BATCH) -l tests/haskell-code-conventions.el \
-f haskell-check-conventions-batch-and-exit
@echo "conventions are okay"

check-ert: $(ELCHECKS)
$(BATCH) --eval "(when (= emacs-major-version 24) \
(require 'undercover) \
(undercover \"*.el\" \
(:exclude \"haskell-mode-pkg.el\" \"haskell-compat.el\")))" \
-L tests \
$(patsubst %,-l %,$(ELCHECKS)) \
-f ert-run-tests-batch-and-exit
@TAB=$$(echo "\t"); \
if grep -Hn "[ $${TAB}]\+\$$" *.el tests/*.el; then \
echo "Error: Files contain whitespace at the end of lines" >&2; \
exit 3; \
fi; \
if grep -Hn "[$${TAB}]" *.el tests/*.el; then \
echo "Error: Tab character is not allowed" >&2; \
exit 3; \
fi
@echo "checks passed!"

clean:
Expand Down
4 changes: 2 additions & 2 deletions haskell-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ comment. May return a qualified name."
;; First, skip whitespace if we're on it, moving point to last
;; identifier char. That way, if we're at "map ", we'll see the word
;; "map".
(when (and (looking-at (rx eol))
(when (and (eolp)
(not (bolp)))
(backward-char))
(when (and (not (eobp))
Expand Down Expand Up @@ -1168,7 +1168,7 @@ generated."
"Echo STR in mini-buffer.
Given string is shrinken to single line, multiple lines just
disturbs the programmer."
(message (haskell-mode-one-line str (frame-width))))
(message "%s" (haskell-mode-one-line str (frame-width))))

(defun haskell-mode-one-line (str width)
"Try to fit STR as much as possible on one line according to given WIDTH."
Expand Down
3 changes: 1 addition & 2 deletions haskell.el
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ If `haskell-process-load-or-reload-prompt' is nil, accept `default'."
(?n))))
;; unwind
(haskell-mode-toggle-interactive-prompt-state t)))
(message
(format "The Haskell process `%s' is dearly departed." process-name)))))
(message "The Haskell process `%s' is dearly departed." process-name))))

(defun haskell-process ()
"Get the current process from the current session."
Expand Down
Loading