Skip to content
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

fix linter #58

Merged
merged 2 commits into from
Dec 12, 2024
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
21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
GO = go

BUILD_VERSION := $(if $(BUILD_VERSION),$(BUILD_VERSION),$(shell git describe --tags --always --dirty))
BUILD_COMMIT := $(if $(BUILD_COMMIT),$(BUILD_COMMIT),$(shell git log --format="%H" -n 1))
BUILD_COMMIT_TS := $(if $(BUILD_COMMIT_TS),$(BUILD_COMMIT_TS),$(shell git log --format="%ct" -n 1))
BUILD_BRANCH := $(if $(BUILD_BRANCH),$(BUILD_BRANCH),$(shell git rev-parse --abbrev-ref HEAD))
BUILD_TIME := $(if $(BUILD_TIME),$(BUILD_TIME),$(shell date +%FT%T%z))
BUILD_MACHINE := $(if $(BUILD_MACHINE),$(BUILD_MACHINE),$(shell uname -n -m -r -s))
BUILD_GO_VERSION := $(if $(BUILD_GO_VERSION),$(BUILD_GO_VERSION),$(shell go version | cut -d' ' -f3))
BUILD_GO_VERSION := $(if $(BUILD_GO_VERSION),$(BUILD_GO_VERSION),$(shell $(GO) version | cut -d' ' -f3))

COMMON_BUILD_VARS := \
-X 'github.com/vkcom/tl/pkg/build.buildTimestamp=$(BUILD_TIME)' \
Expand All @@ -16,8 +18,6 @@ COMMON_BUILD_VARS := \

COMMON_LDFLAGS = $(COMMON_BUILD_VARS) -extldflags '-O2'

GO = go

TEST_PATH := internal/tlcodegen/test
TLS_PATH := $(TEST_PATH)/tls
GEN_PATH := $(TEST_PATH)/gen
Expand All @@ -32,12 +32,6 @@ all: build
build:
@$(GO) build -ldflags "$(COMMON_LDFLAGS)" -buildvcs=false -o target/bin/tlgen ./cmd/tlgen


.PHONY: test
test:
@$(GO) test $(shell go list ./... | grep -v internal/tlcodegen/test/gen/)


tlo-bootstrap: build
@./target/bin/tlgen -v --language=go \
--copyrightPath=./COPYRIGHT \
Expand Down Expand Up @@ -161,8 +155,11 @@ cpp:
$(MAKE) cpp_build


.PHONY: test
test:
@$(GO) test $(shell $(GO) list ./... | grep -v internal/tlcodegen/test/gen/)

# target should be as close as possible to github actions used to enable merge
.PHONY: check
check: build
@go test $(shell go list ./cmd/... ./internal/... ./pkg/... | grep -v /internal/tlcodegen/test/gen/)
@go run honnef.co/go/tools/cmd/[email protected] ./... # update version together with github actions
check: build test
@$(GO) run honnef.co/go/tools/cmd/[email protected] ./... # update version together with github actions
13 changes: 10 additions & 3 deletions cmd/tlgen/main2.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ func runMain(opt *tlcodegen.Gen2Options) error {
return fmt.Errorf("error while walkking through paths: %w", err)
}
for _, path := range paths {
tl, err := parseTlFile(path, false, opt)
tl, err := parseTlFile(path, true, opt)
if err != nil {
return err
}
fullTl, err := parseTlFile(path, true, opt)
fullTl, err := parseTlFile(path, false, opt)
if err != nil {
return err
}
Expand Down Expand Up @@ -197,10 +197,17 @@ func parseTlFile(file string, replaceStrange bool, opt *tlcodegen.Gen2Options) (
dataStr = strings.ReplaceAll(dataStr, "_ {X:Type} result:X = ReqResult X;", "")
dataStr = strings.ReplaceAll(dataStr, "engine.query {X:Type} query:!X = engine.Query;", "")
dataStr = strings.ReplaceAll(dataStr, "engine.queryShortened query:%(VectorTotal int) = engine.Query;", "")
// dataStr = strings.ReplaceAll(dataStr, "engine.queryShortened query:%(VectorTotal int) = engine.Query;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any @internal engine.sendResponseTo {X:Type} pid:%net.Pid query:!X = Bool;", "")
// dataStr = strings.ReplaceAll(dataStr, "@internal @write messages.responseQuery {X:Type} response_query_id:long query:!X = X;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any rpcDestActor#7568aabd {X:Type} actor_id:long query:!X = X;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any rpcDestActorFlags#f0a5acf7 {X:Type} actor_id:long flags:# extra:%(RpcInvokeReqExtra flags) query:!X = X;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any rpcDestFlags#e352035e {X:Type} flags:# extra:%(RpcInvokeReqExtra flags) query:!X = X;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any rpcInvokeReq#2374df3d {X:Type} query_id:long query:!X = RpcReqResult X;", "")
}
tl, err := tlast.ParseTLFile(dataStr, file, tlast.LexerOptions{
AllowBuiltin: false,
AllowDirty: false,
AllowDirty: !replaceStrange,
AllowMLC: !opt.WarningsAreErrors,
}, opt.ErrorWriter)
if err != nil {
Expand Down
11 changes: 7 additions & 4 deletions internal/tlcodegen/tlgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,13 @@ func (gen *Gen2) buildMapDescriptors(tl tlast.TL) error {
gen.typeDescriptors[typeName] = append(gen.typeDescriptors[typeName], typ)
}
} else {
if len(typ.TemplateArguments) != 0 {
// @read funWithArg {fields_mask: #} => True;
pr := typ.TemplateArgumentsPR
return pr.BeautifulError(fmt.Errorf("function declaration %q cannot have template arguments", conName))
for _, t := range typ.TemplateArguments {
if t.IsNat {
// @read funWithArg {fields_mask: #} => True;
return t.PR.BeautifulError(fmt.Errorf("function declaration %q cannot have template arguments", conName))
}
// TODO - sort out things with rpc wrapping later which has a form
// @readwrite tree_stats.preferMaster {X:Type} query:!X = X;
}
if len(typ.Modifiers) == 0 && doLint(typ.CommentRight) {
e1 := typ.Construct.NamePR.CollapseToBegin().BeautifulError(fmt.Errorf("function constructor %q without modifier (identifier starting with '@') not recommended", typ.Construct.Name.String()))
Expand Down
Loading