Skip to content

Commit

Permalink
keira: lint
Browse files Browse the repository at this point in the history
global: add check-docker command
  • Loading branch information
and3rson committed Mar 10, 2024
1 parent 6cbd700 commit 8f7f1b8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
51 changes: 31 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# .PHONY: reformat
# reformat:
# find \
# ./firmware-demo/src/ \
# ./lib/lilka \
# -not \( -name .ccls-cache -prune \) \
# -not \( -name .pio -prune \) \
# -iname *.h \
# -o -iname *.cpp \
# | xargs clang-format -i
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'

all:
false
.PHONY: reformat
reformat: ## Reformat all source files
@find \
. \
-not \( -name .ccls-cache -prune \) \
-not \( -name .pio -prune \) \
-not \( -name mjs -prune \) \
-not \( -name doomgeneric -prune \) \
-not \( -name bak -prune \) \
-iname *.h \
-o -iname *.cpp \
-o -iname *.c \
-o -iname *.hpp \
-o -iname *.h \
-o -iname *.rst \
| xargs clang-format -i

.PHONY: todo
todo:
@# Find all files, but exclude .pio and .ccls-cache directories
@# Preserve colors in output
todo: ## Find all TODO, FIXME, XXX comments
@find \
. \
-not \( -name .ccls-cache -prune \) \
Expand All @@ -32,12 +36,19 @@ todo:
| xargs grep --color=always -n -H -E "TODO|FIXME|XXX" \

.PHONY: check
check: clang-format cppcheck
check: clang-format cppcheck ## Run all checks

.ONESHELL: check-docker
check-docker: ## Run all checks in docker
docker build -t lilka-check -f - . <<EOF
FROM ubuntu:24.04
RUN apt-get update -y && \
apt-get install -y clang-format cppcheck findutils grep make
EOF
docker run --rm -it -v $(PWD):/lilka -w /lilka lilka-check make check

.PHONY: clang-format
clang-format:
# Find all files, but exclude .pio and .ccls-cache directories
# Preserve colors in output
clang-format: ## Run clang-format check
find \
. \
-not \( -name .ccls-cache -prune \) \
Expand All @@ -53,7 +64,7 @@ clang-format:
| xargs clang-format --dry-run --Werror

.PHONY: cppcheck
cppcheck:
cppcheck: ## Run cppcheck check
cppcheck . -i.ccls-cache -ipio -imjs -idoomgeneric -ibak --enable=performance,style \
--suppress=cstyleCast \
--suppress=constVariablePointer \
Expand Down
4 changes: 2 additions & 2 deletions firmware/keira/src/apps/statusbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ void StatusBarApp::run() {
xOffset += 8 + 24;

// Draw battery
int16_t x1 = 6, y1 = 8;
int16_t fullWidth = 22, h = 8;
int level = lilka::battery.readLevel();
if (level == -1) {
canvas->draw16bitRGBBitmapWithTranColor(
xOffset, 0, battery_absent, lilka::display.color565(255, 0, 255), 32, 24
);
} else {
int16_t x1 = 6, y1 = 8;
int16_t fullWidth = 22, h = 8;
int filledWidth = fullWidth * level / 100;
if (filledWidth < 1) filledWidth = 1;
int16_t color =
Expand Down

0 comments on commit 8f7f1b8

Please sign in to comment.