1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-23 22:04:49 +02:00

feature: detect identical-branches in switch statements (#1448)

This commit is contained in:
chavacava
2025-07-30 15:55:03 +02:00
committed by GitHub
parent 9fc7dc7d77
commit 68ac5514f5
5 changed files with 169 additions and 73 deletions

View File

@@ -480,8 +480,8 @@ func checkURLTag(checkCtx *checkContext, tag *structtag.Tag, _ ast.Expr) (messag
var delimiter = ""
for _, opt := range tag.Options {
switch opt {
case "int", "omitempty", "numbered", "brackets":
case "unix", "unixmilli", "unixnano": // TODO : check that the field is of type time.Time
case "int", "omitempty", "numbered", "brackets",
"unix", "unixmilli", "unixnano": // TODO : check that the field is of type time.Time
case "comma", "semicolon", "space":
if delimiter == "" {
delimiter = opt
@@ -597,9 +597,7 @@ func typeValueMatch(t ast.Expr, val string) bool {
case "int":
_, err := strconv.ParseInt(val, 10, 64)
typeMatches = err == nil
case "string":
case "nil":
default:
default: // "string", "nil", ...
// unchecked type
}