summaryrefslogtreecommitdiffstats
path: root/pkg/commands/patch
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-08 15:46:35 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-01-09 14:09:53 +1100
commit18f48a43d5401af97dae18aab07238146b7d587b (patch)
tree5f220bac5ac7210ee5f30c80cba6d396a8f0b18f /pkg/commands/patch
parent5d6d8942862428afb72bc45b562af10ceac6e0a3 (diff)
add some more linters
Diffstat (limited to 'pkg/commands/patch')
-rw-r--r--pkg/commands/patch/patch_modifier.go2
-rw-r--r--pkg/commands/patch/patch_modifier_test.go2
-rw-r--r--pkg/commands/patch/patch_parser.go4
3 files changed, 6 insertions, 2 deletions
diff --git a/pkg/commands/patch/patch_modifier.go b/pkg/commands/patch/patch_modifier.go
index 3ab13931b..2109ad1f0 100644
--- a/pkg/commands/patch/patch_modifier.go
+++ b/pkg/commands/patch/patch_modifier.go
@@ -22,7 +22,7 @@ func GetHeaderFromDiff(diff string) string {
func GetHunksFromDiff(diff string) []*PatchHunk {
hunks := []*PatchHunk{}
firstLineIdx := -1
- var hunkLines []string
+ var hunkLines []string //nolint:prealloc
pastDiffHeader := false
for lineIdx, line := range strings.SplitAfter(diff, "\n") {
diff --git a/pkg/commands/patch/patch_modifier_test.go b/pkg/commands/patch/patch_modifier_test.go
index 8b866019b..ec79cbe32 100644
--- a/pkg/commands/patch/patch_modifier_test.go
+++ b/pkg/commands/patch/patch_modifier_test.go
@@ -511,6 +511,7 @@ func TestModifyPatchForRange(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
result := ModifiedPatchForRange(nil, s.filename, s.diffText, s.firstLineIndex, s.lastLineIndex, s.reverse, false)
if !assert.Equal(t, s.expected, result) {
@@ -538,6 +539,7 @@ func TestLineNumberOfLine(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
result := s.hunk.LineNumberOfLine(s.idx)
if !assert.Equal(t, s.expected, result) {
diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go
index 1fefe0748..c2be120c9 100644
--- a/pkg/commands/patch/patch_parser.go
+++ b/pkg/commands/patch/patch_parser.go
@@ -98,7 +98,7 @@ func (l *PatchLine) render(selected bool, included bool) string {
return coloredString(style.FgCyan, match[1], selected, included) + coloredString(theme.DefaultTextColor, match[2], selected, false)
}
- textStyle := theme.DefaultTextColor
+ var textStyle style.TextStyle
switch l.Kind {
case PATCH_HEADER:
textStyle = textStyle.SetBold()
@@ -108,6 +108,8 @@ func (l *PatchLine) render(selected bool, included bool) string {
textStyle = style.FgRed
case COMMIT_SHA:
textStyle = style.FgYellow
+ default:
+ textStyle = theme.DefaultTextColor
}
return coloredString(textStyle, content, selected, included)