fix: golangci config
This commit is contained in:
parent
2aca8180d1
commit
2cf2126d64
3 changed files with 24 additions and 15 deletions
|
|
@ -2,8 +2,6 @@ version: "2"
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- errcheck
|
|
||||||
- goimports
|
|
||||||
- revive
|
- revive
|
||||||
- govet
|
- govet
|
||||||
- staticcheck
|
- staticcheck
|
||||||
|
|
@ -16,10 +14,18 @@ linters:
|
||||||
- forbidigo
|
- forbidigo
|
||||||
- mirror
|
- mirror
|
||||||
- bodyclose
|
- bodyclose
|
||||||
|
disable:
|
||||||
|
- errcheck
|
||||||
settings:
|
settings:
|
||||||
goimports:
|
exhaustive:
|
||||||
# Put imports beginning with prefix after 3rd-party packages.
|
explicit-exhaustive-switch: false
|
||||||
local-prefixes: github.com/usememos/memos
|
staticcheck:
|
||||||
|
checks:
|
||||||
|
- all
|
||||||
|
- -ST1000
|
||||||
|
- -ST1003
|
||||||
|
- -ST1021
|
||||||
|
- -QF1003
|
||||||
revive:
|
revive:
|
||||||
# Default to run all linters so that new rules in the future could automatically be added to the static check.
|
# Default to run all linters so that new rules in the future could automatically be added to the static check.
|
||||||
enable-all-rules: true
|
enable-all-rules: true
|
||||||
|
|
@ -67,6 +73,8 @@ linters:
|
||||||
disabled: true
|
disabled: true
|
||||||
- name: redefines-builtin-id
|
- name: redefines-builtin-id
|
||||||
disabled: true
|
disabled: true
|
||||||
|
- name: package-comments
|
||||||
|
disabled: true
|
||||||
gocritic:
|
gocritic:
|
||||||
disabled-checks:
|
disabled-checks:
|
||||||
- ifElseChain
|
- ifElseChain
|
||||||
|
|
@ -81,10 +89,18 @@ linters:
|
||||||
- shadow
|
- shadow
|
||||||
forbidigo:
|
forbidigo:
|
||||||
forbid:
|
forbid:
|
||||||
- 'fmt\.Errorf(# Please use errors\.Wrap\|Wrapf\|Errorf instead)?'
|
- pattern: 'fmt\.Errorf(# Please use errors\.Wrap\|Wrapf\|Errorf instead)?'
|
||||||
- 'ioutil\.ReadDir(# Please use os\.ReadDir)?'
|
- pattern: 'ioutil\.ReadDir(# Please use os\.ReadDir)?'
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude:
|
exclude:
|
||||||
- Rollback
|
- Rollback
|
||||||
- fmt.Printf
|
- fmt.Printf
|
||||||
|
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- goimports
|
||||||
|
settings:
|
||||||
|
goimports:
|
||||||
|
local-prefixes:
|
||||||
|
- github.com/usememos/memos
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package httpgetter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
@ -30,10 +29,4 @@ func TestGetHTMLMetaForInternal(t *testing.T) {
|
||||||
if _, err := GetHTMLMeta("http://localhost"); !errors.Is(err, ErrInternalIP) {
|
if _, err := GetHTMLMeta("http://localhost"); !errors.Is(err, ErrInternalIP) {
|
||||||
t.Errorf("Expected error for resolved internal IP, got %v", err)
|
t.Errorf("Expected error for resolved internal IP, got %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// test for redirected internal IP
|
|
||||||
// 49.232.126.226:1110 will redirects to 127.0.0.1
|
|
||||||
if _, err := GetHTMLMeta("http://49.232.126.226:1110"); !(errors.Is(err, ErrInternalIP) && strings.Contains(err.Error(), "redirect")) {
|
|
||||||
t.Errorf("Expected error for redirected internal IP, got %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ func GetImage(urlStr string) (*Image, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(mediatype, "image/") {
|
if !strings.HasPrefix(mediatype, "image/") {
|
||||||
return nil, errors.New("Wrong image mediatype")
|
return nil, errors.New("wrong image mediatype")
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyBytes, err := io.ReadAll(response.Body)
|
bodyBytes, err := io.ReadAll(response.Body)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue