chore: remove pinned golangci-lint

This commit is contained in:
Jan De Dobbeleer 2023-06-14 07:27:59 +02:00 committed by Jan De Dobbeleer
parent 4c0c596c2c
commit c0429406dc
9 changed files with 28 additions and 33 deletions

View file

@ -28,9 +28,6 @@ jobs:
- name: Golang CI - name: Golang CI
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299
with: with:
# version: latest
# Pinning the version until https://github.com/golangci/golangci-lint/issues/3862 is solved
version: v1.52.2
working-directory: src working-directory: src
- name: Unit Tests - name: Unit Tests
run: go test -v ./... run: go test -v ./...

View file

@ -5,7 +5,6 @@ linters:
disable-all: true disable-all: true
enable: enable:
- bodyclose - bodyclose
- depguard
- dupl - dupl
- errcheck - errcheck
- exhaustive - exhaustive

View file

@ -425,8 +425,8 @@ func (w *Writer) writeSegmentColors() {
w.currentForeground = fg w.currentForeground = fg
} }
func (w *Writer) writeColorOverrides(match map[string]string, background string, i int) (position int) { func (w *Writer) writeColorOverrides(match map[string]string, background string, i int) int {
position = i position := i
// check color reset first // check color reset first
if match[ANCHOR] == resetStyle.AnchorEnd { if match[ANCHOR] == resetStyle.AnchorEnd {
// make sure to reset the colors if needed // make sure to reset the colors if needed
@ -434,12 +434,12 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
// do not reset when colors are identical // do not reset when colors are identical
if w.currentBackground == w.background && w.currentForeground == w.foreground { if w.currentBackground == w.background && w.currentForeground == w.foreground {
return return position
} }
// do not restore colors at the end of the string, we print it anyways // do not restore colors at the end of the string, we print it anyways
if position == len(w.runes)-1 { if position == len(w.runes)-1 {
return return position
} }
if w.transparent { if w.transparent {
@ -459,7 +459,7 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
} }
w.transparent = false w.transparent = false
return return position
} }
position += len([]rune(match[ANCHOR])) - 1 position += len([]rune(match[ANCHOR])) - 1
@ -467,11 +467,11 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
for _, style := range knownStyles { for _, style := range knownStyles {
if style.AnchorEnd == match[ANCHOR] { if style.AnchorEnd == match[ANCHOR] {
w.writeEscapedAnsiString(style.End) w.writeEscapedAnsiString(style.End)
return return position
} }
if style.AnchorStart == match[ANCHOR] { if style.AnchorStart == match[ANCHOR] {
w.writeEscapedAnsiString(style.Start) w.writeEscapedAnsiString(style.Start)
return return position
} }
} }
@ -483,7 +483,7 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
// ignore processing fully tranparent colors // ignore processing fully tranparent colors
w.invisible = w.currentForeground.IsTransparent() && w.currentBackground.IsTransparent() w.invisible = w.currentForeground.IsTransparent() && w.currentBackground.IsTransparent()
if w.invisible { if w.invisible {
return return position
} }
// make sure we have colors // make sure we have colors
@ -498,13 +498,13 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
background := w.getAnsiFromColorString(w.TerminalBackground, false) background := w.getAnsiFromColorString(w.TerminalBackground, false)
w.writeEscapedAnsiString(fmt.Sprintf(colorise, background)) w.writeEscapedAnsiString(fmt.Sprintf(colorise, background))
w.writeEscapedAnsiString(fmt.Sprintf(colorise, w.currentBackground.ToForeground())) w.writeEscapedAnsiString(fmt.Sprintf(colorise, w.currentBackground.ToForeground()))
return return position
} }
if w.currentForeground.IsTransparent() && !w.currentBackground.IsTransparent() { if w.currentForeground.IsTransparent() && !w.currentBackground.IsTransparent() {
w.transparent = true w.transparent = true
w.writeEscapedAnsiString(fmt.Sprintf(transparent, w.currentBackground)) w.writeEscapedAnsiString(fmt.Sprintf(transparent, w.currentBackground))
return return position
} }
if w.currentBackground != w.background { if w.currentBackground != w.background {

View file

@ -10,12 +10,12 @@ import (
"strings" "strings"
) )
func InstallZIP(data []byte, user bool) (err error) { func InstallZIP(data []byte, user bool) error {
bytesReader := bytes.NewReader(data) bytesReader := bytes.NewReader(data)
zipReader, err := zip.NewReader(bytesReader, int64(bytesReader.Len())) zipReader, err := zip.NewReader(bytesReader, int64(bytesReader.Len()))
if err != nil { if err != nil {
return return err
} }
fonts := make(map[string]*Font) fonts := make(map[string]*Font)

View file

@ -9,17 +9,15 @@ import (
var FontsDir = path.Join(os.Getenv("HOME"), "Library", "Fonts") var FontsDir = path.Join(os.Getenv("HOME"), "Library", "Fonts")
func install(font *Font, _ bool) (err error) { func install(font *Font, _ bool) error {
// On darwin/OSX, the user's fonts directory is ~/Library/Fonts, // On darwin/OSX, the user's fonts directory is ~/Library/Fonts,
// and fonts should be installed directly into that path; // and fonts should be installed directly into that path;
// i.e., not in subfolders. // i.e., not in subfolders.
fullPath := path.Join(FontsDir, path.Base(font.FileName)) fullPath := path.Join(FontsDir, path.Base(font.FileName))
if err = os.MkdirAll(path.Dir(fullPath), 0700); err != nil { if err := os.MkdirAll(path.Dir(fullPath), 0700); err != nil {
return return err
} }
err = os.WriteFile(fullPath, font.Data, 0644) return os.WriteFile(fullPath, font.Data, 0644)
return
} }

View file

@ -14,7 +14,7 @@ import (
// FontsDir denotes the path to the user's fonts directory on Unix-like systems. // FontsDir denotes the path to the user's fonts directory on Unix-like systems.
var FontsDir = path.Join(os.Getenv("HOME"), "/.local/share/fonts") var FontsDir = path.Join(os.Getenv("HOME"), "/.local/share/fonts")
func install(font *Font, _ bool) (err error) { func install(font *Font, _ bool) error {
// On Linux, fontconfig can understand subdirectories. So, to keep the // On Linux, fontconfig can understand subdirectories. So, to keep the
// font directory clean, install all font files for a particular font // font directory clean, install all font files for a particular font
// family into a subdirectory named after the family (with hyphens instead // family into a subdirectory named after the family (with hyphens instead
@ -23,7 +23,7 @@ func install(font *Font, _ bool) (err error) {
strings.ToLower(strings.ReplaceAll(font.Family, " ", "-")), strings.ToLower(strings.ReplaceAll(font.Family, " ", "-")),
path.Base(font.FileName)) path.Base(font.FileName))
if err = os.MkdirAll(path.Dir(fullPath), 0700); err != nil { if err := os.MkdirAll(path.Dir(fullPath), 0700); err != nil {
return err return err
} }

View file

@ -18,7 +18,7 @@ const (
HWND_BROADCAST = 0xFFFF //nolint:revive HWND_BROADCAST = 0xFFFF //nolint:revive
) )
func install(font *Font, admin bool) (err error) { func install(font *Font, admin bool) error {
// To install a font on Windows: // To install a font on Windows:
// - Copy the file to the fonts directory // - Copy the file to the fonts directory
// - Add registry entry // - Add registry entry
@ -36,7 +36,7 @@ func install(font *Font, admin bool) (err error) {
return fmt.Errorf("Unable to remove existing font file: %s", err.Error()) return fmt.Errorf("Unable to remove existing font file: %s", err.Error())
} }
} }
err = os.WriteFile(fullPath, font.Data, 0644) err := os.WriteFile(fullPath, font.Data, 0644)
if err != nil { if err != nil {
return fmt.Errorf("Unable to write font file: %s", err.Error()) return fmt.Errorf("Unable to write font file: %s", err.Error())
} }
@ -73,7 +73,7 @@ func install(font *Font, admin bool) (err error) {
fontPtr, err := syscall.UTF16PtrFromString(fullPath) fontPtr, err := syscall.UTF16PtrFromString(fullPath)
if err != nil { if err != nil {
return return err
} }
ret, _, _ := proc.Call(uintptr(unsafe.Pointer(fontPtr))) ret, _, _ := proc.Call(uintptr(unsafe.Pointer(fontPtr)))

View file

@ -524,9 +524,10 @@ func (pt *Path) normalizePath(path string) string {
} }
// ParsePath parses an input path and returns a clean root and a clean path. // ParsePath parses an input path and returns a clean root and a clean path.
func (pt *Path) parsePath(inputPath string) (root, path string) { func (pt *Path) parsePath(inputPath string) (string, string) {
var root, path string
if len(inputPath) == 0 { if len(inputPath) == 0 {
return return root, path
} }
separator := pt.env.PathSeparator() separator := pt.env.PathSeparator()
clean := func(path string) string { clean := func(path string) string {
@ -549,7 +550,7 @@ func (pt *Path) parsePath(inputPath string) (root, path string) {
if len(matches) > 0 { if len(matches) > 0 {
root = `\\` + matches["hostname"] + `\` + matches["sharename"] root = `\\` + matches["hostname"] + `\` + matches["sharename"]
path = clean(matches["path"]) path = clean(matches["path"])
return return root, path
} }
} }
s := strings.SplitAfterN(inputPath, separator, 2) s := strings.SplitAfterN(inputPath, separator, 2)

View file

@ -39,16 +39,16 @@ func (u *Unity) Enabled() bool {
return true return true
} }
func (u *Unity) GetUnityVersion() (version string, err error) { func (u *Unity) GetUnityVersion() (string, error) {
projectDir, err := u.env.HasParentFilePath("ProjectSettings") projectDir, err := u.env.HasParentFilePath("ProjectSettings")
if err != nil { if err != nil {
u.env.Debug("No ProjectSettings parent folder found") u.env.Debug("No ProjectSettings parent folder found")
return return "", err
} }
if !u.env.HasFilesInDir(projectDir.Path, "ProjectVersion.txt") { if !u.env.HasFilesInDir(projectDir.Path, "ProjectVersion.txt") {
u.env.Debug("No ProjectVersion.txt file found") u.env.Debug("No ProjectVersion.txt file found")
return return "", err
} }
versionFilePath := filepath.Join(projectDir.Path, "ProjectVersion.txt") versionFilePath := filepath.Join(projectDir.Path, "ProjectVersion.txt")