Skip to content

depguard: add current module name to allow list#4098

Closed
mirecl wants to merge 1 commit intogolangci:masterfrom
mirecl:master
Closed

depguard: add current module name to allow list#4098
mirecl wants to merge 1 commit intogolangci:masterfrom
mirecl:master

Conversation

@mirecl
Copy link
Copy Markdown

@mirecl mirecl commented Sep 21, 2023

AS-IS: depguard/v2 automatic add current module name (from go.mod) in deny list.
TO-BE: depguard/v2 automatic add current module name (from go.mod) in allow list.

@boring-cyborg
Copy link
Copy Markdown

boring-cyborg bot commented Sep 21, 2023

Hey, thank you for opening your first Pull Request !

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Sep 21, 2023

CLA assistant check
All committers have signed the CLA.

@ldez ldez self-requested a review September 21, 2023 09:03
@ldez ldez added enhancement New feature or improvement blocked Need's direct action from maintainer labels Sep 21, 2023
@mirecl
Copy link
Copy Markdown
Author

mirecl commented Sep 21, 2023

@alexandear @ldez , i'm sure this will be a useful addition, what do you think?

@ldez ldez changed the title Add current module name to allow list for depguard v2 depguard: add current module name to allow list Sep 21, 2023
@ldez
Copy link
Copy Markdown
Member

ldez commented Sep 21, 2023

Hello,

I think it will create confusion: it's better to let the user create it's own configuration.
Also, the way to get the go.mod is too naive and it will not work in some context.

I will decline this PR.

@ldez ldez closed this Sep 21, 2023
@ldez ldez added declined and removed blocked Need's direct action from maintainer labels Sep 21, 2023
@mirecl
Copy link
Copy Markdown
Author

mirecl commented Sep 21, 2023

@ldez, your logic is strange, all will continue to do this setting, add current module to allow list!

@ldez
Copy link
Copy Markdown
Member

ldez commented Sep 21, 2023

An example of a real configuration:

  depguard:
    rules:
      main:
        deny:
          - pkg: "github.com/instana/testify"
            desc: not allowed
          - pkg: "github.com/pkg/errors"
            desc: Should be replaced by standard lib errors package

As you can see the current module doesn't need to be added.

@mirecl
Copy link
Copy Markdown
Author

mirecl commented Sep 21, 2023

But if you add at least 1 rule to the allowed list, then the current module becomes prohibited.

@ldez
Copy link
Copy Markdown
Member

ldez commented Sep 21, 2023

Yes because it's the way that depguard v2 works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

declined enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants