Skip to content

Commit

Permalink
Remove unnecessary codes
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Jan 24, 2024
1 parent ba589bf commit 86c55e7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 83 deletions.
32 changes: 0 additions & 32 deletions coverage/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,38 +107,6 @@ func (fc FileCoverages) FuzzyFindByFile(file string) (*FileCoverage, error) { //
return nil, fmt.Errorf("file name not found: %s", file)
}

func (fc FileCoverages) PathPrefix() (string, error) { //nostyle:recvtype
if len(fc) == 0 {
return "", errors.New("no file coverages")
}
p := strings.Split(filepath.Dir(filepath.ToSlash(fc[0].File)), "/")
for _, c := range fc {
d := strings.Split(filepath.Dir(filepath.ToSlash(c.File)), "/")
i := 0
for {
if len(p) <= i {
break
}
if len(d) <= i {
break
}
if p[i] != d[i] {
break
}
i += 1
}
p = p[:i]
}
s := strings.Join(p, "/")
if s == "" && filepath.IsAbs(fc[0].File) {
s = "/"
}
if s == "." {
s = ""
}
return s, nil
}

func (fc *FileCoverage) FindBlocksByLine(n int) BlockCoverages {
if fc == nil {
return BlockCoverages{}
Expand Down
51 changes: 0 additions & 51 deletions coverage/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,57 +90,6 @@ func TestCompare(t *testing.T) {
}
}

func TestPathPrefix(t *testing.T) {
tests := []struct {
files FileCoverages
want string
}{
{
FileCoverages{
&FileCoverage{File: "file_a.go"},
},
"",
},
{
FileCoverages{
&FileCoverage{File: "path/to/file_a.go"},
&FileCoverage{File: "path/file_b.go"},
},
"path",
},
{
FileCoverages{
&FileCoverage{File: "/path/to/file_a.go"},
&FileCoverage{File: "/path/file_b.go"},
},
"/path",
},
{
FileCoverages{
&FileCoverage{File: "/path/to/foo/file_a.go"},
&FileCoverage{File: "/path/to/foo/bar/file_b.go"},
},
"/path/to/foo",
},
{
FileCoverages{
&FileCoverage{File: "/to/foo/file_a.go"},
&FileCoverage{File: "/path/to/foo/bar/file_b.go"},
},
"/",
},
}
for _, tt := range tests {
got, err := tt.files.PathPrefix()
if err != nil {
t.Fatal(err)
}
if got != tt.want {
t.Errorf("got %v\nwant %v", got, tt.want)
}
}
}

func TestMaxCount(t *testing.T) {
tests := []struct {
blocks BlockCoverages
Expand Down

0 comments on commit 86c55e7

Please sign in to comment.