Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
node-version: "22"

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
version: v1.64.8
version: v2.5.0
args: --timeout=30m

- name: Test
Expand Down
77 changes: 69 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,89 @@
version: "2"
linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- decorder
- durationcheck
# - err113
- errcheck
- errchkjson
- errname
# - errorlint
- exptostd
- fatcontext
# - forcetypeassert
- gocheckcompilerdirectives
- gochecksumtype
# - gocritic
# - godoclint
- goheader
- gomoddirectives
- gosec
# - maintidx
- govet
- grouper
- iface
- importas
- inamedparam
- ineffassign
# - intrange
# - ireturn
- loggercheck
- makezero
- mirror
- misspell
- nilerr
- nilnesserr
- nilnil
- noctx
# - nlreturn
# - noctx
- nolintlint
- nosprintfhostport
# - perfsprint
- prealloc
- predeclared
- promlinter
- reassign
# - revive
- rowserrcheck
- sloglint
- spancheck
- staticcheck
- testableexamples
# - testifylint
- thelper
- unconvert
- unparam
- unused
- usestdlibvars

linters-settings:
gosec:
excludes:
- G204 # Audit the use of command execution
- G404 # Insecure random number source (rand)
# - usetesting
- wastedassign
settings:
gosec:
excludes:
- G204 # Audit use of command execution
- G404 # Insecure random number source (rand)
Comment thread
creativeprojects marked this conversation as resolved.
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"go.lintTool": "golangci-lint",
"githubPullRequests.ignoredPullRequestBranches": [
"master"
]
],
"makefile.configureOnOpen": false
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ $(GOBIN)/github-markdown-toc.go: verify $(GOBIN)/eget

$(GOBIN)/mockery: verify $(GOBIN)/eget
@echo "[*] $@"
"$(GOBIN)/eget" vektra/mockery --upgrade-only --to '$(GOBIN)'
"$(GOBIN)/eget" vektra/mockery --tag v3.5.5 --upgrade-only --to '$(GOBIN)'

$(GOBIN)/golangci-lint: verify $(GOBIN)/eget
@echo "[*] $@"
"$(GOBIN)/eget" golangci/golangci-lint --tag v1.64.8 --asset=tar.gz --upgrade-only --to '$(GOBIN)'
"$(GOBIN)/eget" golangci/golangci-lint --tag v2.5.0 --asset=tar.gz --upgrade-only --to '$(GOBIN)'
Comment thread
creativeprojects marked this conversation as resolved.

$(GOBIN)/hugo: $(GOBIN)/eget
@echo "[*] $@"
Expand Down
5 changes: 3 additions & 2 deletions batt/battery.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ func detectRunningOnBattery(batteries []battery.Battery) bool {
pluggedIn := false
discharging := false
for _, bat := range batteries {
if bat.State.Raw == battery.Discharging || bat.State.Raw == battery.Empty {
switch bat.State.Raw {
case battery.Discharging, battery.Empty:
discharging = true
} else if bat.State.Raw == battery.Charging || bat.State.Raw == battery.Full || bat.State.Raw == battery.Idle || bat.State.Raw == battery.Unknown {
case battery.Charging, battery.Full, battery.Idle, battery.Unknown:
pluggedIn = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion commands_display.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func newLineLengthWriter(writer io.Writer, maxLineLength int) *lineLengthWriter
}

func (l *lineLengthWriter) Write(p []byte) (n int, err error) {
written := 0
var written int
inAnsi := false
offset := l.lineLength
lineLength := func() int { return l.lineLength - l.ansiLength }
Expand Down
1 change: 1 addition & 0 deletions commands_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func generateJsonSchema(output io.Writer, args []string) (err error) {
// SectionInfoData is used as data for go templates that render profile section references
type SectionInfoData struct {
templates.DefaultData

Section config.SectionInfo
Weight int
}
1 change: 1 addition & 0 deletions complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func TestCompleter(t *testing.T) {

testValues := func(flagName string, expected []string) func(t *testing.T) {
return func(t *testing.T) {
t.Helper()

t.Run("ReturnsAllValues", func(t *testing.T) {
actual := completer.Complete(newArgs(fmt.Sprintf("--%s", flagName), ""))
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (c *Config) applyMixinsToProfile(profileName string) error {
}

func (c *Config) applyMatchingMixinsOnce(matcher func(useKey string) bool) error {
var matchingUses []map[string][]*mixinUse
matchingUses := make([]map[string][]*mixinUse, 0, len(c.mixinUses))

for _, allUses := range c.mixinUses {
usesToApply := make(map[string][]*mixinUse)
Expand Down Expand Up @@ -756,7 +756,7 @@ func traceConfig(profileName, name string, replace bool, config *bytes.Buffer) {
gutter = "%4d: "
}
for i := 0; i < len(lines); i++ {
output.WriteString(fmt.Sprintf(gutter, i+1))
fmt.Fprintf(output, gutter, i+1)
output.Write(lines[i])
output.WriteString("\n")
}
Expand Down
1 change: 1 addition & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ profile:
func TestBoolPointer(t *testing.T) {
fixtures := []struct {
testTemplate

continueOnError maybe.Bool
}{
{
Expand Down
2 changes: 1 addition & 1 deletion config/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (g *Group) Schedules() map[string]*Schedule {
}

// SchedulableCommands returns the list of commands that can be scheduled (whether they have schedules or not)
func (g Group) SchedulableCommands() []string {
func (g *Group) SchedulableCommands() []string {
// once the deprecated retention schedule is removed, we can use the list from profiles
// return NewProfile(g.config, "").SchedulableCommands()
return []string{
Expand Down
7 changes: 6 additions & 1 deletion config/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type NumericRange struct {
// profileInfo implements ProfileInfo
type profileInfo struct {
propertySet

sections map[string]SectionInfo
}

Expand All @@ -137,6 +138,7 @@ func (p *profileInfo) Sections() []string {
// sectionInfo implements SectionInfo
type sectionInfo struct {
namedPropertySet

command restic.CommandIf
}

Expand Down Expand Up @@ -172,6 +174,7 @@ func (p *propertySet) IsAllOptions() bool {
// namedPropertySet extends propertySet with Named
type namedPropertySet struct {
propertySet

name, description string
}

Expand All @@ -181,7 +184,7 @@ func (p *namedPropertySet) Description() string { return p.description }
// accessibleProperty provides package local access to basicPropertyInfo and the backing struct field (when available)
type accessibleProperty interface {
// sectionField returns or sets the field that declares the PropertySet that this property is in, or nil if unknown.
sectionField(*reflect.StructField) *reflect.StructField
sectionField(f *reflect.StructField) *reflect.StructField
// field returns the field that declares this property, or nil if the property is not based on a field
field() *reflect.StructField
// basic returns the mutable basicPropertyInfo (is never nil)
Expand Down Expand Up @@ -278,6 +281,7 @@ func (b *basicPropertyInfo) resetTypeInfo() *basicPropertyInfo {
// propertyInfo implements PropertyInfo
type propertyInfo struct {
basicPropertyInfo

description string
defaults []string
originField *reflect.StructField
Expand All @@ -302,6 +306,7 @@ func (p *propertyInfo) sectionField(f *reflect.StructField) *reflect.StructField
// resticPropertyInfo implements PropertyInfo for properties derived from restic.Option
type resticPropertyInfo struct {
basicPropertyInfo

originField *reflect.StructField
optionFlag restic.Option
skipDefaultValue bool
Expand Down
5 changes: 3 additions & 2 deletions config/info_customizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ func init() {
note = fmt.Sprintf(`Boolean true is replaced with the %ss from section "backup".`, propertyName)
}

if sectionName == constants.CommandBackup {
switch sectionName {
case constants.CommandBackup:
if propertyName != constants.ParameterHost {
info.examples = info.examples[1:] // remove "true" from examples of backup section
note = `Boolean true is unsupported in section "backup".`
} else {
note += suffixDefaultTrueV2
}
} else if sectionName == constants.SectionConfigurationRetention {
case constants.SectionConfigurationRetention:
if propertyName == constants.ParameterHost {
note = `Boolean true is replaced with the hostname that applies in section "backup".`
}
Expand Down
6 changes: 6 additions & 0 deletions config/jsonschema/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func (s *schemaTypeWithoutBase) describe(title, description string) {

type schemaTypeList struct {
schemaTypeWithoutBase

OneOf []SchemaType `json:"oneOf,omitempty"`
AnyOf []SchemaType `json:"anyOf,omitempty"`
}
Expand Down Expand Up @@ -256,6 +257,7 @@ func newSchemaTypeList(anyType bool, types ...SchemaType) *schemaTypeList {

type schemaReference struct {
schemaTypeWithoutBase

Ref string `json:"$ref"`
}

Expand All @@ -265,6 +267,7 @@ func newSchemaBool() *schemaTypeBase {

type schemaObject struct {
schemaTypeBase

AdditionalProperties any `json:"additionalProperties,omitempty"`
PatternProperties map[string]SchemaType `json:"patternProperties,omitempty"`
Properties map[string]SchemaType `json:"properties,omitempty"`
Expand Down Expand Up @@ -315,6 +318,7 @@ func (s *schemaObject) verify() (err error) {

type schemaArray struct {
schemaTypeBase

Items SchemaType `json:"items"`
MinItems uint64 `json:"minItems"`
MaxItems *uint64 `json:"maxItems,omitempty"`
Expand All @@ -341,6 +345,7 @@ func (a *schemaArray) verify() (err error) {

type schemaNumber struct {
schemaTypeBase

MultipleOf *float64 `json:"multipleOf,omitempty"`
Minimum *float64 `json:"minimum,omitempty"`
Maximum *float64 `json:"maximum,omitempty"`
Expand Down Expand Up @@ -380,6 +385,7 @@ var validFormatNames = []stringFormat{

type schemaString struct {
schemaTypeBase

MinLength uint64 `json:"minLength"`
MaxLength *uint64 `json:"maxLength,omitempty"`
ContentEncoding string `json:"contentEncoding,omitempty"`
Expand Down
6 changes: 5 additions & 1 deletion config/jsonschema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package jsonschema

import (
"bytes"
"context"
"fmt"
"io/fs"
"maps"
Expand Down Expand Up @@ -52,7 +53,10 @@ func npmRunner(t *testing.T) npmRunnerFunc {
t.Helper()
t.Log(args)
if npmExecutable != "" {
cmd := exec.Command(npmExecutable, args...)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()

cmd := exec.CommandContext(ctx, npmExecutable, args...)
cmd.Dir = path.Join(".", ".node-env")
_ = os.MkdirAll(cmd.Dir, 0755)

Expand Down
Loading
Loading