mirror of
https://git.sr.ht/~rjarry/aerc
synced 2026-03-02 18:23:33 +01:00
lint,validate: fix for openbsd
- Remove GNU specific stuff (ln -v, mktemp --tempdir, grep --color) - Remove GCC specific flags in sendemail-validate (-Warith-conversion) - Add -std=c99 and -Wpedantic and fix the reported warnings. - Explicitly call gmake everywhere. - Run our custom analyzer standalone. Golangci lint plugins are not supported on OpenBSD. Indirect dependency to golang.org/x/mod is required somehow... Reported-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
This commit is contained in:
@@ -12,20 +12,20 @@ environment:
|
||||
DESTDIR: ./out
|
||||
GOFLAGS: "-tags=notmuch"
|
||||
CC: gcc
|
||||
CFLAGS: -O2 -g -Wall -Wextra -Wconversion -Warith-conversion -Werror -Wformat-security -Wstack-protector -fstack-protector-strong -fanalyzer
|
||||
CFLAGS: -O0 -g -std=c99 -Wall -Wextra -Wconversion -Werror -Wformat-security -Wstack-protector -Wpedantic -Wmissing-prototypes
|
||||
FILTERS_TEST_PREFIX: valgrind --leak-check=full --error-exitcode=1
|
||||
tasks:
|
||||
- build: |
|
||||
make -C aerc
|
||||
gmake -C aerc
|
||||
- install: |
|
||||
make -C aerc install checkinstall
|
||||
gmake -C aerc install checkinstall
|
||||
- test: |
|
||||
make -C aerc tests
|
||||
gmake -C aerc tests
|
||||
- lint: |
|
||||
make -C aerc lint
|
||||
gmake -C aerc lint
|
||||
- ancient-go-version: |
|
||||
curl -O https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/go-1.18.7-r0.apk
|
||||
sudo apk add ./go-1.18.7-r0.apk
|
||||
make -C aerc clean all
|
||||
gmake -C aerc clean all
|
||||
- check-patches: |
|
||||
make -C aerc check-patches
|
||||
gmake -C aerc check-patches
|
||||
|
||||
6
.github/workflows/macos.yml
vendored
6
.github/workflows/macos.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
- run: brew install gnupg notmuch scdoc
|
||||
- run: make
|
||||
- run: make install
|
||||
- run: make checkinstall
|
||||
- run: gmake
|
||||
- run: gmake install
|
||||
- run: gmake checkinstall
|
||||
- run: go test ./...
|
||||
|
||||
@@ -9,15 +9,9 @@ enable = [
|
||||
"errorlint", # check to ensure no problems with wrapped errors
|
||||
"gocritic", # check for bugs, performance, and style issues
|
||||
"gofmt", # check that gofmt is satisfied
|
||||
"aerc", # aerc specific linters
|
||||
]
|
||||
|
||||
[linters-settings.nolintlint]
|
||||
allow-unused = false # don't allow nolint if not required
|
||||
require-explanation = true # require an explanation when disabling a linter
|
||||
requre-specific = true # linter exceptions must specify the linter
|
||||
|
||||
[linters-settings.custom.aerc]
|
||||
path = "./linters.so"
|
||||
description = "Aerc specific linters"
|
||||
original-url = "git.sr.ht/~rjarry/aerc/contrib"
|
||||
|
||||
@@ -10,7 +10,7 @@ the project:
|
||||
|
||||
$ git clone https://git.sr.ht/~rjarry/aerc
|
||||
$ cd aerc
|
||||
$ make
|
||||
$ gmake
|
||||
|
||||
Patch the code. Write some tests. Ensure that your code is properly formatted
|
||||
with `gofumpt`. Ensure that everything builds and works as expected. Ensure
|
||||
@@ -19,7 +19,7 @@ that you did not break anything.
|
||||
- If applicable, update unit tests.
|
||||
- If adding a new feature, please consider adding new tests.
|
||||
- Do not forget to update the docs.
|
||||
- Run the linter using `make lint`.
|
||||
- Run the linter using `gmake lint`.
|
||||
|
||||
Once you are happy with your work, you can create a commit (or several
|
||||
commits). Follow these general rules:
|
||||
@@ -70,13 +70,14 @@ example:
|
||||
Before sending the patch, you should configure your local clone with sane
|
||||
defaults:
|
||||
|
||||
$ make gitconfig
|
||||
$ gmake gitconfig
|
||||
git config format.subjectPrefix "PATCH aerc"
|
||||
git config sendemail.to "~rjarry/aerc-devel@lists.sr.ht"
|
||||
git config format.notes true
|
||||
git config notes.rewriteRef refs/notes/commits
|
||||
git config notes.rewriteMode concatenate
|
||||
'.git/hooks/sendemail-validate' -> '../../contrib/sendemail-validate'
|
||||
+ ln -s ../../contrib/sendemail-validate .git/hooks/sendemail-validate
|
||||
+ git config sendemail.validate true
|
||||
|
||||
And send the patch to the mailing list ([step-by-step
|
||||
instructions][git-send-email-tutorial]):
|
||||
@@ -270,7 +271,7 @@ is available in the repository.
|
||||
|
||||
The Go-code follows the rules of [gofumpt][gofumpt-repo] which is equivalent to
|
||||
gofmt but adds a few additional rules. The code can be automatically formatted
|
||||
by running `make fmt`.
|
||||
by running `gmake fmt`.
|
||||
|
||||
If gofumpt accepts your code it's most likely properly formatted.
|
||||
|
||||
|
||||
@@ -46,11 +46,8 @@ dev:
|
||||
fmt:
|
||||
$(GO) run mvdan.cc/gofumpt@$(gofumpt_tag) -w .
|
||||
|
||||
linters.so: contrib/linters.go
|
||||
$(GO) build -buildmode=plugin -o linters.so contrib/linters.go
|
||||
|
||||
.PHONY: lint
|
||||
lint: linters.so
|
||||
lint:
|
||||
@contrib/check-whitespace `git ls-files ':!:filters/vectors'` && \
|
||||
echo white space ok.
|
||||
@contrib/check-docs && echo docs ok.
|
||||
@@ -59,6 +56,7 @@ lint: linters.so
|
||||
|| echo all files formatted.
|
||||
$(GO) run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2 run \
|
||||
$$(echo $(GOFLAGS) | sed s/-tags=/--build-tags=/)
|
||||
$(GO) run $(GOFLAGS) contrib/linters.go ./...
|
||||
|
||||
.PHONY: vulncheck
|
||||
vulncheck:
|
||||
@@ -118,7 +116,8 @@ gitconfig:
|
||||
@mkdir -p .git/hooks
|
||||
@rm -f .git/hooks/sendemail-validate*
|
||||
@if grep -q GIT_SENDEMAIL_FILE_COUNTER `git --exec-path`/git-send-email 2>/dev/null; then \
|
||||
ln -svf ../../contrib/sendemail-validate .git/hooks/sendemail-validate && \
|
||||
set -xe; \
|
||||
ln -s ../../contrib/sendemail-validate .git/hooks/sendemail-validate && \
|
||||
git config sendemail.validate true; \
|
||||
fi
|
||||
|
||||
|
||||
16
README.md
16
README.md
@@ -10,7 +10,7 @@ by Drew DeVault.
|
||||
|
||||
A short demonstration can be found on [https://aerc-mail.org/](https://aerc-mail.org/)
|
||||
|
||||
Join the IRC channel: [#aerc on irc.libera.chat](http://web.libera.chat/?channels=aerc&uio=d4)
|
||||
Join the IRC channel: [#aerc on irc.libera.chat](http://web.libera.chat/?channels=aerc)
|
||||
for end-user support, and development.
|
||||
|
||||
## Usage
|
||||
@@ -72,11 +72,11 @@ Install the dependencies:
|
||||
older versions may be dropped at any time due to incompatibilities or newer
|
||||
required language features.)*
|
||||
- [scdoc](https://git.sr.ht/~sircmpwn/scdoc)
|
||||
- GNU make (on \*BSD, `make` commands must be replaced by `gmake`).
|
||||
- GNU make
|
||||
|
||||
Then compile aerc:
|
||||
|
||||
$ make
|
||||
$ gmake
|
||||
|
||||
aerc optionally supports notmuch. To enable it, you need to have a recent
|
||||
version of [notmuch](https://notmuchmail.org/#index7h2), including the header
|
||||
@@ -89,16 +89,16 @@ check if it is, run the following command:
|
||||
|
||||
If it is not, you can force it before building:
|
||||
|
||||
$ make GOFLAGS=-tags=notmuch
|
||||
$ gmake GOFLAGS=-tags=notmuch
|
||||
|
||||
If you have notmuch headers available but do not want to build notmuch support
|
||||
in aerc, force GOFLAGS to an empty value:
|
||||
|
||||
$ make GOFLAGS=
|
||||
$ gmake GOFLAGS=
|
||||
|
||||
To install aerc locally:
|
||||
|
||||
# make install
|
||||
# gmake install
|
||||
|
||||
By default, aerc will install config files to directories under `/usr/local/aerc`,
|
||||
and will search for templates and stylesets in these locations in order:
|
||||
@@ -112,8 +112,8 @@ At build time it is possible to add an extra location to this list and to use
|
||||
that location as the default install location for config files by setting the
|
||||
`PREFIX` option like so:
|
||||
|
||||
# make PREFIX=/custom/location
|
||||
# make install PREFIX=/custom/location
|
||||
# gmake PREFIX=/custom/location
|
||||
# gmake install PREFIX=/custom/location
|
||||
|
||||
This will install templates and other config files to `/custom/location/share/aerc`,
|
||||
and man pages to `/custom/location/share/man`. This extra location will have lower
|
||||
|
||||
@@ -6,14 +6,22 @@ trap "rm -f $tmp" EXIT
|
||||
global_fail=0
|
||||
|
||||
cmd_scd_sed='s/^\*:([a-z][a-z-]*)\*.*/\1/p'
|
||||
cmd_go_sed='/^func ([[:alnum:]]\+) Aliases() \[\]string {$/{n; s/", "/ /g; s/.*return \[\]string{"\(.*\)"}/\1/p}'
|
||||
cmd_go_sed='/^func ([[:alnum:]][[:alnum:]]*) Aliases() \[\]string {$/{n;
|
||||
s/", "/ /g;
|
||||
s/.*return \[\]string{"\(.*\)"}/\1/p
|
||||
}'
|
||||
|
||||
grep_color=
|
||||
if echo . | grep --color . >/dev/null 2>&1; then
|
||||
grep_color=--color
|
||||
fi
|
||||
|
||||
fail=0
|
||||
sed -nre "$cmd_scd_sed" doc/*.scd > "$tmp"
|
||||
for f in $(find commands -type f -name '*.go'); do
|
||||
for cmd in $(sed -ne "$cmd_go_sed" "$f"); do
|
||||
if ! grep -qFx "$cmd" "$tmp"; then
|
||||
grep -HnF --color "\"$cmd\"" "$f"
|
||||
grep -HnF $grep_color "\"$cmd\"" "$f"
|
||||
fail=$((fail+1))
|
||||
fi
|
||||
done
|
||||
@@ -29,7 +37,7 @@ sed -ne "$cmd_go_sed" $(find commands -type f -name '*.go') | tr ' ' '\n' > "$tm
|
||||
for f in doc/*.scd; do
|
||||
for cmd in $(sed -nre "$cmd_scd_sed" "$f"); do
|
||||
if ! grep -qFx "$cmd" "$tmp"; then
|
||||
grep -Hn --color "^\\*:$cmd\\*" "$f"
|
||||
grep -Hn $grep_color "^\\*:$cmd\\*" "$f"
|
||||
fail=$((fail+1))
|
||||
fi
|
||||
done
|
||||
@@ -45,7 +53,7 @@ sed -nre 's/^\*([a-z][a-z-]*)\* = .*/\1/p' doc/*.scd > "$tmp"
|
||||
for f in $(find config -type f -name '*.go'); do
|
||||
for opt in $(sed -nre 's/.*`ini:"([a-z][a-z-]*)".*/\1/p' $f); do
|
||||
if ! grep -qFx "$opt" "$tmp"; then
|
||||
grep -HnF --color "\"$opt\"" "$f"
|
||||
grep -HnF $grep_color "\"$opt\"" "$f"
|
||||
fail=$((fail+1))
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -5,13 +5,14 @@ set -e
|
||||
revision_range="${1?revision range}"
|
||||
|
||||
valid=0
|
||||
total=$(git rev-list --reverse "$revision_range" | wc -l)
|
||||
revisions=$(git rev-list --reverse "$revision_range")
|
||||
total=$(echo $revisions | wc -w)
|
||||
if [ "$total" -eq 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
n=0
|
||||
for rev in $(git rev-list --reverse "$revision_range"); do
|
||||
for rev in $revisions; do
|
||||
n=$((n + 1))
|
||||
title=$(git log --format='%s' -1 "$rev")
|
||||
fail=false
|
||||
|
||||
@@ -5,8 +5,10 @@ import (
|
||||
"go/token"
|
||||
"go/types"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/analysis"
|
||||
"golang.org/x/tools/go/analysis/multichecker"
|
||||
)
|
||||
|
||||
type indirectCalls struct {
|
||||
@@ -71,7 +73,10 @@ func runPanic(pass *analysis.Pass) (interface{}, error) {
|
||||
}
|
||||
|
||||
if !isPanicHandlerInstall(block.List[0]) {
|
||||
pass.Report(panicDiag(block.Pos()))
|
||||
path := pass.Fset.File(block.Pos()).Name()
|
||||
if !strings.HasSuffix(path, "_test.go") {
|
||||
pass.Report(panicDiag(block.Pos()))
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
@@ -85,6 +90,9 @@ func runPanicIndirect(pass *analysis.Pass) (interface{}, error) {
|
||||
calls := pass.ResultOf[PanicAnalyzer].(*indirectCalls)
|
||||
|
||||
for _, file := range pass.Files {
|
||||
if strings.HasSuffix(file.Name.Name, "_test") {
|
||||
continue
|
||||
}
|
||||
for _, decl := range file.Decls {
|
||||
if f, ok := decl.(*ast.FuncDecl); ok {
|
||||
if _, ok := calls.methods[f.Name.Pos()]; ok {
|
||||
@@ -95,7 +103,10 @@ func runPanicIndirect(pass *analysis.Pass) (interface{}, error) {
|
||||
continue
|
||||
}
|
||||
if !isPanicHandlerInstall(f.Body.List[0]) {
|
||||
pass.Report(panicDiag(f.Body.Pos()))
|
||||
path := pass.Fset.File(f.Body.Pos()).Name()
|
||||
if !strings.HasSuffix(path, "_test.go") {
|
||||
pass.Report(panicDiag(f.Body.Pos()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,16 +155,9 @@ func isPanicHandlerInstall(stmt ast.Stmt) bool {
|
||||
return i.Name == "log" && s.Sel.Name == "PanicHandler"
|
||||
}
|
||||
|
||||
// golang-lint required plugin api
|
||||
type analyzerPlugin struct{}
|
||||
|
||||
// This must be implemented
|
||||
func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer {
|
||||
return []*analysis.Analyzer{
|
||||
func main() {
|
||||
multichecker.Main(
|
||||
PanicAnalyzer,
|
||||
PanicIndirectAnalyzer,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// This must be defined and named 'AnalyzerPlugin'
|
||||
var AnalyzerPlugin analyzerPlugin
|
||||
|
||||
@@ -30,10 +30,10 @@ validate_patch () {
|
||||
git am -3 "$file"
|
||||
}
|
||||
|
||||
export CFLAGS="-O2 -g -Wall -Wextra -Wconversion -Warith-conversion -Werror -Wformat-security -Wstack-protector -fstack-protector-strong -fanalyzer"
|
||||
export CFLAGS="-O0 -g -std=c99 -Wall -Wextra -Wconversion -Werror -Wformat-security -Wstack-protector -Wpedantic -Wmissing-prototypes"
|
||||
|
||||
validate_series () {
|
||||
make all tests lint check-patches
|
||||
gmake all tests lint check-patches
|
||||
}
|
||||
|
||||
# main -------------------------------------------------------------------------
|
||||
@@ -41,8 +41,8 @@ validate_series () {
|
||||
if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
|
||||
then
|
||||
remote=$(git config --default origin --get sendemail.validateRemote) &&
|
||||
ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
|
||||
worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
|
||||
ref=$(git config --default master --get sendemail.validateRemoteRef) &&
|
||||
worktree=$(mktemp -t -d sendemail-validate.XXXXXXX) &&
|
||||
git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
|
||||
git config --replace-all sendemail.validateWorktree "$worktree"
|
||||
else
|
||||
|
||||
@@ -62,7 +62,7 @@ static void *xmalloc(size_t s)
|
||||
#define RESET "\x1b[0m"
|
||||
#define LONGEST_SEQ "\x1b[1;2;3;4;5;7;38;2;255;255;255;48;2;255;255;255m"
|
||||
|
||||
const char *seq(struct style *s) {
|
||||
static const char *seq(struct style *s) {
|
||||
if (!s->sequence) {
|
||||
char *b, *buf = xmalloc(strlen(LONGEST_SEQ) + 1);
|
||||
const char *sep = "";
|
||||
@@ -249,7 +249,7 @@ static int parse_color(struct color *c, const char *val)
|
||||
} else if (sscanf(val, "#%x", &color) == 1 && color <= 0xffffff) {
|
||||
c->type = RGB;
|
||||
c->rgb = color;
|
||||
} else if (sscanf(val, "%d", &color) == 1 && color <= 256) {
|
||||
} else if (sscanf(val, "%u", &color) == 1 && color <= 256) {
|
||||
c->type = PALETTE;
|
||||
c->index = color;
|
||||
} else if (!color_name(val, &color)) {
|
||||
@@ -702,7 +702,7 @@ static void colorize_line(const char *in)
|
||||
}
|
||||
}
|
||||
|
||||
int parse_args(int argc, char **argv)
|
||||
static int parse_args(int argc, char **argv)
|
||||
{
|
||||
const char *filename = NULL, *osc8 = NULL;
|
||||
int c;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <locale.h>
|
||||
#include <regex.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -33,7 +34,7 @@ static size_t prose_ratio = 50;
|
||||
static bool reflow;
|
||||
static FILE *in_file;
|
||||
|
||||
int parse_args(int argc, char **argv)
|
||||
static int parse_args(int argc, char **argv)
|
||||
{
|
||||
const char *filename = NULL;
|
||||
long value;
|
||||
@@ -362,18 +363,18 @@ static void write_paragraph(struct paragraph *p)
|
||||
more = false;
|
||||
} else {
|
||||
/* find split point, preferably before margin */
|
||||
size_t split = -1U;
|
||||
size_t split = SIZE_MAX;
|
||||
size_t w = 0;
|
||||
for (size_t i = 0; text[i] != L'\0'; i++) {
|
||||
w += (size_t)wcwidth(text[i]);
|
||||
if (width + w > margin && split != -1U) {
|
||||
if (width + w > margin && split != SIZE_MAX) {
|
||||
break;
|
||||
}
|
||||
if (iswspace((wint_t)text[i])) {
|
||||
split = i;
|
||||
}
|
||||
}
|
||||
if (split == -1U) {
|
||||
if (split == SIZE_MAX) {
|
||||
/* no space found to split, print a long line */
|
||||
line = text;
|
||||
more = false;
|
||||
|
||||
1
go.mod
1
go.mod
@@ -51,6 +51,7 @@ require (
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.8.1 // indirect
|
||||
golang.org/x/crypto v0.8.0 // indirect
|
||||
golang.org/x/mod v0.8.0 // indirect
|
||||
golang.org/x/net v0.9.0 // indirect
|
||||
golang.org/x/term v0.7.0 // indirect
|
||||
golang.org/x/text v0.12.0 // indirect
|
||||
|
||||
2
go.sum
2
go.sum
@@ -152,6 +152,7 @@ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJu
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
@@ -167,6 +168,7 @@ golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
||||
Reference in New Issue
Block a user