Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if name is similar to existing package? #292

Open
ericphanson opened this issue May 9, 2021 · 6 comments
Open

check if name is similar to existing package? #292

ericphanson opened this issue May 9, 2021 · 6 comments
Labels
help wanted new-feature A proposed feature (which is not a new plugin)

Comments

@ericphanson
Copy link
Contributor

ericphanson commented May 9, 2021

One can use

using RegistryCI
using RegistryCI.AutoMerge
function is_far_from_existing_names(name)
    path_to_registry = joinpath(DEPOT_PATH[1], "registries", "General")
    all_pkg_names = AutoMerge.get_all_non_jll_package_names(path_to_registry)
    return AutoMerge.meets_distance_check(name, all_pkg_names)
end

to check if a proposed package name will pass AutoMerge's check about package names (as documented in the General registry's README, https://github.com/JuliaRegistries/General#automatic-merging-of-pull-requests).

I thought it could be helpful if PkgTemplates (perhaps optionally) runs this check at package-creation time. It could also support multiple registries (although obviously AutoMerge for General only looks at General, it can still be good to know if there are similar names in another registry you are using), e.g.

using RegistryCI
using RegistryCI.AutoMerge
function is_far_from_existing_names(name)
    names = String[]
    for registry in readdir(joinpath(DEPOT_PATH[1], "registries"); join=true)
        append!(names, AutoMerge.get_all_non_jll_package_names(registry))
    end
    return AutoMerge.meets_distance_check(name, names)
end

(Perhaps we should add a real API for this in RegistryCI though, if it's going to be used programatically)

@ericphanson ericphanson changed the title check if name is similar to existing package check if name is similar to existing package? May 9, 2021
@nickrobinson251
Copy link
Collaborator

nickrobinson251 commented May 9, 2021

I think this would be a good addition! On first thought, id say this check should always run (assuming it's fast enough) but only be a warning.

Also I'd prefer RegistryCI have an API for this, so we can guarantee to always do what that does.

@nickrobinson251 nickrobinson251 added the new-feature A proposed feature (which is not a new plugin) label May 9, 2021
@christopher-dG
Copy link
Member

I'll note that having RegistryCI as a dependency of this package is rather unappealing... but I do like the idea.

@DilumAluthge
Copy link
Member

RegistryCI is a very heavy package with a lot of dependencies.

@ericphanson Maybe we could refactor the name-checking functionality out into a small package, e.g. JuliaRegistries/NameSquattingChecker.jl. Then RegistryCI.jl and PkgTemplates.jl would both depend on NameSquattingChecker.jl.

@ericphanson
Copy link
Contributor Author

Good point about the dependency. The name checking code actually isn’t super light because it uses various not-totally-trivial distance measures. The code in RegistryCI uses VisualStringDistances (which uses UnbalancedOptimalTransport and StaticArrays, but those only have stdlibs deps themselves) and StringDistances (which uses Distances and StatsAPI, and those just use each other and stdlibs). So even just the name checking code is 6 total dependencies + stdlibs. So I totally get if that’s too many for PkgTemplates.

Also, while it’s pretty fast, it’s not instant; it can take a couple seconds which is a noticeable lag for interactive stuff. That’s because of the visual distance. (Every new package registration involves solving 100s of optimization problems comparing pixelated grids representing the names, in pure Julia, in CI, since it was introduced like 6 months ago, with no issues so far 😎)

@DilumAluthge
Copy link
Member

You know what could be cool? What if JuliaHub had a feature in which you put in a prospective package name, and then JuliaHub runs the name checking code for you? So then we don't need to add any dependencies to PkgTemplates.

@StefanKarpinski @ViralBShah

@gdalle
Copy link
Collaborator

gdalle commented Jul 31, 2023

This could go into #360 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted new-feature A proposed feature (which is not a new plugin)
Projects
None yet
Development

No branches or pull requests

5 participants