Skip to content
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

refactor: replace failure Category raw string with constant #1196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexandear
Copy link
Contributor

The PR adds constants for failure categories and replaces raw strings with respective constants.

We can optimize categories in a separate PR. E.g., FailureCategoryCodeStyle and FailureCategoryStyle should be one category.

Comment on lines +8 to +30
const (
FailureCategoryArgOrder = "arg-order"
FailureCategoryBadPractice = "bad practice"
FailureCategoryCodeStyle = "code-style"
FailureCategoryComments = "comments"
FailureCategoryComplexity = "complexity"
FailureCategoryContent = "content"
FailureCategoryErrors = "errors"
FailureCategoryImports = "imports"
FailureCategoryLogic = "logic"
FailureCategoryMaintenance = "maintenance"
FailureCategoryNaming = "naming"
FailureCategoryOptimization = "optimization"
FailureCategoryStyle = "style"
FailureCategoryTime = "time"
FailureCategoryTypeInference = "type-inference"
FailureCategoryUnaryOp = "unary-op"
FailureCategoryUnexportedTypeInAPI = "unexported-type-in-api"
FailureCategoryZeroValue = "zero-value"

failureCategoryInternal = "REVIVE_INTERNAL"
failureCategoryValidity = "validity"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of them are exported. Do we need it?

Because of the modules and packages we do. But do we need them to be exported outside the module? If not, maybe it could be a internal/failure packages, allowing the constants to be unexported outside the module

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone wants to create a custom rule (not included in Revive), these might be useful.
I'd however make them typed, to avoid further direct strings used for this purpose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for me then.

And yes, good idea about the typed constants

@@ -5,6 +5,30 @@ import (
"go/token"
)

const (
FailureCategoryArgOrder = "arg-order"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported symbols need to be documented

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.

4 participants