-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package golinters | ||
|
||
import ( | ||
"github.com/jiftechnify/untypedconst" | ||
"golang.org/x/tools/go/analysis" | ||
|
||
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis" | ||
) | ||
|
||
func NewUntypedConst() *goanalysis.Linter { | ||
a := untypedconst.Analyzer | ||
|
||
return goanalysis.NewLinter( | ||
a.Name, | ||
a.Doc, | ||
[]*analysis.Analyzer{a}, | ||
nil, | ||
).WithLoadMode(goanalysis.LoadModeTypesInfo) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//golangcitest:args -Euntypedconst | ||
package testdata | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type ExString string | ||
|
||
func retExString() ExString { | ||
if true { | ||
return ExString("hoge") | ||
} else { | ||
fmt.Println("This should never happen") | ||
return "hoge" // want `returning untyped constant as defined type "command-line-arguments.ExString"` | ||
} | ||
} | ||
|
||
type ExInt int | ||
|
||
func retExInt() ExInt { | ||
if true { | ||
return ExInt(1) | ||
} else { | ||
return 1 // want `returning untyped constant as defined type "command-line-arguments.ExInt"` | ||
} | ||
} | ||
|
||
type ExFloat float64 | ||
|
||
func retExFloat() ExFloat { | ||
if true { | ||
return ExFloat(0.5) | ||
} else { | ||
return 0.5 // want `returning untyped constant as defined type "command-line-arguments.ExFloat"` | ||
} | ||
} | ||
|
||
type ExComplex complex128 | ||
|
||
func retExComplex() ExComplex { | ||
if true { | ||
return ExComplex(1.0 + 0.5i) | ||
} else { | ||
return 1.0 + 0.5i // want `returning untyped constant as defined type "command-line-arguments.ExComplex"` | ||
} | ||
} | ||
|
||
type ExRune rune | ||
|
||
func retExRune() ExRune { | ||
if true { | ||
return ExRune('a') | ||
} else { | ||
return 'a' // want `returning untyped constant as defined type "command-line-arguments.ExRune"` | ||
} | ||
} | ||
|
||
type ExBool bool | ||
|
||
func retExBool() ExBool { | ||
if true { | ||
return ExBool(true) | ||
} else { | ||
return true // want `returning untyped constant as defined type "command-line-arguments.ExBool"` | ||
} | ||
} |