diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a6b3afd..69a5dedc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- `test_stale_deps` is renamed to `test_unused_deps`. ([#270](https://github.com/JuliaTesting/Aqua.jl/pull/270)) + + ## [0.8.4] - 2023-12-01 ### Added diff --git a/README.md b/README.md index 41752296..2d69ba71 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Aqua.jl provides functions to run a few automatable checks for Julia packages: * There are no method ambiguities. * There are no undefined `export`s. * There are no unbound type parameters. -* There are no stale dependencies listed in `Project.toml`. +* There are no unused dependencies listed in `Project.toml`. * Check that test target of the root project `Project.toml` and test project (`test/Project.toml`) are consistent. * Check that all external packages listed in `deps` have corresponding `compat` entries. * There are no "obvious" type piracies. diff --git a/docs/make.jl b/docs/make.jl index 27f2d5b4..f1304083 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -10,7 +10,7 @@ makedocs(; "unbound_args.md", "exports.md", "project_extras.md", - "stale_deps.md", + "unused_deps.md", "deps_compat.md", "piracies.md", "persistent_tasks.md", diff --git a/docs/src/index.md b/docs/src/index.md index 22509efc..8cb086d2 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -5,7 +5,7 @@ Aqua.jl provides functions to run a few automatable checks for Julia packages: * There are no method ambiguities. * There are no undefined `export`s. * There are no unbound type parameters. -* There are no stale dependencies listed in `Project.toml`. +* There are no unused dependencies listed in `Project.toml`. * Check that test target of the root project `Project.toml` and test project (`test/Project.toml`) are consistent. * Check that all external packages listed in `deps` have corresponding `compat` entries. * There are no "obvious" type piracies. @@ -75,7 +75,7 @@ using Aqua Aqua.test_all( YourPackage; ambiguities=(exclude=[SomePackage.some_function], broken=true), - stale_deps=(ignore=[:SomePackage],), + unused_deps=(ignore=[:SomePackage],), deps_compat=(ignore=[:SomeOtherPackage],), piracies=false, ) diff --git a/docs/src/stale_deps.md b/docs/src/stale_deps.md deleted file mode 100644 index f33f9819..00000000 --- a/docs/src/stale_deps.md +++ /dev/null @@ -1,7 +0,0 @@ -# Stale dependencies - -## [Test function](@id test_stale_deps) - -```@docs -Aqua.test_stale_deps -``` diff --git a/docs/src/unused_deps.md b/docs/src/unused_deps.md new file mode 100644 index 00000000..0aefc7f7 --- /dev/null +++ b/docs/src/unused_deps.md @@ -0,0 +1,7 @@ +# Unused dependencies + +## [Test function](@id test_unused_deps) + +```@docs +Aqua.test_unused_deps +``` diff --git a/src/Aqua.jl b/src/Aqua.jl index 50f6b532..ab277edd 100644 --- a/src/Aqua.jl +++ b/src/Aqua.jl @@ -19,7 +19,7 @@ include("ambiguities.jl") include("unbound_args.jl") include("exports.jl") include("project_extras.jl") -include("stale_deps.jl") +include("unused_deps.jl") include("deps_compat.jl") include("piracies.jl") include("persistent_tasks.jl") @@ -33,7 +33,7 @@ Run the following tests: * [`test_unbound_args(testtarget)`](@ref test_unbound_args) * [`test_undefined_exports(testtarget)`](@ref test_undefined_exports) * [`test_project_extras(testtarget)`](@ref test_project_extras) -* [`test_stale_deps(testtarget)`](@ref test_stale_deps) +* [`test_unused_deps(testtarget)`](@ref test_unused_deps) * [`test_deps_compat(testtarget)`](@ref test_deps_compat) * [`test_piracies(testtarget)`](@ref test_piracies) * [`test_persistent_tasks(testtarget)`](@ref test_persistent_tasks) @@ -48,7 +48,7 @@ passed to `\$x` to specify the keyword arguments for `test_\$x`. - `unbound_args = true` - `undefined_exports = true` - `project_extras = true` -- `stale_deps = true` +- `unused_deps = true` - `deps_compat = true` - `piracies = true` - `persistent_tasks = true` @@ -59,7 +59,7 @@ function test_all( unbound_args = true, undefined_exports = true, project_extras = true, - stale_deps = true, + unused_deps = true, deps_compat = true, piracies = true, persistent_tasks = true, @@ -85,9 +85,9 @@ function test_all( test_project_extras(testtarget) end end - @testset "Stale dependencies" begin - if stale_deps !== false - test_stale_deps(testtarget; askwargs(stale_deps)...) + @testset "Unused dependencies" begin + if unused_deps !== false + test_unused_deps(testtarget; askwargs(unused_deps)...) end end @testset "Compat bounds" begin diff --git a/src/stale_deps.jl b/src/unused_deps.jl similarity index 70% rename from src/stale_deps.jl rename to src/unused_deps.jl index 6571db9c..7652c1f2 100644 --- a/src/stale_deps.jl +++ b/src/unused_deps.jl @@ -1,5 +1,5 @@ """ - Aqua.test_stale_deps(package; [ignore]) + Aqua.test_unused_deps(package; [ignore]) Test that `package` loads all dependencies listed in `Project.toml`. Note that this does not imply that `package` loads the dependencies @@ -14,7 +14,7 @@ directly, this can be achieved via transitivity as well. !!! warning "Known bug" - Currently, `Aqua.test_stale_deps` does not detect stale + Currently, `Aqua.test_unused_deps` does not detect unused dependencies when they are in the sysimage. This is considered a bug and may be fixed in the future. Such a release is considered non-breaking. @@ -26,23 +26,23 @@ directly, this can be achieved via transitivity as well. # Keyword Arguments - `ignore::Vector{Symbol}`: names of dependent packages to be ignored. """ -function test_stale_deps(pkg::PkgId; kwargs...) - stale_deps = find_stale_deps(pkg; kwargs...) - @test isempty(stale_deps) +function test_unused_deps(pkg::PkgId; kwargs...) + unused_deps = find_unused_deps(pkg; kwargs...) + @test isempty(unused_deps) end -function test_stale_deps(mod::Module; kwargs...) - test_stale_deps(aspkgid(mod); kwargs...) +function test_unused_deps(mod::Module; kwargs...) + test_unused_deps(aspkgid(mod); kwargs...) end # Remove in next breaking release -function test_stale_deps(packages::Vector{<:Union{Module,PkgId}}; kwargs...) +function test_unused_deps(packages::Vector{<:Union{Module,PkgId}}; kwargs...) @testset "$pkg" for pkg in packages - test_stale_deps(pkg; kwargs...) + test_unused_deps(pkg; kwargs...) end end -function find_stale_deps(pkg::PkgId; ignore::AbstractVector{Symbol} = Symbol[]) +function find_unused_deps(pkg::PkgId; ignore::AbstractVector{Symbol} = Symbol[]) root_project_path, found = root_project_toml(pkg) found || error("Unable to locate Project.toml") @@ -66,7 +66,7 @@ function find_stale_deps(pkg::PkgId; ignore::AbstractVector{Symbol} = Symbol[]) output = output[pos.stop+1:end] loaded_uuids = map(UUID, eachline(IOBuffer(output))) - return find_stale_deps_2(; + return find_unused_deps_2(; deps = deps, weakdeps = weakdeps, loaded_uuids = loaded_uuids, @@ -74,8 +74,8 @@ function find_stale_deps(pkg::PkgId; ignore::AbstractVector{Symbol} = Symbol[]) ) end -# Side-effect -free part of stale dependency analysis. -function find_stale_deps_2(; +# Side-effect -free part of unused dependency analysis. +function find_unused_deps_2(; deps::AbstractVector{PkgId}, weakdeps::AbstractVector{PkgId}, loaded_uuids::AbstractVector{UUID}, @@ -84,10 +84,10 @@ function find_stale_deps_2(; deps_uuids = [p.uuid for p in deps] pkgid_from_uuid = Dict(p.uuid => p for p in deps) - stale_uuids = setdiff(deps_uuids, loaded_uuids) - stale_pkgs = [pkgid_from_uuid[uuid] for uuid in stale_uuids] - stale_pkgs = setdiff(stale_pkgs, weakdeps) - stale_pkgs = [p for p in stale_pkgs if !(Symbol(p.name) in ignore)] + unused_uuids = setdiff(deps_uuids, loaded_uuids) + unused_pkgs = [pkgid_from_uuid[uuid] for uuid in unused_uuids] + unused_pkgs = setdiff(unused_pkgs, weakdeps) + unused_pkgs = [p for p in unused_pkgs if !(Symbol(p.name) in ignore)] - return stale_pkgs + return unused_pkgs end diff --git a/test/test_smoke.jl b/test/test_smoke.jl index 599677f2..66c32b5b 100644 --- a/test/test_smoke.jl +++ b/test/test_smoke.jl @@ -5,7 +5,7 @@ using Aqua # test defaults Aqua.test_all( Aqua; - stale_deps = (; ignore = [:Compat]), # conditionally loaded + unused_deps = (; ignore = [:Compat]), # conditionally loaded ) # test everything else @@ -15,7 +15,7 @@ Aqua.test_all( unbound_args = false, undefined_exports = false, project_extras = false, - stale_deps = false, + unused_deps = false, deps_compat = false, piracies = false, persistent_tasks = false, diff --git a/test/test_stale_deps.jl b/test/test_unused_deps.jl similarity index 82% rename from test/test_stale_deps.jl rename to test/test_unused_deps.jl index 9ec84b01..6f8ab9f4 100644 --- a/test/test_stale_deps.jl +++ b/test/test_unused_deps.jl @@ -1,10 +1,10 @@ -module TestStaleDeps +module TestUnusedDeps include("preamble.jl") using Base: PkgId, UUID -using Aqua: find_stale_deps_2 +using Aqua: find_unused_deps_2 -@testset "find_stale_deps_2" begin +@testset "find_unused_deps_2" begin pkg = PkgId(UUID(42), "TargetPkg") dep1 = PkgId(UUID(1), "Dep1") @@ -12,7 +12,7 @@ using Aqua: find_stale_deps_2 dep3 = PkgId(UUID(3), "Dep3") @testset "pass" begin - result = find_stale_deps_2(; + result = find_unused_deps_2(; deps = PkgId[], weakdeps = PkgId[], loaded_uuids = UUID[], @@ -20,7 +20,7 @@ using Aqua: find_stale_deps_2 ) @test isempty(result) - result = find_stale_deps_2(; + result = find_unused_deps_2(; deps = PkgId[dep1], weakdeps = PkgId[], loaded_uuids = UUID[dep1.uuid, dep2.uuid, dep3.uuid], @@ -28,7 +28,7 @@ using Aqua: find_stale_deps_2 ) @test isempty(result) - result = find_stale_deps_2(; + result = find_unused_deps_2(; deps = PkgId[dep1], weakdeps = PkgId[], loaded_uuids = UUID[dep2.uuid, dep3.uuid], @@ -36,7 +36,7 @@ using Aqua: find_stale_deps_2 ) @test isempty(result) - result = find_stale_deps_2(; + result = find_unused_deps_2(; deps = PkgId[dep1], weakdeps = PkgId[dep2], loaded_uuids = UUID[dep1.uuid], @@ -44,7 +44,7 @@ using Aqua: find_stale_deps_2 ) @test isempty(result) - result = find_stale_deps_2(; + result = find_unused_deps_2(; deps = PkgId[dep1, dep2], weakdeps = PkgId[dep2], loaded_uuids = UUID[dep1.uuid], @@ -52,7 +52,7 @@ using Aqua: find_stale_deps_2 ) @test isempty(result) - result = find_stale_deps_2(; + result = find_unused_deps_2(; deps = PkgId[dep1, dep2], weakdeps = PkgId[dep2], loaded_uuids = UUID[], @@ -61,7 +61,7 @@ using Aqua: find_stale_deps_2 @test isempty(result) end @testset "failure" begin - result = find_stale_deps_2(; + result = find_unused_deps_2(; deps = PkgId[dep1], weakdeps = PkgId[], loaded_uuids = UUID[], @@ -70,7 +70,7 @@ using Aqua: find_stale_deps_2 @test length(result) == 1 @test dep1 in result - result = find_stale_deps_2(; + result = find_unused_deps_2(; deps = PkgId[dep1], weakdeps = PkgId[], loaded_uuids = UUID[dep2.uuid, dep3.uuid], @@ -79,7 +79,7 @@ using Aqua: find_stale_deps_2 @test length(result) == 1 @test dep1 in result - result = find_stale_deps_2(; + result = find_unused_deps_2(; deps = PkgId[dep1, dep2], weakdeps = PkgId[], loaded_uuids = UUID[dep3.uuid], @@ -93,7 +93,7 @@ end with_sample_pkgs() do @testset "Package without `deps`" begin pkg = AquaTesting.SAMPLE_PKG_BY_NAME["PkgWithoutDeps"] - results = Aqua.find_stale_deps(pkg) + results = Aqua.find_unused_deps(pkg) @test isempty(results) end end