Open
Conversation
The ireturn linter flags functions that return interfaces, based on the principle "accept interfaces, return concrete types." However, every instance where it fires in this codebase is a false positive: - catch[T any] in geom/util.go returns a generic type parameter T, which is always instantiated with concrete types (Geometry, string, bool, PreparedGeometry) at call sites. - GetLeaf and Cast[T] in internal/jtsport/java/polymorphic.go return the Polymorphic interface or a type parameter constrained by it, which is inherent to their purpose as polymorphism infrastructure. The public API of the geom package has zero exported interfaces and all public functions already return concrete types, so ireturn provides no protection against the problem it's designed to catch. Meanwhile, as more generic code is added, the false positive rate will only grow. Also clean up the now-unnecessary //nolint:ireturn directives, and clarify the comment in the linter config about moving linters between the enable and disable sections.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Disable the
ireturnlinter. Every instance where it fires in this codebaseis a false positive:
catch[T any]ingeom/util.goreturns a generic type parameterT, alwaysinstantiated with concrete types at call sites.
GetLeafandCast[T]ininternal/jtsport/java/polymorphic.goreturn thePolymorphicinterface or a type parameter constrained by it, which isinherent to their design.
The public API of the
geompackage has zero exported interfaces and all publicfunctions already return concrete types, so
ireturnprovides no protectionagainst the problem it's designed to catch. As more generic code is added, the
false positive rate will only grow.
Also cleans up the now-unnecessary
//nolint:ireturndirectives, and clarifiesthe comment in the linter config about moving linters between the enable and
disable sections.
Check List
Have you:
Added unit tests? N/A (linter config change only)
Add cmprefimpl tests? (if appropriate?) N/A
Updated release notes? (if appropriate?) N/A
Updated the README.md (if new functionality is added?) N/A
Related Issue
Benchmark Results