mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 11:11:20 +00:00
dca93ce641
* analyzer with tests * fix bazel file * modify analyzer to fix build issues * add analyzer to tool chain * remove arrays from inspections * fix redundant [:] operator * Merge branch 'master' into use-slice-directly * Merge branch 'master' into use-slice-directly * fix another inspection * add package-level comment
47 lines
736 B
Go
47 lines
736 B
Go
package testdata
|
|
|
|
func NoIndexProvided() {
|
|
x := []byte{'f', 'o', 'o'}
|
|
y := x[:] // want "Expression is already a slice."
|
|
if len(y) == 3 {
|
|
}
|
|
}
|
|
|
|
func StartIndexProvided_NoDiagnostic() {
|
|
x := []byte{'f', 'o', 'o'}
|
|
y := x[1:]
|
|
if len(y) == 3 {
|
|
}
|
|
}
|
|
|
|
func EndIndexProvided_NoDiagnostic() {
|
|
x := []byte{'f', 'o', 'o'}
|
|
y := x[:2]
|
|
if len(y) == 3 {
|
|
}
|
|
}
|
|
|
|
func BothIndicesProvided_NoDiagnostic() {
|
|
x := []byte{'f', 'o', 'o'}
|
|
y := x[1:2]
|
|
if len(y) == 3 {
|
|
}
|
|
}
|
|
|
|
func StringSlice() {
|
|
x := "foo"
|
|
y := x[:] // want "Expression is already a slice."
|
|
if len(y) == 3 {
|
|
}
|
|
}
|
|
|
|
func SliceFromFunction() {
|
|
x := getSlice()[:] // want "Expression is already a slice."
|
|
if len(x) == 3 {
|
|
}
|
|
}
|
|
|
|
func getSlice() []string {
|
|
return []string{"bar"}
|
|
}
|