Skip to content

Bump golang and golangci versions #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.55.2
version: v1.64.5
working-directory: ./

- name: Install dependencies
Expand Down
149 changes: 140 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,57 @@ run:
timeout: 5m

linters:
disable-all: true
disable-all:
true
# Disabled linters:
# canonicalheader
# decorder
# dupword
# err113
# exhaustruct
# forbidigo
# forcetypeassert # заменён на errcheck
# funlen
# ginkgolinter
# gofmt # заменён на goimports
# gofumpt # заменён на goimports
# goheader
# gomoddirectives
# gomodguard # используется более мощный depguard
# gosmopolitan
# grouper
# interfacebloat
# intrange
# ireturn
# lll
# loggercheck
# mirror
# misspell # бесполезный
# nonamedreturns
# nlreturn # слишком строгий и в основном код не более читабелен
# paralleltest # слишком много ложных срабатываний
# protogetter
# sloglint
# spancheck
# sqlclosecheck
# tagalign
# tenv # заменён на usetesting.os-setenv: true
# testableexamples
# testpackage
# varnamelen
# wastedassign
# wsl # слишком строгий и в основном код не более читабелен
# zerologlint
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- copyloopvar
- cyclop
- depguard
- dogsled
- dupl
- durationcheck
Expand All @@ -20,59 +62,86 @@ linters:
- errname
- errorlint
- exhaustive
- exportloopref
- forcetypeassert
- exptostd
- fatcontext
- gci
- gocheckcompilerdirectives
- gochecknoglobals
- gochecknoinits
- gochecksumtype
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- gofmt
- goimports
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- iface
- importas
- inamedparam
- ineffassign
- maintidx
- makezero
- misspell
- mnd # https://golangci-lint.run/usage/linters/#mnd
- musttag
- nakedret
- nestif
- nilerr
- nilnesserr
- nilnil
- nlreturn
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
- reassign
- recvcheck
- revive
- rowserrcheck
- staticcheck
- stylecheck
- tagliatelle
- testifylint
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
- whitespace
- wrapcheck

linters-settings:
cyclop:
max-complexity: 15
skip-tests: true
depguard:
rules:
main:
list-mode: lax
deny:
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package
- pkg: "github.com/golang/protobuf"
desc: "Use google.golang.org/protobuf instead, see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules"
errcheck:
check-type-assertions: true
errorlint:
errorf: false
exhaustive:
# Presence of "default" case in switch statements satisfies exhaustiveness,
# even if all enum members are not listed.
default-signifies-exhaustive: true
# Only run exhaustive check on switches with "//exhaustive:enforce" comment.
explicit-exhaustive-switch: true
gci:
sections:
- standard
Expand All @@ -81,8 +150,70 @@ linters-settings:
gocognit:
min-complexity: 10
gocyclo:
min-complexity: 10
min-complexity: 15
goimports:
local-prefixes: capuchin
gosec:
excludes:
- G108 # Profiling endpoint automatically exposed on /debug/pprof
govet:
# Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers.
enable-all: true
disable:
- fieldalignment # Использовать при необходимости, ухудшается читаемость кода
- slog # На проекте используется zap
settings:
shadow:
strict: true
iface:
enable:
- identical
- unused
- opaque
nestif:
min-complexity: 4
nolintlint:
require-explanation: true
require-specific: true
revive:
enable-all-rules: true
rules:
- name: add-constant
disabled: true
- name: cognitive-complexity
disabled: true
- name: comment-spacings
disabled: true
- name: cyclomatic
disabled: true
- name: function-length
disabled: true
- name: line-length-limit
disabled: true
- name: max-public-structs
disabled: true
- name: unused-parameter
disabled: true
rowserrcheck:
packages:
- github.com/jmoiron/sqlx
tagliatelle:
case:
use-field-name: true
testifylint:
enable-all: true
disable:
- require-error
unparam:
check-exported: true

issues:
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 50

exclude-rules:
- linters:
- govet
text: '^shadow: declaration of "err" shadows declaration.+'
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang 1.21.4
golangci-lint 1.55.2
golang 1.23.6
golangci-lint 1.64.5
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# STEP 1 build executable binary #
##################################

FROM golang:1.21.4-alpine as builder
FROM golang:1.23.6-alpine as builder

LABEL org.opencontainers.image.source="https://github.com/phpgeeks-club/admin-bot"

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module geeksonator

go 1.21
go 1.23.6

require (
github.com/caarlos0/env/v10 v10.0.0
Expand Down
4 changes: 2 additions & 2 deletions internal/app/geeksonator/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Start() error {
if err != nil {
return fmt.Errorf("newLogger: %v", err)
}
defer logger.Sync() //nolint:errcheck
defer logger.Sync() //nolint:errcheck // it's ok

var tgBotToken string
if cfg.DebugMode {
Expand Down Expand Up @@ -118,7 +118,7 @@ func Start() error {
}

// newLogger creates new logger.
func newLogger(debugMode bool) (*zap.Logger, error) {
func newLogger(debugMode bool) (*zap.Logger, error) { //nolint:revive // false positive
if debugMode {
logger, err := zap.NewDevelopment()
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions internal/observer/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func authorIsAdmin(admins []tgbotapi.ChatMember, userID int64) bool {
}

// getMessageText returns message text.
func getMessageText(text string) string { //nolint:cyclop,gocyclo
func getMessageText(text string) string {
switch text {
case "/help", "/хелп":
return `БОТ РАБОТАЕТ ТОЛЬКО У АДМИНОВ.
Expand All @@ -219,7 +219,8 @@ func getMessageText(text string) string { //nolint:cyclop,gocyclo
[<code>/fl</code>, <code>/фл</code>] @freelanceGeeks - IT фриланс, ищем исполнителей и заказчиков, делимся опытом и проблемами связанными с фрилансом.
[<code>/job</code>, <code>/раб</code>] Объединяет сразу две команды: <code>/hr</code> и <code>/fl</code>.
[<code>/code</code>, <code>/код</code>] Код в нашем чате <a href="https://t.me/phpGeeks/1318040">ложут</a> на pastebin.org, gist.github.com или любой аналогичный ресурс (с)der_Igel
[<code>/nometa</code>, <code>/номета</code>] nometa.xyz`
[<code>/nometa</code>, <code>/номета</code>] nometa.xyz
[<code>/wtf</code>, <code>/втф</code>] А причём тут пхп?`
case "/php", "/пхп":
return "@phpGeeks - Best PHP chat"
case "/jun", "/джун":
Expand All @@ -243,6 +244,8 @@ func getMessageText(text string) string { //nolint:cyclop,gocyclo
return "Код в нашем чате <a href=\"https://t.me/phpGeeks/1318040\">ложут</a> на pastebin.org, gist.github.com или любой аналогичный ресурс (с)der_Igel"
case "/nometa", "/номета":
return "nometa.xyz"
case "/wtf", "/втф":
return "А причём тут пхп?"
}

return ""
Expand Down
9 changes: 1 addition & 8 deletions internal/observer/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func TestNewManager(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -57,7 +56,7 @@ func TestNewManagerWithDebug(t *testing.T) {
t.Parallel()

m := NewManager(nil, nil, nil, WithDebug(zap.NewNop()))
assert.NotEqual(t, nil, m.logger)
assert.NotNil(t, m.logger)
}

func TestNewManagerWithSkipAdminCheck(t *testing.T) {
Expand Down Expand Up @@ -183,7 +182,6 @@ func TestManager_processingUpdate(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -359,7 +357,6 @@ func TestManager_processingMessage(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -529,7 +526,6 @@ func TestManager_sendMessage(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -636,7 +632,6 @@ func TestManager_getAdmins(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -689,7 +684,6 @@ func Test_authorIsAdmin(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -719,7 +713,6 @@ func Test_getMessageText(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion internal/provider/telegram/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *Service) GetChatAdministrators(chatConfig tgbotapi.ChatConfig) ([]tgbot
}

// NewMessage creates new message.
func (s *Service) NewMessage(chatID int64, text string) tgbotapi.MessageConfig {
func (*Service) NewMessage(chatID int64, text string) tgbotapi.MessageConfig {
return tgbotapi.NewMessage(chatID, text)
}

Expand Down
Loading