Skip to content

Commit

Permalink
Update workflow tools and fix linting issues (#24)
Browse files Browse the repository at this point in the history
* fix most linter warnings and errors

* update workflow tool versions

* Add go 1.23 explicit support

* Update YAEGI_VERSION to v0.14.1

* Update YAEGI_VERSION to v0.14.3
  • Loading branch information
packruler authored Oct 23, 2024
1 parent 47a1ea9 commit 2c9fc37
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go-cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:

strategy:
matrix:
go-version: [ 1.16, 1.21, 1.22, 1.x ]
go-version: [ 1.16, 1.21, 1.22, 1.23, 1.x ]
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
runs-on: ubuntu-latest
env:
GO_VERSION: 1.16
GOLANGCI_LINT_VERSION: v1.48.0
YAEGI_VERSION: v0.14.1
GOLANGCI_LINT_VERSION: v1.61.0
YAEGI_VERSION: v0.14.3
CGO_ENABLED: 0
defaults:
run:
Expand All @@ -26,20 +26,20 @@ jobs:

# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

# https://github.com/marketplace/actions/checkout
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: go/src/github.com/${{ github.repository }}
fetch-depth: 0

# https://github.com/marketplace/actions/cache
- name: Cache Go modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
39 changes: 19 additions & 20 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
run:
timeout: 3m
skip-files:
- httputil/header/header.go
- apps/app_name.go
- themes/theme_name.go
skip-dirs: []
linters-settings:
govet:
check-shadowing: false
golint:
min-confidence: 0
depguard:
rules:
allow_repos:
allow:
- github.com/packruler/rewrite-body/handler
- github.com/packruler/rewrite-body/compressutil
- bytes
- context
- fmt
- net/http
- net/http/httptest
- regexp
- strconv
- strings
- testing
gocyclo:
min-complexity: 12
maligned:
suggest-new: true
goconst:
min-len: 3
min-occurrences: 4
Expand All @@ -25,22 +29,13 @@ linters-settings:
linters:
enable-all: true
disable:
- scopelint
- golint
- interfacer
- maligned
- bodyclose
- goerr113
- wrapcheck
- maligned
- exhaustivestruct
- testpackage
- paralleltest
- tparallel
- nosnakecase
issues:
exclude-use-default: false
max-per-linter: 0
max-same-issues: 0
exclude:
- don't use an underscore in package name
Expand All @@ -57,3 +52,7 @@ issues:
- path: themepark.go
linters:
- exhaustruct
exclude-files:
- httputil/header/header.go
- apps/app_name.go
- themes/theme_name.go
32 changes: 17 additions & 15 deletions themepark.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,33 @@ func (config *Config) setDefaults() {
}

if config.Theme == "" || config.Theme == "base" {
config.Theme = fmt.Sprintf("%s-base", config.App)
config.Theme = config.App + "-base"
}

if config.Target == "" {
config.Target = config.getRegexTarget()
}
}

var bodyBasedAppsList []string = []string{
"vuetorrent",
"qbittorrent",
"emby",
"jellyfin",
"radarr",
"prowlarr",
"sonarr",
"readarr",
"lidarr",
"whisparr",
}
func getBodyBasedAppsRegex() string {
bodyBasedAppsList := []string{
"vuetorrent",
"qbittorrent",
"emby",
"jellyfin",
"radarr",
"prowlarr",
"sonarr",
"readarr",
"lidarr",
"whisparr",
}

var bodyBasedApps string = "(?i)" + strings.Join(bodyBasedAppsList, "|")
return "(?i)" + strings.Join(bodyBasedAppsList, "|")
}

func (config *Config) getRegexTarget() string {
match, _ := regexp.Match(bodyBasedApps, []byte(config.App))
match, _ := regexp.MatchString(getBodyBasedAppsRegex(), config.App)
if match {
return "</body>"
}
Expand Down
4 changes: 2 additions & 2 deletions themepark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ func TestServeHTTP(t *testing.T) {
t.Run(test.desc, func(t *testing.T) {
config := test.config

next := func(responseWriter http.ResponseWriter, req *http.Request) {
next := func(responseWriter http.ResponseWriter, _ *http.Request) {
responseWriter.Header().Set("Content-Encoding", test.contentEncoding)
responseWriter.Header().Set("Content-Type", test.contentType)
responseWriter.Header().Set("Content-Length", strconv.Itoa(len(test.resBody)))
responseWriter.WriteHeader(http.StatusOK)

_, _ = fmt.Fprintf(responseWriter, test.resBody)
_, _ = fmt.Fprintf(responseWriter, "%s", test.resBody)
}

rewriteBody, err := New(context.Background(), http.HandlerFunc(next), &config, "rewriteBody")
Expand Down

0 comments on commit 2c9fc37

Please sign in to comment.