diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index f2cbc25..41e505d 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,4 +16,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.37 + version: v1.42 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8353122..38f50db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v1 with: - go-version: 1.16.x + go-version: 1.17.x - name: go test run: go test -v ./... core-test: diff --git a/.golangci.yml b/.golangci.yml index 3f0f8cf..7c56db2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ linters-settings: - golint: - min-confidence: 0.3 + gci: + local-prefixes: github.com/editorconfig/editorconfig-core-go cyclop: max-complexity: 15 package-average: 10 @@ -8,9 +8,12 @@ linters-settings: linters: disable: - exhaustivestruct + - golint - gomnd - interfacer - maligned + - scopelint + - tagliatelle presets: - bugs - complexity diff --git a/editorconfig.go b/editorconfig.go index 76d3f1a..dffdf0e 100644 --- a/editorconfig.go +++ b/editorconfig.go @@ -141,7 +141,12 @@ func (e *Editorconfig) GetDefinitionForFilename(name string) (*Definition, error // FnmatchCase calls the matcher from the config's parser or the vanilla's. func (e *Editorconfig) FnmatchCase(selector string, filename string) (bool, error) { if e.config != nil && e.config.Parser != nil { - return e.config.Parser.FnmatchCase(selector, filename) + ok, err := e.config.Parser.FnmatchCase(selector, filename) + if err != nil { + return ok, fmt.Errorf("filename match failed: %w", err) + } + + return ok, nil } return FnmatchCase(selector, filename) @@ -152,8 +157,7 @@ func (e *Editorconfig) FnmatchCase(selector string, filename string) (bool, erro func (e *Editorconfig) Serialize() ([]byte, error) { buffer := bytes.NewBuffer(nil) - err := e.Write(buffer) - if err != nil { + if err := e.Write(buffer); err != nil { return nil, fmt.Errorf("cannot write into buffer: %w", err) } @@ -174,8 +178,7 @@ func (e *Editorconfig) Write(w io.Writer) error { d.InsertToIniFile(iniFile) } - _, err := iniFile.WriteTo(w) - if err != nil { + if _, err := iniFile.WriteTo(w); err != nil { return fmt.Errorf("error writing ini file: %w", err) } diff --git a/editorconfig_test.go b/editorconfig_test.go index 3e278a8..804b0c5 100644 --- a/editorconfig_test.go +++ b/editorconfig_test.go @@ -113,7 +113,7 @@ func TestWrite(t *testing.T) { // nolint: paralleltest tempFile := filepath.Join(os.TempDir(), ".editorconfig") - f, err := os.OpenFile(tempFile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) + f, err := os.OpenFile(tempFile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o644) assert.Nil(t, err) defer func() {