-
Notifications
You must be signed in to change notification settings - Fork 285
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
base: master
Are you sure you want to change the base?
refactor: replace failure Category raw string with constant #1196
Conversation
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" | ||
) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
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
andFailureCategoryStyle
should be one category.