mirror of
https://github.com/usememos/memos.git
synced 2025-11-24 11:30:26 +08:00
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:
|
||||
enable:
|
||||
- errcheck
|
||||
- goimports
|
||||
- revive
|
||||
- govet
|
||||
- staticcheck
|
||||
|
|
@ -16,10 +14,18 @@ linters:
|
|||
- forbidigo
|
||||
- mirror
|
||||
- bodyclose
|
||||
disable:
|
||||
- errcheck
|
||||
settings:
|
||||
goimports:
|
||||
# Put imports beginning with prefix after 3rd-party packages.
|
||||
local-prefixes: github.com/usememos/memos
|
||||
exhaustive:
|
||||
explicit-exhaustive-switch: false
|
||||
staticcheck:
|
||||
checks:
|
||||
- all
|
||||
- -ST1000
|
||||
- -ST1003
|
||||
- -ST1021
|
||||
- -QF1003
|
||||
revive:
|
||||
# Default to run all linters so that new rules in the future could automatically be added to the static check.
|
||||
enable-all-rules: true
|
||||
|
|
@ -67,6 +73,8 @@ linters:
|
|||
disabled: true
|
||||
- name: redefines-builtin-id
|
||||
disabled: true
|
||||
- name: package-comments
|
||||
disabled: true
|
||||
gocritic:
|
||||
disabled-checks:
|
||||
- ifElseChain
|
||||
|
|
@ -81,10 +89,18 @@ linters:
|
|||
- shadow
|
||||
forbidigo:
|
||||
forbid:
|
||||
- 'fmt\.Errorf(# Please use errors\.Wrap\|Wrapf\|Errorf instead)?'
|
||||
- 'ioutil\.ReadDir(# Please use os\.ReadDir)?'
|
||||
- pattern: 'fmt\.Errorf(# Please use errors\.Wrap\|Wrapf\|Errorf instead)?'
|
||||
- pattern: 'ioutil\.ReadDir(# Please use os\.ReadDir)?'
|
||||
|
||||
issues:
|
||||
exclude:
|
||||
- Rollback
|
||||
- fmt.Printf
|
||||
|
||||
formatters:
|
||||
enable:
|
||||
- goimports
|
||||
settings:
|
||||
goimports:
|
||||
local-prefixes:
|
||||
- github.com/usememos/memos
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package httpgetter
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -30,10 +29,4 @@ func TestGetHTMLMetaForInternal(t *testing.T) {
|
|||
if _, err := GetHTMLMeta("http://localhost"); !errors.Is(err, ErrInternalIP) {
|
||||
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
|
||||
}
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue