Documentation
¶
Index ¶
- Variables
- func GetEscapedCommentIdentifierFromPath(path string) string
- func IssueAsTextFromJson(jsonData []byte) ([]byte, error)
- func Preorder(pass *Pass, fn func(*sitter.Node))
- func ReportIssues(issues []*Issue, format string) ([]byte, error)
- func RunAnalyzerTests(testDir string, analyzers []*Analyzer) (string, string, bool, error)
- type Analyzer
- type Category
- type Issue
- type Language
- type ParseResult
- type Pass
- type Severity
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnsupportedLanguage = fmt.Errorf("unsupported language")
ParseFile parses the file at the given path using the appropriate tree-sitter grammar.
Functions ¶
func GetEscapedCommentIdentifierFromPath ¶ added in v0.3.0
func IssueAsTextFromJson ¶ added in v0.3.0
Types ¶
type Issue ¶
type Issue struct {
// The category of the issue
Category Category
// The severity of the issue
Severity Severity
// The message to display to the user
Message string
// The file path of the file that the issue was found in
Filepath string
// (optional) The AST node that caused the issue
Node *sitter.Node
// Id is a unique ID for the issue.
// Issue that have 'Id's can be explained using the `globstar desc` command.
Id *string
}
func IssueFromJson ¶ added in v0.3.0
type Language ¶
type Language int
const ( LangUnknown Language = iota LangPy LangJs // vanilla JS and JSX LangTs // TypeScript (not TSX) LangTsx // TypeScript with JSX extension LangJava LangRuby LangRust LangYaml LangCss LangDockerfile LangMarkdown LangSql LangKotlin LangOCaml LangLua LangBash LangCsharp LangElixir LangElm LangGo LangGroovy LangHcl LangHtml LangPhp LangScala LangSwift )
func LanguageFromFilePath ¶
LanguageFromFilePath returns the Language of the file at the given path returns `LangUnkown` if the language is not recognized (e.g: `.txt` files).
type ParseResult ¶
type ParseResult struct {
// Ast is the root node of the tree-sitter parse-tree
// representing this file
Ast *sitter.Node
// Source is the raw source code of the file
Source []byte
// FilePath is the path to the file that was parsed
FilePath string
// Language is the tree-sitter language used to parse the file
TsLanguage *sitter.Language
// Language is the language of the file
Language Language
}
ParseResult is the result of parsing a file.
func ParseFile ¶
func ParseFile(filePath string) (*ParseResult, error)
type Pass ¶
type Pass struct {
Analyzer *Analyzer
FileContext *ParseResult
Files []*ParseResult
Report func(*Pass, *sitter.Node, string)
}
Click to show internal directories.
Click to hide internal directories.