mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-01-13 13:21:00 +00:00
chore: enable some more linters (#16)
This commit is contained in:
parent
f0eed8cc56
commit
d5fd606577
7 changed files with 48 additions and 18 deletions
27
.golangci.yaml
Normal file
27
.golangci.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
linters:
|
||||||
|
presets:
|
||||||
|
- bugs
|
||||||
|
- error
|
||||||
|
- import
|
||||||
|
- metalinter
|
||||||
|
- module
|
||||||
|
- unused
|
||||||
|
|
||||||
|
enable:
|
||||||
|
- testifylint
|
||||||
|
|
||||||
|
disable:
|
||||||
|
# preset error
|
||||||
|
# These should probably be cleaned up at some point if we want to publish part of this as a library.
|
||||||
|
- err113 # Very annoying to define static errors everywhere
|
||||||
|
- wrapcheck # Very annoying to wrap errors everywhere
|
||||||
|
# preset import
|
||||||
|
- depguard
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
gci:
|
||||||
|
sections:
|
||||||
|
- standard
|
||||||
|
- default
|
||||||
|
- localmodule
|
||||||
|
|
||||||
|
|
@ -51,9 +51,9 @@ func run(cmd *cobra.Command, _ []string) error {
|
||||||
BaseBranch: flagBranch,
|
BaseBranch: flagBranch,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch flagForge {
|
switch flagForge { // nolint:gocritic // Will become a proper switch once gitlab is added
|
||||||
//case "gitlab":
|
// case "gitlab":
|
||||||
//f = rp.NewGitLab(forgeOptions)
|
// f = rp.NewGitLab(forgeOptions)
|
||||||
case "github":
|
case "github":
|
||||||
logger.DebugContext(ctx, "using forge GitHub")
|
logger.DebugContext(ctx, "using forge GitHub")
|
||||||
forge = rp.NewGitHub(logger, &rp.GitHubOptions{
|
forge = rp.NewGitHub(logger, &rp.GitHubOptions{
|
||||||
|
|
|
||||||
2
forge.go
2
forge.go
|
|
@ -19,7 +19,7 @@ const (
|
||||||
GitHubPerPageMax = 100
|
GitHubPerPageMax = 100
|
||||||
GitHubPRStateOpen = "open"
|
GitHubPRStateOpen = "open"
|
||||||
GitHubPRStateClosed = "closed"
|
GitHubPRStateClosed = "closed"
|
||||||
GitHubEnvAPIToken = "GITHUB_TOKEN"
|
GitHubEnvAPIToken = "GITHUB_TOKEN" // nolint:gosec // Not actually a hardcoded credential
|
||||||
GitHubEnvUsername = "GITHUB_USER"
|
GitHubEnvUsername = "GITHUB_USER"
|
||||||
GitHubEnvRepository = "GITHUB_REPOSITORY"
|
GitHubEnvRepository = "GITHUB_REPOSITORY"
|
||||||
GitHubLabelColor = "dedede"
|
GitHubLabelColor = "dedede"
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,10 @@ import (
|
||||||
"github.com/apricote/releaser-pleaser/internal/markdown/extensions/ast"
|
"github.com/apricote/releaser-pleaser/internal/markdown/extensions/ast"
|
||||||
)
|
)
|
||||||
|
|
||||||
var sectionStartRegex = regexp.MustCompile(`^<!-- section-start (.+) -->`)
|
var (
|
||||||
var sectionEndRegex = regexp.MustCompile(`^<!-- section-end (.+) -->`)
|
sectionStartRegex = regexp.MustCompile(`^<!-- section-start (.+) -->`)
|
||||||
|
sectionEndRegex = regexp.MustCompile(`^<!-- section-end (.+) -->`)
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
sectionTrigger = "<!--"
|
sectionTrigger = "<!--"
|
||||||
|
|
@ -21,8 +23,7 @@ const (
|
||||||
SectionEndFormat = "<!-- section-end %s -->"
|
SectionEndFormat = "<!-- section-end %s -->"
|
||||||
)
|
)
|
||||||
|
|
||||||
type sectionParser struct {
|
type sectionParser struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (s *sectionParser) Open(_ gast.Node, reader text.Reader, _ parser.Context) (gast.Node, parser.State) {
|
func (s *sectionParser) Open(_ gast.Node, reader text.Reader, _ parser.Context) (gast.Node, parser.State) {
|
||||||
line, _ := reader.PeekLine()
|
line, _ := reader.PeekLine()
|
||||||
|
|
@ -75,8 +76,7 @@ func (s *sectionParser) Trigger() []byte {
|
||||||
return []byte(sectionTrigger)
|
return []byte(sectionTrigger)
|
||||||
}
|
}
|
||||||
|
|
||||||
type section struct {
|
type section struct{}
|
||||||
}
|
|
||||||
|
|
||||||
// Section is an extension that allow you to use group content under a shared parent ast node.
|
// Section is an extension that allow you to use group content under a shared parent ast node.
|
||||||
var Section = §ion{}
|
var Section = §ion{}
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ func (r *Renderer) renderFencedCodeBlock(w util.BufWriter, source []byte, node a
|
||||||
return ast.WalkStop, fmt.Errorf(": %w", err)
|
return ast.WalkStop, fmt.Errorf(": %w", err)
|
||||||
}
|
}
|
||||||
if err := r.writeByte(w, '\n'); err != nil {
|
if err := r.writeByte(w, '\n'); err != nil {
|
||||||
return ast.WalkStop, nil
|
return ast.WalkStop, fmt.Errorf(": %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the contents of the fenced code block.
|
// Write the contents of the fenced code block.
|
||||||
|
|
|
||||||
|
|
@ -11,25 +11,26 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var author = &object.Signature{
|
||||||
author = &object.Signature{
|
Name: "releaser-pleaser",
|
||||||
Name: "releaser-pleaser",
|
When: time.Date(2020, 01, 01, 01, 01, 01, 01, time.UTC),
|
||||||
When: time.Date(2020, 01, 01, 01, 01, 01, 01, time.UTC),
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
type CommitOption func(*commitOptions)
|
type CommitOption func(*commitOptions)
|
||||||
|
|
||||||
type commitOptions struct {
|
type commitOptions struct {
|
||||||
cleanFiles bool
|
cleanFiles bool
|
||||||
files []commitFile
|
files []commitFile
|
||||||
tags []string
|
tags []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type commitFile struct {
|
type commitFile struct {
|
||||||
path string
|
path string
|
||||||
content string
|
content string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Commit func(*testing.T, *git.Repository) error
|
type Commit func(*testing.T, *git.Repository) error
|
||||||
|
|
||||||
type Repo func(*testing.T) *git.Repository
|
type Repo func(*testing.T) *git.Repository
|
||||||
|
|
||||||
func WithCommit(message string, options ...CommitOption) Commit {
|
func WithCommit(message string, options ...CommitOption) Commit {
|
||||||
|
|
@ -83,7 +84,6 @@ func WithCommit(message string, options ...CommitOption) Commit {
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,9 @@ func (pr *ReleasePullRequest) parseVersioningFlags(overrides ReleaseOverrides) R
|
||||||
overrides.NextVersionType = NextVersionTypeBeta
|
overrides.NextVersionType = NextVersionTypeBeta
|
||||||
case LabelNextVersionTypeAlpha:
|
case LabelNextVersionTypeAlpha:
|
||||||
overrides.NextVersionType = NextVersionTypeAlpha
|
overrides.NextVersionType = NextVersionTypeAlpha
|
||||||
|
case LabelReleasePending, LabelReleaseTagged:
|
||||||
|
// These labels have no effect on the versioning.
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue