Skip to content

Disable ireturn linter#703

Open
peterstace wants to merge 1 commit intomasterfrom
disable_ireturn
Open

Disable ireturn linter#703
peterstace wants to merge 1 commit intomasterfrom
disable_ireturn

Conversation

@peterstace
Copy link
Owner

Description

Disable the ireturn linter. 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, always
    instantiated with concrete types 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 design.

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. As more generic code is added, the
false positive rate will only grow.

Also cleans up the now-unnecessary //nolint:ireturn directives, and clarifies
the 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

  • N/A

Benchmark Results

  • N/A (no code changes affecting performance)

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.
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.

1 participant