Last active
December 2, 2024 12:57
-
-
Save pfitzseb/22493b0214276d3b65833232aa94bf11 to your computer and use it in GitHub Desktop.
Lint a Julia project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using LanguageServer, StaticLint, SymbolServer | |
path = abspath(ARGS[1]) | |
root_file = if length(ARGS) > 1 | |
abspath(ARGS[2]) | |
else | |
joinpath(path, "src", string(basename(path), ".jl")) | |
end | |
s = LanguageServerInstance(Pipe(), stdout, path) | |
_, symbols = SymbolServer.getstore(s.symbol_server, path) | |
s.global_env.symbols = symbols | |
s.global_env.extended_methods = SymbolServer.collect_extended_methods(s.global_env.symbols) | |
s.global_env.project_deps = collect(keys(s.global_env.symbols)) | |
f = StaticLint.loadfile(s, root_file) | |
StaticLint.semantic_pass(LanguageServer.getroot(f)) | |
for doc in LanguageServer.getdocuments_value(s) | |
StaticLint.check_all(LanguageServer.getcst(doc), s.lint_options, LanguageServer.getenv(doc, s)) | |
LanguageServer.mark_errors(doc, doc.diagnostics) | |
foreach(println, doc.diagnostics) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx for the script. I wondered, how I can use it for a whole project.
I guess I would include the main script, i.e.
src/MyPackage.jl
asroot_file
and thepath
is where the package is. However, I get e.g.┌ Warning: Mocking not stored on disc
and thenLanguageServer.Diagnostic(LanguageServer.Range(LanguageServer.Position(89, 16), LanguageServer.Position(89, 21)), 2, missing, missing, "Julia", "Missing reference: @mock", missing, missing)
.