Description
Currently, tlin's linting process handles .gno files by converting them into temporary .go files (see, prepareFile function) and parsing them one by one. This file-by-file approach has several drawbacks:
- Reduced Accuracy:
- Parsing files in isolation can miss important cross-file references and package-level contexts.
- Performance Overhead:
- Repeatedly creating temporary
.go files and parsing each file separately is inefficient.
- Analyzing multiple
.gno files within the same package context would reduce parsing overhead and improve overall speed.
Proposed Solution
-
Create a Temporary Directory Structure
- Instead of generating a single
.go temp file per .gno file, copy or convert all .gno files in a package into a temporary directory, renaming them with a .go extension.
- Preserve the directory/package structure so golangci-lint can parse them as it would standard go files.
-
Parse Using Package-Level APIs
- Switch from
go/parser.ParseFile (file-centric) to go/parser.ParseDir or similar package-level APIs to load all files in a directory at once.
- This allows cross-file symbol resolution and more accurate AST analysis.
-
Maintain nolint and Ignore Logic
- Ensure that
nolint comments and path ignores still apply correctly across multiple files within the package.
Note
Before proceeding with the task, benchmarks related to current file processing and parsing should be added first. Then the results should be compared after the modifications.
Description
Currently, tlin's linting process handles
.gnofiles by converting them into temporary.gofiles (see,prepareFilefunction) and parsing them one by one. This file-by-file approach has several drawbacks:.gofiles and parsing each file separately is inefficient..gnofiles within the same package context would reduce parsing overhead and improve overall speed.Proposed Solution
Create a Temporary Directory Structure
.gotemp file per.gnofile, copy or convert all.gnofiles in a package into a temporary directory, renaming them with a .go extension.Parse Using Package-Level APIs
go/parser.ParseFile(file-centric) togo/parser.ParseDiror similar package-level APIs to load all files in a directory at once.Maintain
nolintand Ignore Logicnolintcomments and path ignores still apply correctly across multiple files within the package.Note
Before proceeding with the task, benchmarks related to current file processing and parsing should be added first. Then the results should be compared after the modifications.