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

Remove some unused functions #111628

Merged
merged 1 commit into from Aug 2, 2022
Merged

Remove some unused functions #111628

merged 1 commit into from Aug 2, 2022

Conversation

thockin
Copy link
Member

@thockin thockin commented Aug 2, 2022

We really should have a tool that check for this on internal (unsupported for external users, not staging/...) pkgs.

I found these by accident - I guarantee there are more.

/kind cleanup

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 2, 2022
@k8s-ci-robot
Copy link
Contributor

@thockin: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Aug 2, 2022
@thockin thockin added the sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. label Aug 2, 2022
@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 2, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 2, 2022
@aojea
Copy link
Member

aojea commented Aug 2, 2022

why the linter unused is not flagging them?

- unused

it seems there is a private copy here

// nodeSelectorRequirementsAsSelector converts the []NodeSelectorRequirement api type into a struct that implements
// labels.Selector.
func nodeSelectorRequirementsAsSelector(nsm []v1.NodeSelectorRequirement, path *field.Path) (labels.Selector, []error) {

@aojea
Copy link
Member

aojea commented Aug 2, 2022

/lgtm

double checked

$ grep -r NodeSelectorRequirementsAsSelector
pkg/apis/core/helper/helpers_test.go:func TestNodeSelectorRequirementsAsSelector(t *testing.T) {
pkg/apis/core/helper/helpers_test.go:           out, err := NodeSelectorRequirementsAsSelector(tc.in)
pkg/apis/core/helper/helpers.go:// NodeSelectorRequirementsAsSelector converts the []NodeSelectorRequirement core type into a struct that implements
pkg/apis/core/helper/helpers.go:func NodeSelectorRequirementsAsSelector(nsm []core.NodeSelectorRequirement) (labels.Selector, error) {
staging/src/k8s.io/component-helpers/scheduling/corev1/nodeaffinity/nodeaffinity_test.go:func TestNodeSelectorRequirementsAsSelector(t *testing.T) {
$ grep -r NodeSelectorRequirementsAsFieldSelector
pkg/apis/core/helper/helpers.go:// NodeSelectorRequirementsAsFieldSelector converts the []NodeSelectorRequirement core type into a struct that implements
pkg/apis/core/helper/helpers.go:func NodeSelectorRequirementsAsFieldSelector(nsm []core.NodeSelectorRequirement) (fields.Selector, error) {

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 2, 2022
@k8s-ci-robot k8s-ci-robot merged commit 6ce72e1 into kubernetes:master Aug 2, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone Aug 2, 2022
@Abirdcfly
Copy link
Member

Let me try to explain, I'm not very familiar with https://github.com/dominikh/go-tools, please correct me if I'm wrong.


why the linter unused is not flagging them?

Because this pr deleted function is an exported function.

The linter unused uses internally is https://github.com/dominikh/go-tools/blob/master/unused/unused.go, It has some internal rules, such as treating the exported functions as having used, see https://github.com/dominikh/go-tools/blob/14865dd2a6230e8794e7a91ddcab515999bd50c6/unused/unused.go#L48-L154 for full description.


it seems there is a private copy here

There is something not quite the same, at least one more function parameter in private copy.


We really should have a tool that check for this on internal (unsupported for external users, not staging/...) pkgs.

Through my quick search, there doesn't seem to be such a tool readily available at the moment.

BTW, are we sure we don't guarantee the compatibility of the exported functions in the non-staging folder?

@thockin
Copy link
Member Author

thockin commented Aug 2, 2022

non-staging is effectively internal and we DO NOT make API guarantees there. We just can't.

@thockin
Copy link
Member Author

thockin commented Aug 2, 2022

It would be nice to have a tool that found "likely candidates" and let humans verify later.

@Abirdcfly
Copy link
Member

Create #111666 for discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants