Skip to content

Conversation

@sonalys
Copy link
Contributor

@sonalys sonalys commented Jul 29, 2025

Description

Small draft for issue #1092

Do not merge!

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Version of Go used when building/testing:

  • 1.22
  • 1.23

How Has This Been Tested?

Added test files for confirming no generation of invalid code, while all other test fixtures remain unchanged.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@LandonTClipp
Copy link
Member

Thank you! I'll take a look in a few days.

@LandonTClipp
Copy link
Member

I haven't yet looked too deeply into the implementation of this, but I think what we should do is retain the current behavior and add a warning log when mockery detects this that prompts the user to enable something like disable-private-type-generation: true if they want mockery to exclude such interfaces. The reason why is that there are some build pipelines of our users whereby they generate the mocks in a directory tree outside of the original mocks but then copy that tree directly into the source code. In such cases, this PR would always exclude privately-typed mocks and break these pipelines.

We should also add a mechanism for users to disable the warning log. You might be able to borrow the logic in v2 that lets users disable certain deprecation warnings.

@sonalys
Copy link
Contributor Author

sonalys commented Jul 30, 2025

I haven't yet looked too deeply into the implementation of this, but I think what we should do is retain the current behavior and add a warning log when mockery detects this that prompts the user to enable something like disable-private-type-generation: true if they want mockery to exclude such interfaces. The reason why is that there are some build pipelines of our users whereby they generate the mocks in a directory tree outside of the original mocks but then copy that tree directly into the source code. In such cases, this PR would always exclude privately-typed mocks and break these pipelines.

We should also add a mechanism for users to disable the warning log. You might be able to borrow the logic in v2 that lets users disable certain deprecation warnings.

If the package name is different, even the scenario you mentioned is not applicable.

So maybe there is a need for 2 detection layers, a different package name, and a different package path.

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.

2 participants