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

add private packages to no_index metadata #1380

Merged
merged 1 commit into from
Jul 9, 2019
Merged

add private packages to no_index metadata #1380

merged 1 commit into from
Jul 9, 2019

Conversation

Grinnz
Copy link
Contributor

@Grinnz Grinnz commented Jul 9, 2019

Summary

Prevent private packages from being indexed.

Motivation

Packages starting with _ are not intended to be externally used or depended on, so they have no reason to be indexed on CPAN.

An alternative method is to put a newline after the 'package' keyword so PAUSE will ignore these packages, but this requires an exception for perltidy.

@Grinnz
Copy link
Contributor Author

Grinnz commented Jul 9, 2019

Calling for a vote from @mojolicious/core to gauge interest.

@kraih
Copy link
Member

kraih commented Jul 9, 2019

I think this is the most indifferent i have ever felt about a patch. 😐

@christopherraa
Copy link
Member

christopherraa commented Jul 9, 2019

Asking just so I understand: is this change proposed because CPAN can (or won't?) skip indexing _-prefixed packages?

@kraih kraih added the vote label Jul 9, 2019
@Grinnz
Copy link
Contributor Author

Grinnz commented Jul 9, 2019

Correct, PAUSE currently does not care about _ prefixes on package names.

@Grinnz
Copy link
Contributor Author

Grinnz commented Jul 9, 2019

The alternative approach does seem workable with perltidy, so it is opened at #1381

@kraih
Copy link
Member

kraih commented Jul 9, 2019

After #1381, i suddenly feel much less indifferent about this one. 🤣

@christopherraa
Copy link
Member

From what I have understood so far the situation is this:

  • it is assumed but not enforced that _-prefixed packages should not be indexed
  • it does not present problems that they do get indexed
  • the fix is either cosmetically dubious code, changes that requires perltidy-changes or the Makefile.PL-change

Given the above I would rather see the changes in the Makefile.PL if I had to choose, but overall I am 👎 to this change as I do not see why indexing _-prefixed packages is a problem. Feel free to enlighten me. :)

@Grinnz
Copy link
Contributor Author

Grinnz commented Jul 9, 2019

It's not an explicit problem. It (being indexed on CPAN) could be considered an implicit indication that these packages can be used or depended on, which is not the case.

@genio
Copy link
Contributor

genio commented Jul 9, 2019

If you have any secondary packages within an actual module, you do not want to index those modules as you would not be able to use them directly from any application. So, it's best practice to hide inner packages/classes from PAUSE so that people don't try to do the wrong thing.

package Foo;
use strict;

{
  package Foo::Inner;
  use strict;
  sub whatever { return 42 }
}

sub new {
  my $self = bless {}, shift;
  $self->{_something} = "bar";
  return $self;
}

sub foo { return Foo::Inner::whatever }
1;

Now, in a script, I should be able to find Foo but not Foo::Inner.

#!/usr/bin/env perl
use strict;
use warnings;
use Foo;
my $foo = Foo->new();
print $foo->foo; # yay
#!/usr/bin/env perl
use strict;
use warnings;
use Foo::Inner; # kaboom

print Foo::Inner::whatever;

Since PAUSE will index that by default, it will show up as something shipped in your distribution. You should hide these from PAUSE so people aren't going to try that second script example.

package # hide from PAUSE
  Foo::Inner;

@Grinnz
Copy link
Contributor Author

Grinnz commented Jul 9, 2019

Note that #1381 will additionally hide the packages from the metacpan release page, while this PR will not.

@christopherraa
Copy link
Member

Thank you for a good example. That helped my understanding. Considering the example I'm neutral to this change as this does not require changes to code like shown in #1381 .

@kraih kraih merged commit ca766cb into master Jul 9, 2019
@Grinnz Grinnz deleted the no_index_private branch July 9, 2019 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants