Skip to content

Commit

Permalink
Add static_link and aqua verifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
orenbenkiki committed Apr 6, 2024
1 parent 3c5d366 commit f2f81fb
Show file tree
Hide file tree
Showing 40 changed files with 939 additions and 907 deletions.
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ deps/.format: */*.jl deps/format.sh deps/format.jl
@touch deps/.format

.PHONY: check
check: jet untested_lines
check: static_analysis jet aqua untested_lines

.PHONY: static_analysis
static_analysis: deps/.static_analysis

deps/.static_analysis: *.toml src/*.jl test/*.toml test/*.jl deps/static_analysis.sh deps/static_analysis.jl
deps/static_analysis.sh
@touch deps/.static_analysis

.PHONY: jet
jet: deps/.jet
Expand All @@ -30,6 +37,13 @@ deps/.jet: *.toml src/*.jl test/*.toml test/*.jl deps/jet.sh deps/jet.jl deps/je
deps/jet.sh
@touch deps/.jet

.PHONY: aqua
aqua: deps/.aqua

deps/.aqua: *.toml src/*.jl test/*.toml test/*.jl deps/aqua.sh deps/aqua.jl
deps/aqua.sh
@touch deps/.aqua

.PHONY: test
test: tracefile.info

Expand Down
25 changes: 7 additions & 18 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "59e7df362cbccf9b3489ca11436d43634605ed35"
project_hash = "8e03bb75bf6f51f8955793f4a225b42fdf673d0d"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -118,11 +118,6 @@ deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
version = "1.6.0"

[[deps.EnumX]]
git-tree-sha1 = "bdb1942cd4c45e3c678fd11569d5cccd80976237"
uuid = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
version = "1.0.4"

[[deps.ExprTools]]
git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
Expand All @@ -148,9 +143,9 @@ uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[[deps.HDF5]]
deps = ["Compat", "HDF5_jll", "Libdl", "MPIPreferences", "Mmap", "Preferences", "Printf", "Random", "Requires", "UUIDs"]
git-tree-sha1 = "26407bd1c60129062cec9da63dc7d08251544d53"
git-tree-sha1 = "e856eef26cf5bf2b0f95f8f4fc37553c72c8641c"
uuid = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
version = "0.17.1"
version = "0.17.2"

[deps.HDF5.extensions]
MPIExt = "MPI"
Expand All @@ -160,9 +155,9 @@ version = "0.17.1"

[[deps.HDF5_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "LibCURL_jll", "Libdl", "MPICH_jll", "MPIPreferences", "MPItrampoline_jll", "MicrosoftMPI_jll", "OpenMPI_jll", "OpenSSL_jll", "TOML", "Zlib_jll", "libaec_jll"]
git-tree-sha1 = "e4591176488495bf44d7456bd73179d87d5e6eab"
git-tree-sha1 = "6384c847ff5056c5624e30e75b3ca48902cae0ac"
uuid = "0234f1f7-429e-5d53-9886-15a909be8d59"
version = "1.14.3+1"
version = "1.14.3+2"

[[deps.Hwloc_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
Expand Down Expand Up @@ -266,12 +261,6 @@ version = "0.3.27"
[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[deps.LoggingExtras]]
deps = ["Dates", "Logging"]
git-tree-sha1 = "c1dd6d7978c12545b4179fb6153b9250c96b0075"
uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36"
version = "1.0.3"

[[deps.MPICH_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"]
git-tree-sha1 = "656036b9ed6f942d35e536e249600bc31d0f9df8"
Expand Down Expand Up @@ -459,9 +448,9 @@ version = "1.7.0"

[[deps.StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "1d77abd07f617c4868c33d4f5b9e1dbb2643c9cf"
git-tree-sha1 = "5cf7606d6cef84b543b483848d4ae08ad9832b21"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.34.2"
version = "0.34.3"

[[deps.StringManipulation]]
deps = ["PrecompileTools"]
Expand Down
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
Muon = "446846d7-b4ce-489d-bf74-72da18fe3629"
NamedArrays = "86f7a689-2022-50b4-a561-43c23ac3c673"
Expand Down
14 changes: 13 additions & 1 deletion deps/add_pkgs.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
using Pkg

for pkg in ("Coverage", "Documenter", "JET", "JuliaFormatter", "Logging", "LoggingExtras", "SnoopCompile")
for pkg in (
"Aqua",
"Coverage",
"Documenter",
"JET",
"JuliaFormatter",
"LanguageServer",
"Logging",
"LoggingExtras",
"SnoopCompile",
"StaticLint",
"SymbolServer",
)
println("Adding $(pkg):")
Pkg.add(pkg)
end
6 changes: 6 additions & 0 deletions deps/aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
push!(LOAD_PATH, ".")

using Aqua
using Daf
Aqua.test_ambiguities([Daf])
Aqua.test_all(Daf; ambiguities = false, unbound_args = false, deps_compat = false)
2 changes: 2 additions & 0 deletions deps/aqua.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
julia deps/aqua.jl
74 changes: 74 additions & 0 deletions deps/static_analysis.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using LanguageServer
using StaticLint
using SymbolServer

language_server = LanguageServerInstance(Pipe(), stdout, ".")
_, symbols = SymbolServer.getstore(language_server.symbol_server, ".")
language_server.global_env.symbols = symbols
language_server.global_env.extended_methods = SymbolServer.collect_extended_methods(language_server.global_env.symbols)
language_server.global_env.project_deps = collect(keys(language_server.global_env.symbols))

file = StaticLint.loadfile(language_server, abspath("src/Daf.jl"))
StaticLint.semantic_pass(LanguageServer.getroot(file))

global errors = 0
global skipped = 0
global unused = 0
for doc in LanguageServer.getdocuments_value(language_server)
StaticLint.check_all(
LanguageServer.getcst(doc),
language_server.lint_options,
LanguageServer.getenv(doc, language_server),
)
LanguageServer.mark_errors(doc, doc.diagnostics)
no_lint_lines = Set{Int}()
unused_no_lint_lines = Set{Int}()
for (line_number, line_text) in enumerate(readlines(doc._path))
if contains(line_text, "NOLINT")
push!(no_lint_lines, line_number)
push!(unused_no_lint_lines, line_number)
end
end
for diagnostic in doc.diagnostics
line_number = diagnostic.range.start.line + 1
character_number = diagnostic.range.start.character + 1
if line_number in no_lint_lines
delete!(unused_no_lint_lines, line_number)
global skipped
skipped += 1
else
println("$(doc._path):$(line_number):$(character_number): $(diagnostic.message)")
global errors
errors += 1
end
end
for line_number in sort(collect(unused_no_lint_lines))
global unused
unused += 1
println("$(doc._path):$(line_number): unused NOLINT directive)")
end
end

message = "StaticLint:"
separator = ""
if errors > 0
message *= " $(errors) errors"
separator = ","
end
if skipped > 0
message *= "$(separator) $(skipped) skipped"
separator = ","
end
if unused > 0
message *= "$(separator) $(unused) unused"
end

if errors + skipped + unused > 0
println(message)
else
println("StaticLint: clean!")
end

if errors + unused > 0
exit(1)
end
3 changes: 3 additions & 0 deletions deps/static_analysis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -e -o pipefail
julia deps/static_analysis.jl
2 changes: 1 addition & 1 deletion docs/v0.1.0/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-04-04T20:19:23","documenter_version":"1.3.0"}}
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-04-06T13:17:46","documenter_version":"1.3.0"}}
6 changes: 3 additions & 3 deletions src/adapters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function adapter(
end

function get_adapter_capture_name(view::Union{DafWriter, DafReadOnly}; name::Maybe{AbstractString})::AbstractString
_base, prefix = get_base(view, name)
_, prefix = get_base(view, name)
return prefix * ".capture"
end

Expand All @@ -126,7 +126,7 @@ function get_adapter_input(
name::Maybe{AbstractString},
writer::DafWriter,
)::DafWriter
_base, prefix = get_base(view, name)
_, prefix = get_base(view, name)
return chain_writer([view, writer]; name = "$(prefix).adapted")
end

Expand All @@ -153,7 +153,7 @@ function get_base(view::Union{DafWriter, DafReadOnly}, name::Maybe{AbstractStrin
@assert base isa DafWriter
end

if name == nothing
if name === nothing
prefix = base.name
else
prefix = name # untested
Expand Down
24 changes: 12 additions & 12 deletions src/anndata_format.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ function by_annotation(
name::AbstractString,
default::AbstractString,
)::AbstractString
if value == nothing
if value === nothing
value = get(adata.uns, name, default)
@assert value != nothing
@assert value !== nothing
end
return value
end
Expand Down Expand Up @@ -218,7 +218,7 @@ function verify_is_supported_type(
unsupported_handler::AbnormalHandler,
)::Nothing
if value isa StorageMatrix &&
major_axis(value) == nothing &&
major_axis(value) === nothing &&
!(value isa Muon.TransposedDataset) &&
!(value isa Muon.SparseDataset)
report_unsupported( # untested
Expand Down Expand Up @@ -332,11 +332,11 @@ function copy_supported_matrices(
end

function copy_supported_matrix( # untested
matrix::Any,
memory::MemoryDaf,
rows_axis::AbstractString,
columns_axis::AbstractString,
name::AbstractString,
::Any,
::MemoryDaf,
::AbstractString,
::AbstractString,
::AbstractString,
)::Nothing
return nothing
end
Expand Down Expand Up @@ -380,7 +380,7 @@ function copy_supported_matrix(
matrix = transpose(matrix)
rows_axis, columns_axis = columns_axis, rows_axis
end
if matrix_major_axis != nothing
if matrix_major_axis !== nothing
set_matrix!(memory, rows_axis, columns_axis, name, matrix; relayout = false)
end
end
Expand Down Expand Up @@ -459,7 +459,7 @@ function daf_as_anndata(

copy_matrices(daf, obs_is, var_is, X_is, adata.layers)

if h5ad != nothing
if h5ad !== nothing
writeh5ad(h5ad, adata; compress = UInt8(0)) # NOJET
end

Expand All @@ -472,9 +472,9 @@ function by_scalar(
name::AbstractString,
default::AbstractString,
)::AbstractString
if value == nothing
if value === nothing
value = get_scalar(daf, name; default = default)
@assert value != nothing
@assert value !== nothing
end
return value
end
Expand Down
Loading

0 comments on commit f2f81fb

Please sign in to comment.