Skip to content

Commit

Permalink
chore: bump golangci-lint and fixes (#115)
Browse files Browse the repository at this point in the history
Signed-off-by: Yoan Blanc <[email protected]>
  • Loading branch information
greut authored Sep 21, 2021
1 parent 26d5e3b commit 1a185cb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.37
version: v1.42
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
linters-settings:
golint:
min-confidence: 0.3
gci:
local-prefixes: github.com/editorconfig/editorconfig-core-go
cyclop:
max-complexity: 15
package-average: 10

linters:
disable:
- exhaustivestruct
- golint
- gomnd
- interfacer
- maligned
- scopelint
- tagliatelle
presets:
- bugs
- complexity
Expand Down
13 changes: 8 additions & 5 deletions editorconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion editorconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 1a185cb

Please sign in to comment.