-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Cleanup: multiple unnecessarily exported methods #3262
Comments
@imjasonh If no one is working on this, I can take a stab at this issue. |
Great! It should be pretty straightforward, let me know if you have any questions or find any difficulties. |
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
Stale issues rot after 30d of inactivity. /lifecycle rotten Send feedback to tektoncd/plumbing. |
I think it still there :
the PR on #3327 is still open @vigneshashokan would you like to rebase it ? /remove-lifecycle rotten /assign @vigneshashokan |
/lifecycle frozen |
Fwiw, I'd change the
i.e., change the last |
fixes tektoncd#3262 There are a few things left, either by design or uncertainty: * `pkg/apis/pipeline/v1beta1/conversion_error.go`'s `ConvertErrorf` - I'm not entirely clear on whether this should be around or not. `CannotConvertError` is still used in tests in `pkg/apis/pipeline/v1alpha1`, and the whole thing is just messy enough that I'm not sure what to do. * `pkg/apis/pipeline/v1beta1/version_validation.go`'s `ValidateEnabledAPIFields` - it's referenced in `docs/developers/README.md` and I can't tell if that's something that could be intended to eb used in something depending on Tekton, not just in Tekton itself. * `pkg/pipelinerunmetrics/injection.go` and `pkg/taskrunmetrics/injection.go`'s `WithInformer` - these are both used as function references in their respective `.../fake/fake.go`s. Signed-off-by: Andrew Bayer <[email protected]>
fixes tektoncd#3262 There are a few things left, either by design or uncertainty: * `pkg/apis/pipeline/v1beta1/conversion_error.go`'s `ConvertErrorf` - I'm not entirely clear on whether this should be around or not. `CannotConvertError` is still used in tests in `pkg/apis/pipeline/v1alpha1`, and the whole thing is just messy enough that I'm not sure what to do. * `pkg/apis/pipeline/v1beta1/version_validation.go`'s `ValidateEnabledAPIFields` - it's referenced in `docs/developers/README.md` and I can't tell if that's something that could be intended to eb used in something depending on Tekton, not just in Tekton itself. * `pkg/pipelinerunmetrics/injection.go` and `pkg/taskrunmetrics/injection.go`'s `WithInformer` - these are both used as function references in their respective `.../fake/fake.go`s. Signed-off-by: Andrew Bayer <[email protected]>
fixes #3262 There are a few things left, either by design or uncertainty: * `pkg/apis/pipeline/v1beta1/conversion_error.go`'s `ConvertErrorf` - I'm not entirely clear on whether this should be around or not. `CannotConvertError` is still used in tests in `pkg/apis/pipeline/v1alpha1`, and the whole thing is just messy enough that I'm not sure what to do. * `pkg/apis/pipeline/v1beta1/version_validation.go`'s `ValidateEnabledAPIFields` - it's referenced in `docs/developers/README.md` and I can't tell if that's something that could be intended to eb used in something depending on Tekton, not just in Tekton itself. * `pkg/pipelinerunmetrics/injection.go` and `pkg/taskrunmetrics/injection.go`'s `WithInformer` - these are both used as function references in their respective `.../fake/fake.go`s. Signed-off-by: Andrew Bayer <[email protected]>
fixes tektoncd#3262 There are a few things left, either by design or uncertainty: * `pkg/apis/pipeline/v1beta1/conversion_error.go`'s `ConvertErrorf` - I'm not entirely clear on whether this should be around or not. `CannotConvertError` is still used in tests in `pkg/apis/pipeline/v1alpha1`, and the whole thing is just messy enough that I'm not sure what to do. * `pkg/apis/pipeline/v1beta1/version_validation.go`'s `ValidateEnabledAPIFields` - it's referenced in `docs/developers/README.md` and I can't tell if that's something that could be intended to eb used in something depending on Tekton, not just in Tekton itself. * `pkg/pipelinerunmetrics/injection.go` and `pkg/taskrunmetrics/injection.go`'s `WithInformer` - these are both used as function references in their respective `.../fake/fake.go`s. Signed-off-by: Andrew Bayer <[email protected]>
Repurposing a script used to find unused test builder methods from #3178 (comment) to try to find exported method names that aren't invoked from outside their package.
This greps for exported function names like
Foo
which aren't found in the codebase.Foo(
, which would indicate that it's called by another package -- callers in the same package wouldn't need to reference the package name with a.
This also:
pkg/client
since those are generatedTest
in the name, since those are test methods called bygo test
Spot-checking some of these:
SubmoduleFetch
is exported inpkg/git/git.go
and only ever called in that package. It could be unexported.ValidateDeclaredWorkspaces
, same story.NeedsPVC
is exported and only called in its corresponding test, it could be unexported.DagFromState
is defined in a_test.go
file and only called from other tests, it could be unexported. (If it stays exported it should also be renamed toDAGFromState
to adhere to Go style advice for initialismsI have a strong suspicion we could rename all these methods to be unexported (e.g.,
ValidateResults
becomesvalidateResults
) and check that tests still pass and images still build.Exported methods present a potential maintenance burden on Tekton contributors, since some external user might come to depend on the method, and could be broken if we change or remove the method.
Exported methods are effectively part of our Go library API, and while we don't have any support/deprecation policy around that, that wouldn't stop users from depending on it and being upset when we change it.
In general, methods should not be exported unless they need to be.
/kind cleanup
The text was updated successfully, but these errors were encountered: