Skip to content

Commit

Permalink
Fix StringsModifyFilterer
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Mar 15, 2022
1 parent 2d65adf commit 83f0605
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type Reasons struct {
type StringsModifyFilterer struct{}

func (s StringsModifyFilterer) Filter(file *gitdiff.File) *Reasons {

total := 0
stringModiry := 0
for _, fragments := range file.TextFragments {
for i, line := range fragments.Lines {
if line.Op != gitdiff.OpAdd {
Expand All @@ -74,14 +77,18 @@ func (s StringsModifyFilterer) Filter(file *gitdiff.File) *Reasons {
continue
}

total++
if strings.ContainsAny(diffs[0].Text, `"'`) && strings.ContainsAny(diffs[2].Text, `"'`) {
return &Reasons{
File: file.NewName,
Message: "only string modified",
}
stringModiry++
}
}
}
if total != 0 && total == stringModiry {
return &Reasons{
File: file.NewName,
Message: "only string modified",
}
}
return nil
}

Expand Down

0 comments on commit 83f0605

Please sign in to comment.