Home

Awesome

StaticLint

Dev Project Status: Active - The project has reached a stable, usable state and is being actively developed. codecov.io

Static Code Analysis for Julia

Installation and Usage

using Pkg
Pkg.add("StaticLint")
using StaticLint

Documentation: Dev

Description

This package supports LanguageServer.jl functionality broadly by:

  1. linking the file tree of a project
  2. marking scopes/namespaces within the syntax tree (ST)
  3. marking variable bindings (functions, instances, etc.)
  4. linking identifiers (i.e. variable names) to the relevant bindings
  5. marking possible errors within the ST

Identifying and marking errors (5.) is, in general, dependent on steps 1-4. These are achieved through a single pass over the ST of a project. A pass over a single EXPR is achieved through calling a State object on the ST. This State requires an AbstractServer that determines how files within a project are loaded and makes packages available for loading.

Passes

For a given expression x this pass will:

Server

As mentioned, an AbstractServer is required to hold files within a project and provide access to user installed packages. An implementation must support the following functions:

StaticLint.hasfile(server, path)::Bool : Does the server have a file matching the name path.

StaticLint.getfile(server, path)::AbstractFile : Retrieves the file path - assumes the server has the file.

StaticLint.setfile(server, path, file)::AbstractFile : Stores file in the server under the name path, returning the file.

StaticLint.canloadfile(server, path)::Bool : Can the server load the file denoted by path, likely from an external source.

StaticLint.loadfile(server, path)::AbstractFile : Load the file at path from an external source (i.e. the hard drive).

StaticLint.getsymbolserver(server)::Dict{String,SymbolServer.ModuleStore} : Retrieve the server's depot of loadable packages.

An AbstractFile must support the following:

StaticLint.getpath(file) : Retrieve the path of a file.

StaticLint.getroot(file) : Retrieve the root of a file. The root is the main/first file in a file structure. For example the StaticLint.jl file is the root of all files (including itself) in src/.

StaticLint.setroot(file, root) : Set the root of a file.

StaticLint.getcst(file) : Retrieve the cst of a file.

StaticLint.setcst(file, cst::CSTParser.EXPR) : Set the cst of a file.

StaticLint.getserver(file) : Retrieve the server holding of a file.

StaticLint.setserver(file, server::AbstractServer) : Set the server of a file.

StaticLint.semantic_pass(file, target = nothing(optional)) : Run a full pass on the ST of a project (i.e. ST of all linked files). It is expected that file is the root of the project.