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

Move from File-Level to Pacakge-Level Parsing for Improved Linting #130

Open
notJoon opened this issue Feb 8, 2025 · 0 comments
Open

Move from File-Level to Pacakge-Level Parsing for Improved Linting #130

notJoon opened this issue Feb 8, 2025 · 0 comments
Labels
good first issue Good for newcomers L-performance Lint: performance T-engine Type: related with engine (or internal)

Comments

@notJoon
Copy link
Contributor

notJoon commented Feb 8, 2025

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:

  1. Reduced Accuracy:
    • Parsing files in isolation can miss important cross-file references and package-level contexts.
  2. 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

  1. 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.
  2. 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.
  3. 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.

@notJoon notJoon added good first issue Good for newcomers L-performance Lint: performance T-engine Type: related with engine (or internal) labels Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers L-performance Lint: performance T-engine Type: related with engine (or internal)
Projects
None yet
Development

No branches or pull requests

1 participant