Skip to content
Open
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,23 @@ lint-config-check:
$(GOTOOL) $(GOLINT_PKG) config verify -v

#? lint: Run static code analysis
lint: check-go-version lint-config-check lint-source
lint: check-go-version lint-config-check lint-source

# Globs to exclude generated files from ast-grep.
AST_GREP_EXCLUDE := --globs '!**/*.pb.go' --globs '!**/*.pb.gw.go' --globs '!**/*.pb.json.go' --globs '!**/sqlc/*.go'

# Optional directory/package filter for ast-grep (e.g., make ast-lint pkg=lnwallet).
AST_GREP_PATH := $(if $(pkg),$(pkg),.)

#? ast-lint: Run ast-grep style checks. Use pkg=<dir> to focus on a specific directory.
ast-lint:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it giving false positives, or should we update our guidelines to be more specific?

warning[func-def-dangling-return-paren]: Function return types should not start with open paren on its own line
     ┌─ lnwallet/channel_test.go:1625:1
     │  
1625 │ ╭ func TestHTLCSigNumber(t *testing.T) {
     · │
1775 │ │ }
     │ ╰─^
     │  
     = Per docs/development_guidelines.md: Return type wrapping should continue
       on the same line, not start a new line with open paren.
       
       WRONG:
         func bar(a, b, c) (
         d, error,
         ) {
       
       RIGHT:
         func baz(a, b, c) (d,
         error) {

@$(call print, "Running ast-grep style checks.")
sg scan $(AST_GREP_EXCLUDE) $(AST_GREP_PATH)

#? ast-grep-fix: Auto-fix ast-grep style issues. Use pkg=<dir> to focus on a specific directory.
ast-grep-fix:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried make ast-grep-fix pkg=lnwallet but it didn't fix.

@$(call print, "Auto-fixing ast-grep style issues.")
sg scan --update-all $(AST_GREP_EXCLUDE) $(AST_GREP_PATH)

#? protolint: Lint proto files using protolint
protolint:
Expand Down
Loading